@checkstack/script-packages-backend 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +106 -0
- package/drizzle/0002_dry_sue_storm.sql +27 -0
- package/drizzle/meta/0002_snapshot.json +666 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +11 -8
- package/src/audit-delta.test.ts +127 -0
- package/src/audit-delta.ts +100 -0
- package/src/audit-parse.test.ts +128 -0
- package/src/audit-parse.ts +147 -0
- package/src/audit-runner.test.ts +230 -0
- package/src/audit-runner.ts +224 -0
- package/src/audit-scanner.test.ts +101 -0
- package/src/audit-scanner.ts +156 -0
- package/src/hooks.ts +14 -0
- package/src/index.ts +264 -3
- package/src/router.ts +49 -0
- package/src/sandbox-policy-router.test.ts +105 -0
- package/src/sandbox-policy.test.ts +119 -0
- package/src/sandbox-policy.ts +68 -0
- package/src/sandbox-startup-log.test.ts +128 -0
- package/src/sandbox-startup-log.ts +83 -0
- package/src/schema.ts +53 -1
- package/src/sdk-types-route.test.ts +121 -0
- package/src/sdk-types-route.ts +137 -0
- package/src/stores.ts +216 -1
- package/tsconfig.json +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,111 @@
|
|
|
1
1
|
# @checkstack/script-packages-backend
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [13373ce]
|
|
8
|
+
- @checkstack/common@0.14.0
|
|
9
|
+
- @checkstack/backend-api@0.21.1
|
|
10
|
+
- @checkstack/auth-common@0.8.1
|
|
11
|
+
- @checkstack/notification-common@1.3.1
|
|
12
|
+
- @checkstack/script-packages-common@0.3.1
|
|
13
|
+
- @checkstack/sdk@0.95.1
|
|
14
|
+
- @checkstack/secrets-backend@0.2.1
|
|
15
|
+
- @checkstack/secrets-common@0.2.1
|
|
16
|
+
|
|
17
|
+
## 0.3.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- 9dcc848: Add scheduled vulnerability auditing for Script Packages.
|
|
22
|
+
|
|
23
|
+
A daily recurring job runs `bun audit --json` against the installed script-packages tree, persists advisories to new plugin-owned Postgres tables (`script_package_audit_advisory` keyed by lockfile hash + advisory id, plus a `script_package_audit_state` singleton last-run summary), and notifies every holder of `script-packages.manage` when a new or severity-escalated advisory appears. All severities are recorded; notifications fire on medium/high/critical, with a stable per-advisory key + a durable `notified` flag suppressing repeat-notify on an unchanged set. The pass is single-flight across the cluster via the existing installer advisory lock (mutually exclusive with installs, storage migrations, and blob GC) and reuses the installer's scratch / `.npmrc` / registry setup, reporting purely from the lockfile. New `getAuditState` and `auditNow` RPCs (gated by `script-packages.manage`), a `SCRIPT_PACKAGES_AUDIT_COMPLETED` signal, and a "Vulnerability audit" section in the settings page with an "Audit now" button that live-refreshes on completion.
|
|
24
|
+
|
|
25
|
+
State and scale: audit results are the cluster-wide source of truth in Postgres (not the pod-local node_modules tree), so any pod returns the same advisories regardless of which pod ran the audit.
|
|
26
|
+
|
|
27
|
+
This is a beta minor.
|
|
28
|
+
|
|
29
|
+
- 9dcc848: Layered OS-level script sandbox, secure and fail-closed by default (epic #247).
|
|
30
|
+
|
|
31
|
+
Script and shell health checks and the `run_shell` / `run_script` automation actions now run inside a layered OS-level sandbox by default. The sandbox lives in `core/backend-api/src/script-sandbox/` (the single source of truth) and is enforced inside the shared runners, so it applies wherever a job runs.
|
|
32
|
+
|
|
33
|
+
Layers:
|
|
34
|
+
|
|
35
|
+
- Resource caps (CPU / memory / PID / FD / file-size, via `prlimit` on capable Linux; ESM JS-heap cap via `--max-old-space-size`; portable wall-clock timeout) and an OOM-safe streaming output cap.
|
|
36
|
+
- Privilege drop via a NON-ROOT supervisor model: the shipped images run the supervisor as non-root uid `65532`, so every sandboxed script inherits non-root and can never be host-root; filesystem + network confinement is delivered by ROOTLESS `bwrap`/`nsjail` via unprivileged user namespaces. `enforced.privilege` is truthful (true only when the child cannot run as host-root). Runners no longer pass `uid`/`gid` to `Bun.spawn` (a silent no-op and a forward-compat hazard).
|
|
37
|
+
- Filesystem isolation (`scratch-only` / `scratch-plus-ro`) confining the child to its per-run scratch dir over a read-only base; the interpreter path is RO-bound so the runtime execs, and `TMPDIR` is pinned to the in-namespace tmpfs.
|
|
38
|
+
- Network egress control: `deny` (routeless loopback-only netns), `allowlist` (real plumbed egress via macvlan OR rootless slirp4netns + an in-kernel nftables filter), and an always-on metadata / link-local block (`169.254.0.0/16`, `fe80::/10`, `fc00::/7`). No-blackhole invariant: `enforced.network` is never true when egress is actually severed or unfiltered; unpluggable egress degrades to surfaced host net.
|
|
39
|
+
- Per-run fork-bomb containment via RLIMIT*NPROC inside the fresh per-run user+PID namespace; a centralized forbidden-env denylist (`LD_PRELOAD`, `LD_LIBRARY_PATH`, `DYLD*_`, `NODE*OPTIONS`, `BUN*_`, caller `PATH` overrides).
|
|
40
|
+
- A validated tuned seccomp profile (`deploy/seccomp/checkstack-userns.json`) and a live `clone(CLONE_NEWUSER|CLONE_NEWNET)` capability probe (not the static sysctl), shipped by default in both Dockerfiles, `docker-compose.yml`, and `deploy/k8s/checkstack-sandbox.yaml`.
|
|
41
|
+
|
|
42
|
+
Global policy and operator surface:
|
|
43
|
+
|
|
44
|
+
- The global sandbox policy lives in ONE durable row owned by `script-packages` (its `ConfigService` row in shared `plugin_configs`). A single process-wide provider serves every runner; the two script plugins no longer register competing providers. A dedicated admin-only `script-sandbox.manage` permission gates both reading and writing the policy. New `getSandboxPolicy` / `setSandboxPolicy` endpoints and a Settings -> Script Sandbox admin UI (`enabled`, `onUnavailable`, network/filesystem/privilege modes, allow list, metadata block, resource caps). The startup capability/readiness log is emitted in-process by `script-packages-backend` (no fragile init-order RPC self-loop), and on a host that cannot enforce a layer a one-time startup warning explains the two local-dev paths (Docker, or set the global policy to `degrade`).
|
|
45
|
+
- Satellite relay: the WS protocol carries the resolved policy in the `authenticated` message and a `sandbox_policy` push-on-change; a satellite caches the last relayed policy and resolves every run through it.
|
|
46
|
+
|
|
47
|
+
BREAKING CHANGES (platform in BETA, shipped as minor):
|
|
48
|
+
|
|
49
|
+
- Scripts run sandboxed by default. The shipped global default is FAIL-CLOSED (`onUnavailable: "fail"`): when a requested layer cannot be enforced the run is REFUSED (clean `exitCode: -1`, never an unsandboxed spawn) rather than silently degrading. Deployments on hosts that cannot enforce a layer (no bubblewrap, user namespaces blocked, no `/proc` unmask) must run the official images with the documented runtime flags (the bundled seccomp profile + `systempaths=unconfined`, or k8s `procMount: Unmasked`), or set the global policy to `degrade`. On macOS / restricted containers the strong layers degrade to the portable subset and are surfaced per run.
|
|
50
|
+
- Default network posture is deny-egress (`allowlist` with an empty allow list, which resolves to the routeless `deny` path). Scripts calling external endpoints fail until those destinations are allowlisted in the global default. The always-on metadata / link-local block applies even under looser modes.
|
|
51
|
+
- The per-action / per-check `sandbox` config override and the transport `ScriptRequest.sandbox` field are removed; policy is global-only, so an automation/check author can no longer weaken the sandbox on their own item. Stored configs carrying a stray `sandbox` key are tolerated (stripped on parse).
|
|
52
|
+
- The shared runners' `run()` no longer accepts a `sandbox` option; callers rely on the global policy provider.
|
|
53
|
+
- A satellite fails closed (most restrictive profile) until it receives the first relayed policy; a relay-read failure or an older core keeps it fail-closed. A relay failure can never loosen a satellite's sandbox.
|
|
54
|
+
|
|
55
|
+
State and scale: the global policy is a single durable Postgres row read identically on every pod. Capability detection is per-process, deterministic from the host kernel, and surfaced per run via the `EffectiveSandbox` report (a Linux pod and a macOS satellite may legitimately differ). `CHECKSTACK_SANDBOX_UID/GID` and macvlan addressing are genuinely per-host infrastructure, surfaced per run, not the queryable policy. The satellite's policy cache is satellite-local transport state. No new pod-local current-state.
|
|
56
|
+
|
|
57
|
+
This is a beta minor.
|
|
58
|
+
|
|
59
|
+
- 9dcc848: Add the auto-generated, version-pinned `@checkstack/sdk` package + codegen, and serve its types live to the in-app editor.
|
|
60
|
+
|
|
61
|
+
- A new committed workspace package `@checkstack/sdk`, generated from the platform's source of truth by `scripts/generate-sdk.ts` (`generate:sdk` / `generate:sdk:check`): a fully-typed oRPC client (`createCheckstackClient`) over the REST surface with one `InferClient` per plugin contract, real script-authoring helpers (`@checkstack/sdk/healthcheck`, `@checkstack/sdk/integration`) whose runtime body is the same identity function the in-app runner injects, per-subpath `.d.ts` under the package `exports` map, and an editor-only ambient bundle. A `generate:sdk:check` CI guard fails when the committed SDK files drift from a fresh generation. The `@checkstack/sdk` version is stamped from `@checkstack/release` and MUST NOT appear in a changeset (a guard enforces this); the `@checkstack/release` bump here advances the release version so the generated SDK can be published later. The generated client also normalizes its base URL without a backtracking-prone regex, closing a CodeQL `js/polynomial-redos` finding.
|
|
62
|
+
- Live editor type injection: a new version-keyed route `GET /api/script-packages/sdk-types/:releaseVersion` (raw handler in `@checkstack/script-packages-backend`) serves the generated SDK editor bundle with `Cache-Control: private, max-age=1y, immutable`; the pure path-build/parse module lives in `@checkstack/script-packages-common`, shared by backend and frontend. A mismatched version returns `409` so the editor refetches and never serves stale types after an upgrade. The frontend `useSdkTypeInjection` hook fetches the bundle once per session and mounts it into Monaco via `addExtraLib`. Schema-narrowed `context.config` / `context.event.payload` editor types stay local; the package-resolving module declarations come from the one published `@checkstack/sdk` source.
|
|
63
|
+
|
|
64
|
+
BREAKING CHANGES: the script-authoring import surface moves from the bare `@checkstack/healthcheck` / `@checkstack/integration` virtual modules to the `@checkstack/sdk/healthcheck` / `@checkstack/sdk/integration` subpaths of the published `@checkstack/sdk` package. The old bare-name imports no longer resolve (an old import now errors in the editor, surfacing the migration). Existing scripts must update the module specifier:
|
|
65
|
+
|
|
66
|
+
- import { defineHealthCheck } from "@checkstack/healthcheck";
|
|
67
|
+
+ import { defineHealthCheck } from "@checkstack/sdk/healthcheck";
|
|
68
|
+
|
|
69
|
+
- import { defineIntegration } from "@checkstack/integration";
|
|
70
|
+
+ import { defineIntegration } from "@checkstack/sdk/integration";
|
|
71
|
+
|
|
72
|
+
The helper names and their runtime behaviour are unchanged - only the module specifier moves. The global (no-import) helper form continues to work unchanged.
|
|
73
|
+
|
|
74
|
+
This is a beta minor.
|
|
75
|
+
|
|
76
|
+
- 9dcc848: Align workspace dependency versions and migrate React Router to v7.
|
|
77
|
+
|
|
78
|
+
BREAKING CHANGES (React Router v7): All frontend packages now depend on `react-router-dom@^7.16.0`. Previously the workspace declared four divergent ranges (`^6.20.0`, `^6.22.0`, `^7.1.1`, `^7.14.2`), which resolved both `react-router@6` and `react-router@7` into a single bundle. Everything is now unified on v7. The public imports the app uses (`BrowserRouter`, `Routes`, `Route`, `Link`, `NavLink`, `MemoryRouter`, `useNavigate`, `useParams`, `useSearchParams`, `useLocation`) are unchanged between v6 and v7, so no source rewrites were required - but any out-of-tree plugin still on react-router v6 should upgrade to v7 (see the React Router v6 -> v7 upgrade guide) to share the host's single router instance via the import map.
|
|
79
|
+
|
|
80
|
+
Other unified ranges (no API change): `react` -> `^18.3.1`, the `@orpc/*` family (`contract`, `server`, `client`, `tanstack-query`, `openapi`, `zod`) -> `^1.14.4`, and `better-auth` -> `^1.6.13`.
|
|
81
|
+
|
|
82
|
+
Removed the pre-rename `@orpc/react-query` leftover from `@checkstack/frontend-api`; its `createRouterUtils` / `RouterUtils` / `ProcedureUtils` now come from `@orpc/tanstack-query` (the package already in use).
|
|
83
|
+
|
|
84
|
+
Stale in-range runtime deps pulled up to current published versions: `hono` `^4.12.23`, `@tanstack/react-query` (+devtools) `^5.100.14`, `date-fns` `^4.4.0`, `jose` `^6.2.3`, `tar` `^7.5.16`, `semver` `^7.8.1`, `@xyflow/react` `^12.11.0`.
|
|
85
|
+
|
|
86
|
+
### Patch Changes
|
|
87
|
+
|
|
88
|
+
- Updated dependencies [9dcc848]
|
|
89
|
+
- Updated dependencies [9dcc848]
|
|
90
|
+
- Updated dependencies [9dcc848]
|
|
91
|
+
- Updated dependencies [9dcc848]
|
|
92
|
+
- Updated dependencies [9dcc848]
|
|
93
|
+
- Updated dependencies [9dcc848]
|
|
94
|
+
- Updated dependencies [9dcc848]
|
|
95
|
+
- Updated dependencies [9dcc848]
|
|
96
|
+
- Updated dependencies [9dcc848]
|
|
97
|
+
- Updated dependencies [9dcc848]
|
|
98
|
+
- Updated dependencies [9dcc848]
|
|
99
|
+
- Updated dependencies [9dcc848]
|
|
100
|
+
- @checkstack/auth-common@0.8.0
|
|
101
|
+
- @checkstack/backend-api@0.21.0
|
|
102
|
+
- @checkstack/notification-common@1.3.0
|
|
103
|
+
- @checkstack/common@0.13.0
|
|
104
|
+
- @checkstack/script-packages-common@0.3.0
|
|
105
|
+
- @checkstack/secrets-backend@0.2.0
|
|
106
|
+
- @checkstack/secrets-common@0.2.0
|
|
107
|
+
- @checkstack/sdk@0.93.1
|
|
108
|
+
|
|
3
109
|
## 0.2.1
|
|
4
110
|
|
|
5
111
|
### Patch Changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
CREATE TABLE "script_package_audit_advisory" (
|
|
2
|
+
"lockfile_hash" text NOT NULL,
|
|
3
|
+
"advisory_id" text NOT NULL,
|
|
4
|
+
"package_name" text NOT NULL,
|
|
5
|
+
"title" text DEFAULT '' NOT NULL,
|
|
6
|
+
"severity" text NOT NULL,
|
|
7
|
+
"vulnerable_versions" text DEFAULT '' NOT NULL,
|
|
8
|
+
"url" text,
|
|
9
|
+
"cvss_score" double precision,
|
|
10
|
+
"notified" boolean DEFAULT false NOT NULL,
|
|
11
|
+
"first_seen_at" timestamp DEFAULT now() NOT NULL,
|
|
12
|
+
CONSTRAINT "script_package_audit_advisory_lockfile_hash_advisory_id_package_name_pk" PRIMARY KEY("lockfile_hash","advisory_id","package_name")
|
|
13
|
+
);
|
|
14
|
+
--> statement-breakpoint
|
|
15
|
+
CREATE TABLE "script_package_audit_state" (
|
|
16
|
+
"id" text PRIMARY KEY DEFAULT 'singleton' NOT NULL,
|
|
17
|
+
"last_run_at" timestamp,
|
|
18
|
+
"lockfile_hash" text,
|
|
19
|
+
"total" integer DEFAULT 0 NOT NULL,
|
|
20
|
+
"count_low" integer DEFAULT 0 NOT NULL,
|
|
21
|
+
"count_moderate" integer DEFAULT 0 NOT NULL,
|
|
22
|
+
"count_high" integer DEFAULT 0 NOT NULL,
|
|
23
|
+
"count_critical" integer DEFAULT 0 NOT NULL,
|
|
24
|
+
"error_message" text
|
|
25
|
+
);
|
|
26
|
+
--> statement-breakpoint
|
|
27
|
+
CREATE INDEX "script_package_audit_advisory_hash_idx" ON "script_package_audit_advisory" USING btree ("lockfile_hash");
|