opencode-agent-orchestration-kit 1.0.28 → 1.0.29
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/README.md +19 -9
- package/docker/open-design/Dockerfile +2 -2
- package/docs/compatibility.md +28 -8
- package/docs/docker-open-design.md +8 -0
- package/docs/installation.md +9 -3
- package/docs/quickstart.md +6 -3
- package/docs/releases/v1.0.29.md +78 -0
- package/docs/security.md +9 -0
- package/docs/superpowers.md +11 -4
- package/docs/supply-chain.md +145 -0
- package/docs/workflows.md +15 -0
- package/opencode/opencode.json +1 -1
- package/opencode/package-lock.json +92 -95
- package/opencode/package.json +2 -1
- package/package.json +25 -3
- package/scripts/check-compatibility.mjs +65 -12
- package/scripts/check-compatibility.test.mjs +228 -32
- package/scripts/check-supply-chain.mjs +635 -0
- package/scripts/check-supply-chain.test.mjs +944 -0
- package/scripts/check.sh +9 -5
- package/scripts/install-smoke.sh +1 -1
- package/scripts/opencode-compat-smoke.sh +97 -7
- package/scripts/package-smoke.mjs +357 -0
- package/scripts/package-smoke.sh +5 -0
- package/scripts/package-smoke.test.mjs +256 -0
- package/scripts/version.test.mjs +2 -2
- package/supply-chain.json +34 -0
- package/.github/CODEOWNERS +0 -1
- package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -65
- package/.github/ISSUE_TEMPLATE/config.yml +0 -11
- package/.github/ISSUE_TEMPLATE/documentation.yml +0 -22
- package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -43
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -25
- package/.github/workflows/check.yml +0 -92
- package/.github/workflows/compatibility-canary.yml +0 -28
|
@@ -0,0 +1,944 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import test from "node:test";
|
|
6
|
+
import { spawnSync } from "node:child_process";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
checkSupplyChain,
|
|
11
|
+
validateSupplyChainData,
|
|
12
|
+
} from "./check-supply-chain.mjs";
|
|
13
|
+
|
|
14
|
+
const SCRIPTS_ROOT = path.dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
const PACKAGE_FILES = [
|
|
16
|
+
"CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "NOTICE.md", "README.md",
|
|
17
|
+
"SECURITY.md", "compatibility.json", "docker/", "docs/", "doctor.sh",
|
|
18
|
+
"env.example", "install.sh", "opencode/", "rollback.sh", "scripts/",
|
|
19
|
+
"supply-chain.json", "uninstall.sh", "upgrade.sh",
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const VALID = {
|
|
23
|
+
schema_version: 1,
|
|
24
|
+
external_refs: {
|
|
25
|
+
superpowers: {
|
|
26
|
+
release: "v6.1.1",
|
|
27
|
+
commit: "d884ae04edebef577e82ff7c4e143debd0bbec99",
|
|
28
|
+
},
|
|
29
|
+
actions_checkout: {
|
|
30
|
+
release: "v6",
|
|
31
|
+
commit: "d23441a48e516b6c34aea4fa41551a30e30af803",
|
|
32
|
+
},
|
|
33
|
+
actions_setup_node: {
|
|
34
|
+
release: "v6",
|
|
35
|
+
commit: "249970729cb0ef3589644e2896645e5dc5ba9c38",
|
|
36
|
+
},
|
|
37
|
+
open_design: {
|
|
38
|
+
commit: "1592beb96134f9d49b8a90dc6a359b94a69af57e",
|
|
39
|
+
},
|
|
40
|
+
node_image: {
|
|
41
|
+
tag: "24-bookworm-slim",
|
|
42
|
+
digest: "sha256:6f7b03f7c2c8e2e784dcf9295400527b9b1270fd37b7e9a7285cf83b6951452d",
|
|
43
|
+
},
|
|
44
|
+
pnpm: { version: "10.33.2" },
|
|
45
|
+
opencode_ai: { version: "1.14.31" },
|
|
46
|
+
},
|
|
47
|
+
npm_overrides: {
|
|
48
|
+
"@babel/core": "7.29.7",
|
|
49
|
+
uuid: "14.0.0",
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
function cloneValid() {
|
|
54
|
+
return structuredClone(VALID);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function expectInvalid(mutator, message) {
|
|
58
|
+
const data = cloneValid();
|
|
59
|
+
mutator(data);
|
|
60
|
+
assert.throws(
|
|
61
|
+
() => validateSupplyChainData(data),
|
|
62
|
+
(error) => error.code === "INVALID_SUPPLY_CHAIN" && error.message.includes(message),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function withFixture(data, callback) {
|
|
67
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), "supply-chain-test-"));
|
|
68
|
+
try {
|
|
69
|
+
fs.writeFileSync(path.join(root, "supply-chain.json"), `${JSON.stringify(data)}\n`);
|
|
70
|
+
return callback(root);
|
|
71
|
+
} finally {
|
|
72
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const SUPERPOWERS_REF = `superpowers@git+https://github.com/obra/superpowers.git#${VALID.external_refs.superpowers.commit}`;
|
|
77
|
+
const CHECKOUT_USE = `actions/checkout@${VALID.external_refs.actions_checkout.commit} # ${VALID.external_refs.actions_checkout.release}`;
|
|
78
|
+
const SETUP_NODE_USE = `actions/setup-node@${VALID.external_refs.actions_setup_node.commit} # ${VALID.external_refs.actions_setup_node.release}`;
|
|
79
|
+
|
|
80
|
+
function canonicalPolicy() {
|
|
81
|
+
return `# Supply-chain policy
|
|
82
|
+
|
|
83
|
+
<!-- supply-chain-pins:start -->
|
|
84
|
+
| Surface | Reviewed label | Immutable identifier |
|
|
85
|
+
|---|---|---|
|
|
86
|
+
| Superpowers | ${VALID.external_refs.superpowers.release} | \`${VALID.external_refs.superpowers.commit}\` |
|
|
87
|
+
| actions/checkout | ${VALID.external_refs.actions_checkout.release} | \`${VALID.external_refs.actions_checkout.commit}\` |
|
|
88
|
+
| actions/setup-node | ${VALID.external_refs.actions_setup_node.release} | \`${VALID.external_refs.actions_setup_node.commit}\` |
|
|
89
|
+
| Open Design | reviewed commit | \`${VALID.external_refs.open_design.commit}\` |
|
|
90
|
+
| Node image | ${VALID.external_refs.node_image.tag} | \`${VALID.external_refs.node_image.digest}\` |
|
|
91
|
+
| pnpm | ${VALID.external_refs.pnpm.version} | exact version |
|
|
92
|
+
| opencode-ai | ${VALID.external_refs.opencode_ai.version} | exact version |
|
|
93
|
+
| @babel/core override | ${VALID.npm_overrides["@babel/core"]} | exact version |
|
|
94
|
+
| uuid override | ${VALID.npm_overrides.uuid} | exact version |
|
|
95
|
+
<!-- supply-chain-pins:end -->
|
|
96
|
+
|
|
97
|
+
Automated installs with intact shipped manifests use \`npm ci --ignore-scripts\`.
|
|
98
|
+
The canonical checksum format is \`<64 lowercase hexadecimal characters> opencode-agent-orchestration-kit-<version>.tgz\`.
|
|
99
|
+
Publication is never performed by checks and requires separate explicit authorization.
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function writeValidDocumentation(root) {
|
|
104
|
+
fs.mkdirSync(path.join(root, "docs/superpowers/specs"), { recursive: true });
|
|
105
|
+
fs.mkdirSync(path.join(root, "docs/superpowers/plans"), { recursive: true });
|
|
106
|
+
fs.mkdirSync(path.join(root, "docs/releases"), { recursive: true });
|
|
107
|
+
fs.writeFileSync(path.join(root, "docs/supply-chain.md"), canonicalPolicy());
|
|
108
|
+
fs.writeFileSync(path.join(root, "README.md"), `${SUPERPOWERS_REF}\nnpm ci --ignore-scripts\n`);
|
|
109
|
+
fs.writeFileSync(path.join(root, "docs/superpowers.md"), `${SUPERPOWERS_REF}\n`);
|
|
110
|
+
fs.writeFileSync(
|
|
111
|
+
path.join(root, "docs/docker-open-design.md"),
|
|
112
|
+
`node:${VALID.external_refs.node_image.tag}@${VALID.external_refs.node_image.digest}\nOPEN_DESIGN_REF=${VALID.external_refs.open_design.commit}\nOPENCODE_AI_VERSION=${VALID.external_refs.opencode_ai.version}\npnpm@${VALID.external_refs.pnpm.version} with pnpm install --frozen-lockfile\n`,
|
|
113
|
+
);
|
|
114
|
+
fs.writeFileSync(path.join(root, "docs/installation.md"), "npm ci --ignore-scripts\n");
|
|
115
|
+
fs.writeFileSync(path.join(root, "docs/quickstart.md"), "npm ci --ignore-scripts\nnpm run check:release\n");
|
|
116
|
+
fs.writeFileSync(path.join(root, "docs/compatibility.md"), "core smoke\ndefault-config smoke\n");
|
|
117
|
+
fs.writeFileSync(path.join(root, "docs/security.md"), "npm audit signatures\npackage-smoked tarball\nSHA-256 checksum\n");
|
|
118
|
+
fs.writeFileSync(path.join(root, "docs/workflows.md"), "package artifact\nchecksum\npost-publication verification\n");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function writeValidSurfaceFiles(root) {
|
|
122
|
+
fs.mkdirSync(path.join(root, "opencode"), { recursive: true });
|
|
123
|
+
fs.writeFileSync(path.join(root, "opencode/opencode.json"), `${JSON.stringify({
|
|
124
|
+
plugin: [SUPERPOWERS_REF],
|
|
125
|
+
})}\n`);
|
|
126
|
+
fs.mkdirSync(path.join(root, ".github/workflows"), { recursive: true });
|
|
127
|
+
fs.writeFileSync(
|
|
128
|
+
path.join(root, ".github/workflows/check.yml"),
|
|
129
|
+
`steps:\n - uses: ${CHECKOUT_USE}\n - uses: ${SETUP_NODE_USE}\n - working-directory: opencode\n run: npm ci --ignore-scripts\n`,
|
|
130
|
+
);
|
|
131
|
+
fs.writeFileSync(
|
|
132
|
+
path.join(root, ".github/workflows/compatibility-canary.yml"),
|
|
133
|
+
`# compatibility-canary:start\nsteps:\n - uses: ${CHECKOUT_USE}\n - uses: ${SETUP_NODE_USE}\n - run: bash scripts/opencode-compat-smoke.sh latest\n# compatibility-canary:end\n`,
|
|
134
|
+
);
|
|
135
|
+
fs.mkdirSync(path.join(root, "docker/open-design"), { recursive: true });
|
|
136
|
+
fs.writeFileSync(
|
|
137
|
+
path.join(root, "docker/open-design/Dockerfile"),
|
|
138
|
+
`FROM node:${VALID.external_refs.node_image.tag}@${VALID.external_refs.node_image.digest}\nARG OPEN_DESIGN_REF=${VALID.external_refs.open_design.commit}\nARG OPENCODE_AI_VERSION=${VALID.external_refs.opencode_ai.version}\nRUN corepack prepare pnpm@${VALID.external_refs.pnpm.version} --activate \\\n && pnpm install --frozen-lockfile\n`,
|
|
139
|
+
);
|
|
140
|
+
fs.appendFileSync(
|
|
141
|
+
path.join(root, "docker/open-design/Dockerfile"),
|
|
142
|
+
'RUN git checkout "$OPEN_DESIGN_REF"\nRUN npm install -g "opencode-ai@$OPENCODE_AI_VERSION"\n',
|
|
143
|
+
);
|
|
144
|
+
fs.mkdirSync(path.join(root, "scripts"), { recursive: true });
|
|
145
|
+
fs.writeFileSync(
|
|
146
|
+
path.join(root, "scripts/package-smoke.sh"),
|
|
147
|
+
"#!/usr/bin/env bash\nset -euo pipefail\nexec node scripts/package-smoke.mjs \"$@\"\n",
|
|
148
|
+
{ mode: 0o755 },
|
|
149
|
+
);
|
|
150
|
+
fs.writeFileSync(path.join(root, "scripts/package-smoke.mjs"), "export {};\n");
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function withSurfaceFixture(callback) {
|
|
154
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), "supply-chain-surfaces-test-"));
|
|
155
|
+
try {
|
|
156
|
+
fs.writeFileSync(path.join(root, "supply-chain.json"), `${JSON.stringify(VALID)}\n`);
|
|
157
|
+
fs.writeFileSync(path.join(root, "package.json"), `${JSON.stringify({
|
|
158
|
+
files: PACKAGE_FILES,
|
|
159
|
+
scripts: {
|
|
160
|
+
"dependency-audit": "npm --prefix opencode audit --omit=dev --audit-level=low",
|
|
161
|
+
"dependency-signature-audit": "npm --prefix opencode audit signatures",
|
|
162
|
+
"check:release": "npm --prefix opencode ci --ignore-scripts && npm run check",
|
|
163
|
+
"package-smoke": "bash scripts/package-smoke.sh",
|
|
164
|
+
},
|
|
165
|
+
})}\n`);
|
|
166
|
+
writeValidSurfaceFiles(root);
|
|
167
|
+
writeValidDocumentation(root);
|
|
168
|
+
fs.writeFileSync(path.join(root, "opencode/package.json"), `${JSON.stringify({
|
|
169
|
+
overrides: { ...VALID.npm_overrides },
|
|
170
|
+
})}\n`);
|
|
171
|
+
fs.writeFileSync(path.join(root, "opencode/package-lock.json"), `${JSON.stringify({
|
|
172
|
+
lockfileVersion: 3,
|
|
173
|
+
packages: {
|
|
174
|
+
"": {},
|
|
175
|
+
"node_modules/@babel/core": {
|
|
176
|
+
version: VALID.npm_overrides["@babel/core"],
|
|
177
|
+
resolved: "https://registry.npmjs.org/@babel/core/-/core-7.29.7.tgz",
|
|
178
|
+
integrity: "sha512-babel",
|
|
179
|
+
},
|
|
180
|
+
"node_modules/uuid": {
|
|
181
|
+
version: VALID.npm_overrides.uuid,
|
|
182
|
+
resolved: "https://registry.npmjs.org/uuid/-/uuid-14.0.0.tgz",
|
|
183
|
+
integrity: "sha512-uuid",
|
|
184
|
+
},
|
|
185
|
+
"node_modules/example": {
|
|
186
|
+
version: "1.2.3",
|
|
187
|
+
resolved: "https://registry.npmjs.org/example/-/example-1.2.3.tgz",
|
|
188
|
+
integrity: "sha512-example",
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
})}\n`);
|
|
192
|
+
fs.writeFileSync(path.join(root, "scripts/install-smoke.sh"), "#!/usr/bin/env bash\nnpm ci --ignore-scripts\n", { mode: 0o755 });
|
|
193
|
+
return callback(root);
|
|
194
|
+
} finally {
|
|
195
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function withCliFixture(inventory, callback) {
|
|
200
|
+
const root = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), "supply-chain-cli-test-")));
|
|
201
|
+
const scripts = path.join(root, "scripts");
|
|
202
|
+
try {
|
|
203
|
+
fs.mkdirSync(scripts);
|
|
204
|
+
fs.copyFileSync(path.join(SCRIPTS_ROOT, "check-supply-chain.mjs"), path.join(scripts, "check-supply-chain.mjs"));
|
|
205
|
+
fs.copyFileSync(path.join(SCRIPTS_ROOT, "version.mjs"), path.join(scripts, "version.mjs"));
|
|
206
|
+
if (inventory !== undefined) {
|
|
207
|
+
const contents = typeof inventory === "string" ? inventory : `${JSON.stringify(inventory)}\n`;
|
|
208
|
+
fs.writeFileSync(path.join(root, "supply-chain.json"), contents);
|
|
209
|
+
if (typeof inventory !== "string") {
|
|
210
|
+
writeValidSurfaceFiles(root);
|
|
211
|
+
writeValidDocumentation(root);
|
|
212
|
+
fs.writeFileSync(path.join(root, "package.json"), `${JSON.stringify({
|
|
213
|
+
files: PACKAGE_FILES,
|
|
214
|
+
scripts: {
|
|
215
|
+
"dependency-audit": "npm --prefix opencode audit --omit=dev --audit-level=low",
|
|
216
|
+
"dependency-signature-audit": "npm --prefix opencode audit signatures",
|
|
217
|
+
"package-smoke": "bash scripts/package-smoke.sh",
|
|
218
|
+
},
|
|
219
|
+
})}\n`);
|
|
220
|
+
fs.writeFileSync(path.join(root, "opencode/package.json"), `${JSON.stringify({
|
|
221
|
+
overrides: { ...VALID.npm_overrides },
|
|
222
|
+
})}\n`);
|
|
223
|
+
fs.writeFileSync(path.join(root, "opencode/package-lock.json"), `${JSON.stringify({
|
|
224
|
+
packages: Object.fromEntries(Object.entries(VALID.npm_overrides).map(([name, version]) => [
|
|
225
|
+
`node_modules/${name}`,
|
|
226
|
+
{ version, resolved: `https://registry.npmjs.org/${name}/fixture.tgz`, integrity: "sha512-fixture" },
|
|
227
|
+
])),
|
|
228
|
+
})}\n`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const result = spawnSync(process.execPath, [path.join(scripts, "check-supply-chain.mjs")], {
|
|
232
|
+
cwd: root,
|
|
233
|
+
encoding: "utf8",
|
|
234
|
+
});
|
|
235
|
+
return callback(result);
|
|
236
|
+
} finally {
|
|
237
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
test("accepts the canonical supply-chain schema", () => {
|
|
242
|
+
assert.deepEqual(validateSupplyChainData(cloneValid()), VALID);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
test("rejects missing and unknown keys at every schema level", () => {
|
|
246
|
+
expectInvalid((data) => delete data.npm_overrides, "supply chain keys");
|
|
247
|
+
expectInvalid((data) => { data.unknown = true; }, "supply chain keys");
|
|
248
|
+
expectInvalid((data) => delete data.external_refs.pnpm, "external_refs keys");
|
|
249
|
+
expectInvalid((data) => { data.external_refs.unknown = {}; }, "external_refs keys");
|
|
250
|
+
expectInvalid((data) => delete data.external_refs.superpowers.commit, "external_refs.superpowers keys");
|
|
251
|
+
expectInvalid((data) => { data.external_refs.node_image.unknown = true; }, "external_refs.node_image keys");
|
|
252
|
+
expectInvalid((data) => delete data.npm_overrides.uuid, "npm_overrides keys");
|
|
253
|
+
expectInvalid((data) => { data.npm_overrides.extra = "1.0.0"; }, "npm_overrides keys");
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
test("requires schema version 1", () => {
|
|
257
|
+
expectInvalid((data) => { data.schema_version = 2; }, "schema_version must be 1");
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
test("requires lowercase full-length immutable commits", () => {
|
|
261
|
+
expectInvalid(
|
|
262
|
+
(data) => { data.external_refs.superpowers.commit = "D884AE04EDEBEF577E82FF7C4E143DEBD0BBEC99"; },
|
|
263
|
+
"external_refs.superpowers.commit",
|
|
264
|
+
);
|
|
265
|
+
expectInvalid(
|
|
266
|
+
(data) => { data.external_refs.open_design.commit = "1592beb"; },
|
|
267
|
+
"external_refs.open_design.commit",
|
|
268
|
+
);
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
test("requires a lowercase sha256 digest", () => {
|
|
272
|
+
expectInvalid(
|
|
273
|
+
(data) => { data.external_refs.node_image.digest = "sha256:not-a-digest"; },
|
|
274
|
+
"external_refs.node_image.digest",
|
|
275
|
+
);
|
|
276
|
+
expectInvalid(
|
|
277
|
+
(data) => { data.external_refs.node_image.digest = `sha256:${"A".repeat(64)}`; },
|
|
278
|
+
"external_refs.node_image.digest",
|
|
279
|
+
);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
test("requires canonical release labels", () => {
|
|
283
|
+
expectInvalid(
|
|
284
|
+
(data) => { data.external_refs.superpowers.release = "6.1.1"; },
|
|
285
|
+
"external_refs.superpowers.release",
|
|
286
|
+
);
|
|
287
|
+
expectInvalid(
|
|
288
|
+
(data) => { data.external_refs.actions_checkout.release = "v0"; },
|
|
289
|
+
"external_refs.actions_checkout.release",
|
|
290
|
+
);
|
|
291
|
+
expectInvalid(
|
|
292
|
+
(data) => { data.external_refs.actions_setup_node.release = "v6.0.0"; },
|
|
293
|
+
"external_refs.actions_setup_node.release",
|
|
294
|
+
);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
test("requires exact canonical versions without ranges", () => {
|
|
298
|
+
expectInvalid(
|
|
299
|
+
(data) => { data.external_refs.pnpm.version = "^10.33.2"; },
|
|
300
|
+
"external_refs.pnpm.version",
|
|
301
|
+
);
|
|
302
|
+
expectInvalid(
|
|
303
|
+
(data) => { data.external_refs.opencode_ai.version = "01.14.31"; },
|
|
304
|
+
"external_refs.opencode_ai.version",
|
|
305
|
+
);
|
|
306
|
+
expectInvalid(
|
|
307
|
+
(data) => { data.npm_overrides["@babel/core"] = ">=7.29.7"; },
|
|
308
|
+
"npm_overrides.@babel/core",
|
|
309
|
+
);
|
|
310
|
+
expectInvalid(
|
|
311
|
+
(data) => { data.npm_overrides.uuid = "14.0"; },
|
|
312
|
+
"npm_overrides.uuid",
|
|
313
|
+
);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
test("reads a safe regular canonical inventory without surface checks", () => {
|
|
317
|
+
withFixture(VALID, (root) => {
|
|
318
|
+
assert.deepEqual(checkSupplyChain(root, { surfaces: false }), VALID);
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
test("surface validation accepts exact overrides, regenerated lock entries, and frozen automated installs", () => {
|
|
323
|
+
withSurfaceFixture((root) => {
|
|
324
|
+
assert.deepEqual(checkSupplyChain(root), VALID);
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
test("surface validation requires the exact Superpowers commit", () => {
|
|
329
|
+
withSurfaceFixture((root) => {
|
|
330
|
+
const relative = "opencode/opencode.json";
|
|
331
|
+
const config = JSON.parse(fs.readFileSync(path.join(root, relative), "utf8"));
|
|
332
|
+
config.plugin = ["superpowers@git+https://github.com/obra/superpowers.git"];
|
|
333
|
+
fs.writeFileSync(path.join(root, relative), `${JSON.stringify(config)}\n`);
|
|
334
|
+
assert.throws(() => checkSupplyChain(root), /superpowers.*full reviewed commit/i);
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
for (const [label, replacement, message] of [
|
|
339
|
+
["major tag", "actions/checkout@v6 # v6", /full commit/i],
|
|
340
|
+
["short SHA", "actions/checkout@d23441a # v6", /full commit/i],
|
|
341
|
+
["missing release comment", `actions/checkout@${VALID.external_refs.actions_checkout.commit}`, /release comment.*v6/i],
|
|
342
|
+
["malformed release comment", `actions/checkout@${VALID.external_refs.actions_checkout.commit} #v6`, /uses syntax/i],
|
|
343
|
+
["unapproved tuple", `actions/cache@${VALID.external_refs.actions_checkout.commit} # v6`, /not present in supply-chain\.json/i],
|
|
344
|
+
]) {
|
|
345
|
+
test(`surface validation rejects an Action ${label}`, () => {
|
|
346
|
+
withSurfaceFixture((root) => {
|
|
347
|
+
const relative = ".github/workflows/check.yml";
|
|
348
|
+
const workflow = fs.readFileSync(path.join(root, relative), "utf8").replace(CHECKOUT_USE, replacement);
|
|
349
|
+
fs.writeFileSync(path.join(root, relative), workflow);
|
|
350
|
+
assert.throws(() => checkSupplyChain(root), message);
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
test("surface validation rejects undeclared latest in a stable workflow", () => {
|
|
356
|
+
withSurfaceFixture((root) => {
|
|
357
|
+
const relative = ".github/workflows/check.yml";
|
|
358
|
+
fs.appendFileSync(path.join(root, relative), " - run: npx stable-tool@latest\n");
|
|
359
|
+
assert.throws(() => checkSupplyChain(root), /@latest.*stable/i);
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
test("surface validation rejects a mutable git clone branch in a stable workflow command", () => {
|
|
364
|
+
withSurfaceFixture((root) => {
|
|
365
|
+
const relative = ".github/workflows/check.yml";
|
|
366
|
+
fs.appendFileSync(
|
|
367
|
+
path.join(root, relative),
|
|
368
|
+
" - run: git clone --branch main https://github.com/example/helper.git /tmp/helper\n",
|
|
369
|
+
);
|
|
370
|
+
assert.throws(() => checkSupplyChain(root), /mutable git clone --branch/i);
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
test("surface validation rejects an npm exec mutable major tag in a stable workflow command", () => {
|
|
375
|
+
withSurfaceFixture((root) => {
|
|
376
|
+
const relative = ".github/workflows/check.yml";
|
|
377
|
+
fs.appendFileSync(
|
|
378
|
+
path.join(root, relative),
|
|
379
|
+
" - run: npm exec example-cli@v6 -- --help\n",
|
|
380
|
+
);
|
|
381
|
+
assert.throws(() => checkSupplyChain(root), /npm exec.*mutable major tag/i);
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
test("surface validation rejects a scoped npm exec mutable major tag", () => {
|
|
386
|
+
withSurfaceFixture((root) => {
|
|
387
|
+
const relative = ".github/workflows/check.yml";
|
|
388
|
+
fs.appendFileSync(
|
|
389
|
+
path.join(root, relative),
|
|
390
|
+
" - run: npm exec @scope/example-cli@v6 -- --help\n",
|
|
391
|
+
);
|
|
392
|
+
assert.throws(() => checkSupplyChain(root), /npm exec.*mutable major tag/i);
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
test("surface validation accepts a scoped npm exec exact version", () => {
|
|
397
|
+
withSurfaceFixture((root) => {
|
|
398
|
+
fs.appendFileSync(
|
|
399
|
+
path.join(root, ".github/workflows/check.yml"),
|
|
400
|
+
" - run: npm exec @scope/example-cli@6.1.0 -- --help\n",
|
|
401
|
+
);
|
|
402
|
+
assert.deepEqual(checkSupplyChain(root), VALID);
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
for (const [label, command] of [
|
|
407
|
+
["plain", "npx example-cli@v6 --help"],
|
|
408
|
+
["scoped", "npx @scope/example-cli@v6 --help"],
|
|
409
|
+
["continued", "npx \\\n example-cli@v6 --help"],
|
|
410
|
+
]) {
|
|
411
|
+
test(`surface validation rejects a ${label} npx mutable major tag`, () => {
|
|
412
|
+
withSurfaceFixture((root) => {
|
|
413
|
+
fs.appendFileSync(
|
|
414
|
+
path.join(root, ".github/workflows/check.yml"),
|
|
415
|
+
` - run: |\n ${command}\n`,
|
|
416
|
+
);
|
|
417
|
+
assert.throws(() => checkSupplyChain(root), /npx.*mutable major tag/i);
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
test("surface validation accepts exact npx versions", () => {
|
|
423
|
+
withSurfaceFixture((root) => {
|
|
424
|
+
fs.appendFileSync(
|
|
425
|
+
path.join(root, ".github/workflows/check.yml"),
|
|
426
|
+
" - run: npx example-cli@6.1.0 --help\n - run: npx @scope/example-cli@6.1.0 --help\n",
|
|
427
|
+
);
|
|
428
|
+
assert.deepEqual(checkSupplyChain(root), VALID);
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
test("surface validation ignores commented and quoted npx major examples", () => {
|
|
433
|
+
withSurfaceFixture((root) => {
|
|
434
|
+
fs.appendFileSync(
|
|
435
|
+
path.join(root, ".github/workflows/check.yml"),
|
|
436
|
+
" # npx example-cli@v6 --help\n - run: echo 'npx example-cli@v6 --help'\n - run: echo \"npx @scope/example-cli@v6 --help\"\n",
|
|
437
|
+
);
|
|
438
|
+
assert.deepEqual(checkSupplyChain(root), VALID);
|
|
439
|
+
});
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
test("surface validation accepts immutable Git and exact npm versions in stable commands", () => {
|
|
443
|
+
withSurfaceFixture((root) => {
|
|
444
|
+
fs.appendFileSync(
|
|
445
|
+
path.join(root, ".github/workflows/check.yml"),
|
|
446
|
+
` - run: git clone --branch ${VALID.external_refs.open_design.commit} https://github.com/example/helper.git /tmp/helper\n - run: npm exec example-cli@6.1.0 -- --help\n`,
|
|
447
|
+
);
|
|
448
|
+
assert.deepEqual(checkSupplyChain(root), VALID);
|
|
449
|
+
});
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
test("surface validation ignores commented and quoted latest examples", () => {
|
|
453
|
+
withSurfaceFixture((root) => {
|
|
454
|
+
fs.appendFileSync(
|
|
455
|
+
path.join(root, ".github/workflows/check.yml"),
|
|
456
|
+
" # npx historical-tool@latest\n - run: echo 'npx documented-tool@latest'\n - run: echo 'git clone --branch main https://github.com/example/helper.git /tmp/helper'\n - run: echo 'npm exec example-cli@v6 -- --help'\n",
|
|
457
|
+
);
|
|
458
|
+
fs.appendFileSync(
|
|
459
|
+
path.join(root, "docker/open-design/Dockerfile"),
|
|
460
|
+
"# RUN npx historical-tool@latest\n",
|
|
461
|
+
);
|
|
462
|
+
assert.deepEqual(checkSupplyChain(root), VALID);
|
|
463
|
+
});
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
for (const [surface, relative, contents, message] of [
|
|
467
|
+
["workflow install", ".github/workflows/check.yml", " - run: |\n npm \\\n install\n", /automated npm install is forbidden/i],
|
|
468
|
+
["script install", "scripts/continued.sh", "#!/usr/bin/env bash\nnpm \\\n install\n", /automated npm install is forbidden/i],
|
|
469
|
+
["workflow clone", ".github/workflows/check.yml", " - run: |\n git clone \\\n --branch main https://github.com/example/helper.git\n", /mutable git clone --branch/i],
|
|
470
|
+
["script clone", "scripts/continued.sh", "#!/usr/bin/env bash\ngit clone \\\n --branch main https://github.com/example/helper.git\n", /mutable git clone --branch/i],
|
|
471
|
+
["workflow npm exec", ".github/workflows/check.yml", " - run: |\n npm exec \\\n example-cli@v6\n", /npm exec.*mutable major tag/i],
|
|
472
|
+
["script npm exec", "scripts/continued.sh", "#!/usr/bin/env bash\nnpm exec \\\n example-cli@v6\n", /npm exec.*mutable major tag/i],
|
|
473
|
+
]) {
|
|
474
|
+
test(`surface validation rejects a continued ${surface}`, () => {
|
|
475
|
+
withSurfaceFixture((root) => {
|
|
476
|
+
fs.appendFileSync(path.join(root, relative), contents);
|
|
477
|
+
if (relative.startsWith("scripts/")) fs.chmodSync(path.join(root, relative), 0o755);
|
|
478
|
+
assert.throws(() => checkSupplyChain(root), message);
|
|
479
|
+
});
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
test("surface validation keeps comments and quoted data masked across apparent continuations", () => {
|
|
484
|
+
withSurfaceFixture((root) => {
|
|
485
|
+
fs.writeFileSync(
|
|
486
|
+
path.join(root, "scripts/quoted-continuations.sh"),
|
|
487
|
+
"#!/usr/bin/env bash\n# npm \\\ninstall\necho 'git clone \\\n--branch main example'\necho \"npm exec \\\nexample-cli@v6\"\n",
|
|
488
|
+
{ mode: 0o755 },
|
|
489
|
+
);
|
|
490
|
+
assert.deepEqual(checkSupplyChain(root), VALID);
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
test("surface validation keeps multiline quoted commands masked", () => {
|
|
495
|
+
withSurfaceFixture((root) => {
|
|
496
|
+
fs.writeFileSync(
|
|
497
|
+
path.join(root, "scripts/multiline-quoted.sh"),
|
|
498
|
+
"#!/usr/bin/env bash\necho \"quoted \\\nnpm install\"\nprintf '%s' 'quoted \\\nnpm exec example-cli@v6'\n",
|
|
499
|
+
{ mode: 0o755 },
|
|
500
|
+
);
|
|
501
|
+
assert.deepEqual(checkSupplyChain(root), VALID);
|
|
502
|
+
});
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
test("surface validation admits the marked OpenCode latest canary", () => {
|
|
506
|
+
withSurfaceFixture((root) => {
|
|
507
|
+
assert.deepEqual(checkSupplyChain(root), VALID);
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
test("surface validation excludes historical specifications from active pin matching", () => {
|
|
512
|
+
withSurfaceFixture((root) => {
|
|
513
|
+
fs.mkdirSync(path.join(root, "docs/superpowers/specs"), { recursive: true });
|
|
514
|
+
fs.writeFileSync(
|
|
515
|
+
path.join(root, "docs/superpowers/specs/history.md"),
|
|
516
|
+
"uses: actions/checkout@v4\nsuperpowers@git+https://github.com/obra/superpowers.git#main\n",
|
|
517
|
+
);
|
|
518
|
+
assert.deepEqual(checkSupplyChain(root), VALID);
|
|
519
|
+
});
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
test("documentation validation requires one ordered canonical supply-chain pin block", () => {
|
|
523
|
+
for (const mutation of [
|
|
524
|
+
(policy) => policy.replace("<!-- supply-chain-pins:start -->\n", ""),
|
|
525
|
+
(policy) => `${policy}\n${policy}`,
|
|
526
|
+
(policy) => policy.replace(
|
|
527
|
+
/\| Superpowers \|[^\n]+\n\| actions\/checkout \|[^\n]+/,
|
|
528
|
+
(pair) => pair.split("\n").reverse().join("\n"),
|
|
529
|
+
),
|
|
530
|
+
]) {
|
|
531
|
+
withSurfaceFixture((root) => {
|
|
532
|
+
const relative = "docs/supply-chain.md";
|
|
533
|
+
fs.writeFileSync(path.join(root, relative), mutation(canonicalPolicy()));
|
|
534
|
+
assert.throws(() => checkSupplyChain(root), /one ordered supply-chain-pins block/i);
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
for (const [label, current, replacement] of [
|
|
540
|
+
["Superpowers release", `| Superpowers | ${VALID.external_refs.superpowers.release} |`, "| Superpowers | DRIFTED |"],
|
|
541
|
+
["Superpowers commit", `| \`${VALID.external_refs.superpowers.commit}\` |`, "| `DRIFTED` |"],
|
|
542
|
+
["checkout release", `| actions/checkout | ${VALID.external_refs.actions_checkout.release} |`, "| actions/checkout | DRIFTED |"],
|
|
543
|
+
["checkout commit", `| \`${VALID.external_refs.actions_checkout.commit}\` |`, "| `DRIFTED` |"],
|
|
544
|
+
["setup-node release", `| actions/setup-node | ${VALID.external_refs.actions_setup_node.release} |`, "| actions/setup-node | DRIFTED |"],
|
|
545
|
+
["setup-node commit", `| \`${VALID.external_refs.actions_setup_node.commit}\` |`, "| `DRIFTED` |"],
|
|
546
|
+
["Open Design commit", `| \`${VALID.external_refs.open_design.commit}\` |`, "| `DRIFTED` |"],
|
|
547
|
+
["Node image tag", `| Node image | ${VALID.external_refs.node_image.tag} |`, "| Node image | DRIFTED |"],
|
|
548
|
+
["Node image digest", `| \`${VALID.external_refs.node_image.digest}\` |`, "| `DRIFTED` |"],
|
|
549
|
+
["pnpm", `| pnpm | ${VALID.external_refs.pnpm.version} |`, "| pnpm | DRIFTED |"],
|
|
550
|
+
["opencode-ai", `| opencode-ai | ${VALID.external_refs.opencode_ai.version} |`, "| opencode-ai | DRIFTED |"],
|
|
551
|
+
["Babel override", `| @babel/core override | ${VALID.npm_overrides["@babel/core"]} |`, "| @babel/core override | DRIFTED |"],
|
|
552
|
+
["uuid override", `| uuid override | ${VALID.npm_overrides.uuid} |`, "| uuid override | DRIFTED |"],
|
|
553
|
+
]) {
|
|
554
|
+
test(`documentation validation rejects a drifted ${label} pin`, () => {
|
|
555
|
+
withSurfaceFixture((root) => {
|
|
556
|
+
const relative = "docs/supply-chain.md";
|
|
557
|
+
fs.writeFileSync(path.join(root, relative), canonicalPolicy().replace(current, replacement));
|
|
558
|
+
assert.throws(() => checkSupplyChain(root), /docs\/supply-chain\.md.*canonical pins/i);
|
|
559
|
+
});
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
for (const [label, current, message] of [
|
|
564
|
+
["frozen install policy", "npm ci --ignore-scripts", /frozen install policy/i],
|
|
565
|
+
["checksum format", "<64 lowercase hexadecimal characters> opencode-agent-orchestration-kit-<version>.tgz", /checksum format/i],
|
|
566
|
+
["manual publication warning", "Publication is never performed by checks and requires separate explicit authorization.", /separate explicit authorization/i],
|
|
567
|
+
]) {
|
|
568
|
+
test(`documentation validation requires the ${label}`, () => {
|
|
569
|
+
withSurfaceFixture((root) => {
|
|
570
|
+
const relative = "docs/supply-chain.md";
|
|
571
|
+
fs.writeFileSync(path.join(root, relative), canonicalPolicy().replace(current, "missing policy"));
|
|
572
|
+
assert.throws(() => checkSupplyChain(root), message);
|
|
573
|
+
});
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
for (const relative of ["README.md", "docs/superpowers.md"]) {
|
|
578
|
+
test(`documentation validation requires active Superpowers examples in ${relative} to use the full commit`, () => {
|
|
579
|
+
withSurfaceFixture((root) => {
|
|
580
|
+
fs.writeFileSync(
|
|
581
|
+
path.join(root, relative),
|
|
582
|
+
"superpowers@git+https://github.com/obra/superpowers.git#v6.1.1\n",
|
|
583
|
+
);
|
|
584
|
+
assert.throws(() => checkSupplyChain(root), /active Superpowers reference.*full reviewed commit/i);
|
|
585
|
+
});
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
test("documentation validation excludes historical plans, specs, and releases", () => {
|
|
590
|
+
withSurfaceFixture((root) => {
|
|
591
|
+
for (const relative of [
|
|
592
|
+
"docs/superpowers/specs/history.md",
|
|
593
|
+
"docs/superpowers/plans/history.md",
|
|
594
|
+
"docs/releases/history.md",
|
|
595
|
+
]) {
|
|
596
|
+
fs.writeFileSync(
|
|
597
|
+
path.join(root, relative),
|
|
598
|
+
"superpowers@git+https://github.com/obra/superpowers.git#main\n",
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
assert.deepEqual(checkSupplyChain(root), VALID);
|
|
602
|
+
});
|
|
603
|
+
});
|
|
604
|
+
|
|
605
|
+
test("Docker validation ignores a historical git checkout comment", () => {
|
|
606
|
+
withSurfaceFixture((root) => {
|
|
607
|
+
fs.appendFileSync(
|
|
608
|
+
path.join(root, "docker/open-design/Dockerfile"),
|
|
609
|
+
"# historical note: git checkout main\n",
|
|
610
|
+
);
|
|
611
|
+
assert.deepEqual(checkSupplyChain(root), VALID);
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
test("Docker validation ignores a historical pnpm preparation comment", () => {
|
|
616
|
+
withSurfaceFixture((root) => {
|
|
617
|
+
fs.appendFileSync(
|
|
618
|
+
path.join(root, "docker/open-design/Dockerfile"),
|
|
619
|
+
"# docs: corepack prepare pnpm@9.0.0 --activate\n",
|
|
620
|
+
);
|
|
621
|
+
assert.deepEqual(checkSupplyChain(root), VALID);
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
for (const [label, current, replacement, message] of [
|
|
626
|
+
["base digest", `FROM node:${VALID.external_refs.node_image.tag}@${VALID.external_refs.node_image.digest}`, `FROM node:${VALID.external_refs.node_image.tag}`, /Dockerfile FROM.*digest/i],
|
|
627
|
+
["single FROM", `FROM node:${VALID.external_refs.node_image.tag}@${VALID.external_refs.node_image.digest}`, `FROM node:${VALID.external_refs.node_image.tag}@${VALID.external_refs.node_image.digest}\nFROM scratch`, /exactly one FROM/i],
|
|
628
|
+
["Open Design commit", `ARG OPEN_DESIGN_REF=${VALID.external_refs.open_design.commit}`, "ARG OPEN_DESIGN_REF=1592beb", /OPEN_DESIGN_REF/i],
|
|
629
|
+
["Open Design checkout", "git checkout \"$OPEN_DESIGN_REF\"", "git checkout main", /Open Design checkout/i],
|
|
630
|
+
["OpenCode version", `ARG OPENCODE_AI_VERSION=${VALID.external_refs.opencode_ai.version}`, "ARG OPENCODE_AI_VERSION=latest", /OPENCODE_AI_VERSION/i],
|
|
631
|
+
["OpenCode install", "npm install -g \"opencode-ai@$OPENCODE_AI_VERSION\"", "npm install -g \"opencode-ai@latest\"", /OpenCode install/i],
|
|
632
|
+
["pnpm version", `pnpm@${VALID.external_refs.pnpm.version}`, "pnpm@latest", /pnpm version/i],
|
|
633
|
+
["frozen pnpm install", "pnpm install --frozen-lockfile", "pnpm install --frozen-lockfile=false", /pnpm install.*frozen-lockfile/i],
|
|
634
|
+
]) {
|
|
635
|
+
test(`surface validation rejects wrong Docker ${label}`, () => {
|
|
636
|
+
withSurfaceFixture((root) => {
|
|
637
|
+
const relative = "docker/open-design/Dockerfile";
|
|
638
|
+
const dockerfile = fs.readFileSync(path.join(root, relative), "utf8").replace(current, replacement);
|
|
639
|
+
fs.writeFileSync(path.join(root, relative), dockerfile);
|
|
640
|
+
assert.throws(() => checkSupplyChain(root), message);
|
|
641
|
+
});
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
for (const [dependency, mutation] of [
|
|
646
|
+
["@babel/core", (packageData) => { delete packageData.overrides["@babel/core"]; }],
|
|
647
|
+
["@babel/core range", (packageData) => { packageData.overrides["@babel/core"] = "^7.29.7"; }],
|
|
648
|
+
["@babel/core wrong version", (packageData) => { packageData.overrides["@babel/core"] = "7.29.6"; }],
|
|
649
|
+
["uuid", (packageData) => { delete packageData.overrides.uuid; }],
|
|
650
|
+
["uuid range", (packageData) => { packageData.overrides.uuid = "^14.0.0"; }],
|
|
651
|
+
["uuid wrong version", (packageData) => { packageData.overrides.uuid = "13.0.0"; }],
|
|
652
|
+
]) {
|
|
653
|
+
test(`surface validation rejects absent, ranged, or wrong ${dependency} override`, () => {
|
|
654
|
+
withSurfaceFixture((root) => {
|
|
655
|
+
const relative = "opencode/package.json";
|
|
656
|
+
const packageData = JSON.parse(fs.readFileSync(path.join(root, relative), "utf8"));
|
|
657
|
+
mutation(packageData);
|
|
658
|
+
fs.writeFileSync(path.join(root, relative), `${JSON.stringify(packageData)}\n`);
|
|
659
|
+
assert.throws(() => checkSupplyChain(root), /opencode\/package\.json override/);
|
|
660
|
+
});
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
test("surface validation rejects a lockfile not regenerated to the Babel override", () => {
|
|
665
|
+
withSurfaceFixture((root) => {
|
|
666
|
+
const relative = "opencode/package-lock.json";
|
|
667
|
+
const lock = JSON.parse(fs.readFileSync(path.join(root, relative), "utf8"));
|
|
668
|
+
lock.packages["node_modules/@babel/core"].version = "7.28.0";
|
|
669
|
+
fs.writeFileSync(path.join(root, relative), `${JSON.stringify(lock)}\n`);
|
|
670
|
+
assert.throws(() => checkSupplyChain(root), /package-lock\.json @babel\/core must resolve to 7\.29\.7/);
|
|
671
|
+
});
|
|
672
|
+
});
|
|
673
|
+
|
|
674
|
+
for (const [label, mutate, message] of [
|
|
675
|
+
["missing resolved", (entry) => { delete entry.resolved; }, /node_modules\/example.*canonical npm registry resolved URL/i],
|
|
676
|
+
["non-registry resolved", (entry) => { entry.resolved = "https://example.invalid/example.tgz"; }, /node_modules\/example.*canonical npm registry resolved URL/i],
|
|
677
|
+
["missing integrity", (entry) => { delete entry.integrity; }, /node_modules\/example.*non-empty sha512 integrity/i],
|
|
678
|
+
["corrupt integrity", (entry) => { entry.integrity = "sha256-corrupt"; }, /node_modules\/example.*non-empty sha512 integrity/i],
|
|
679
|
+
]) {
|
|
680
|
+
test(`surface validation rejects non-override lock entry ${label}`, () => {
|
|
681
|
+
withSurfaceFixture((root) => {
|
|
682
|
+
const relative = "opencode/package-lock.json";
|
|
683
|
+
const lock = JSON.parse(fs.readFileSync(path.join(root, relative), "utf8"));
|
|
684
|
+
mutate(lock.packages["node_modules/example"]);
|
|
685
|
+
fs.writeFileSync(path.join(root, relative), `${JSON.stringify(lock)}\n`);
|
|
686
|
+
assert.throws(() => checkSupplyChain(root), message);
|
|
687
|
+
});
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
test("the committed lockfile gives every non-root package canonical registry metadata", () => {
|
|
692
|
+
const lock = JSON.parse(fs.readFileSync(path.join(SCRIPTS_ROOT, "../opencode/package-lock.json"), "utf8"));
|
|
693
|
+
for (const [name, entry] of Object.entries(lock.packages)) {
|
|
694
|
+
if (name === "") continue;
|
|
695
|
+
assert.match(entry.resolved, /^https:\/\/registry\.npmjs\.org\//, `${name} resolved`);
|
|
696
|
+
assert.match(entry.integrity, /^sha512-.+/, `${name} integrity`);
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
|
|
700
|
+
for (const [relative, current, replacement, message] of [
|
|
701
|
+
["docs/docker-open-design.md", VALID.external_refs.node_image.digest, `sha256:${"0".repeat(64)}`, /docker-open-design\.md.*Node image digest/i],
|
|
702
|
+
["docs/docker-open-design.md", VALID.external_refs.open_design.commit, "0".repeat(40), /docker-open-design\.md.*Open Design commit/i],
|
|
703
|
+
["docs/docker-open-design.md", `pnpm@${VALID.external_refs.pnpm.version}`, "pnpm@10.0.0", /docker-open-design\.md.*pnpm version/i],
|
|
704
|
+
["docs/security.md", "npm audit signatures", "npm audit --omit=dev", /security\.md.*signature audit/i],
|
|
705
|
+
["docs/security.md", "package-smoked tarball", "package directory", /security\.md.*package-smoked tarball/i],
|
|
706
|
+
["docs/quickstart.md", "npm run check:release", "npm run check", /quickstart\.md.*release gate/i],
|
|
707
|
+
["docs/workflows.md", "post-publication verification", "publication", /workflows\.md.*post-publication verification/i],
|
|
708
|
+
]) {
|
|
709
|
+
test(`documentation validation rejects active drift in ${relative}: ${message.source}`, () => {
|
|
710
|
+
withSurfaceFixture((root) => {
|
|
711
|
+
const full = path.join(root, relative);
|
|
712
|
+
fs.writeFileSync(full, fs.readFileSync(full, "utf8").replace(current, replacement));
|
|
713
|
+
assert.throws(() => checkSupplyChain(root), message);
|
|
714
|
+
});
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
test("surface validation rejects automated npm ci without ignore-scripts", () => {
|
|
719
|
+
withSurfaceFixture((root) => {
|
|
720
|
+
const relative = ".github/workflows/check.yml";
|
|
721
|
+
fs.writeFileSync(
|
|
722
|
+
path.join(root, relative),
|
|
723
|
+
"steps:\n - working-directory: opencode\n run: npm ci\n",
|
|
724
|
+
);
|
|
725
|
+
assert.throws(() => checkSupplyChain(root), /npm ci must include --ignore-scripts/);
|
|
726
|
+
});
|
|
727
|
+
});
|
|
728
|
+
|
|
729
|
+
test("surface validation rejects an npm script using npm ci without ignore-scripts", () => {
|
|
730
|
+
withSurfaceFixture((root) => {
|
|
731
|
+
const relative = "package.json";
|
|
732
|
+
const packageData = JSON.parse(fs.readFileSync(path.join(root, relative), "utf8"));
|
|
733
|
+
packageData.scripts["check:release"] = "npm --prefix opencode ci && npm run check";
|
|
734
|
+
fs.writeFileSync(path.join(root, relative), `${JSON.stringify(packageData)}\n`);
|
|
735
|
+
assert.throws(() => checkSupplyChain(root), /npm ci must include --ignore-scripts/);
|
|
736
|
+
});
|
|
737
|
+
});
|
|
738
|
+
|
|
739
|
+
test("surface validation rejects an automated npm install fallback", () => {
|
|
740
|
+
withSurfaceFixture((root) => {
|
|
741
|
+
fs.writeFileSync(path.join(root, "scripts/fallback.sh"), "#!/usr/bin/env bash\nnpm install\n", { mode: 0o755 });
|
|
742
|
+
assert.throws(() => checkSupplyChain(root), /automated npm install is forbidden/);
|
|
743
|
+
});
|
|
744
|
+
});
|
|
745
|
+
|
|
746
|
+
test("surface validation rejects npm install after a shell command prefix", () => {
|
|
747
|
+
withSurfaceFixture((root) => {
|
|
748
|
+
fs.writeFileSync(
|
|
749
|
+
path.join(root, "scripts/fallback.sh"),
|
|
750
|
+
"#!/usr/bin/env bash\ncd opencode && npm install\n",
|
|
751
|
+
{ mode: 0o755 },
|
|
752
|
+
);
|
|
753
|
+
assert.throws(() => checkSupplyChain(root), /automated npm install is forbidden/);
|
|
754
|
+
});
|
|
755
|
+
});
|
|
756
|
+
|
|
757
|
+
test("surface validation rejects npm ci after an environment assignment", () => {
|
|
758
|
+
withSurfaceFixture((root) => {
|
|
759
|
+
fs.writeFileSync(
|
|
760
|
+
path.join(root, "scripts/assigned.sh"),
|
|
761
|
+
"#!/usr/bin/env bash\nFOO=1 npm ci\n",
|
|
762
|
+
{ mode: 0o755 },
|
|
763
|
+
);
|
|
764
|
+
assert.throws(() => checkSupplyChain(root), /npm ci must include --ignore-scripts/);
|
|
765
|
+
});
|
|
766
|
+
});
|
|
767
|
+
|
|
768
|
+
test("surface validation rejects assigned npm install after a shell command prefix", () => {
|
|
769
|
+
withSurfaceFixture((root) => {
|
|
770
|
+
fs.writeFileSync(
|
|
771
|
+
path.join(root, "scripts/fallback.sh"),
|
|
772
|
+
"#!/usr/bin/env bash\ncd opencode && FOO=1 npm install\n",
|
|
773
|
+
{ mode: 0o755 },
|
|
774
|
+
);
|
|
775
|
+
assert.throws(() => checkSupplyChain(root), /automated npm install is forbidden/);
|
|
776
|
+
});
|
|
777
|
+
});
|
|
778
|
+
|
|
779
|
+
test("surface validation rejects npm ci after multiple POSIX assignments", () => {
|
|
780
|
+
withSurfaceFixture((root) => {
|
|
781
|
+
fs.writeFileSync(
|
|
782
|
+
path.join(root, "scripts/assigned.sh"),
|
|
783
|
+
"#!/usr/bin/env bash\nFOO='two words' BAR=2 npm ci\n",
|
|
784
|
+
{ mode: 0o755 },
|
|
785
|
+
);
|
|
786
|
+
assert.throws(() => checkSupplyChain(root), /npm ci must include --ignore-scripts/);
|
|
787
|
+
});
|
|
788
|
+
});
|
|
789
|
+
|
|
790
|
+
test("surface validation rejects an assigned package npm ci without ignore-scripts", () => {
|
|
791
|
+
withSurfaceFixture((root) => {
|
|
792
|
+
const relative = "package.json";
|
|
793
|
+
const packageData = JSON.parse(fs.readFileSync(path.join(root, relative), "utf8"));
|
|
794
|
+
packageData.scripts.assigned = "FOO=1 npm --prefix opencode ci";
|
|
795
|
+
fs.writeFileSync(path.join(root, relative), `${JSON.stringify(packageData)}\n`);
|
|
796
|
+
assert.throws(() => checkSupplyChain(root), /npm ci must include --ignore-scripts/);
|
|
797
|
+
});
|
|
798
|
+
});
|
|
799
|
+
|
|
800
|
+
test("surface validation accepts an assigned frozen package npm ci", () => {
|
|
801
|
+
withSurfaceFixture((root) => {
|
|
802
|
+
const relative = "package.json";
|
|
803
|
+
const packageData = JSON.parse(fs.readFileSync(path.join(root, relative), "utf8"));
|
|
804
|
+
packageData.scripts.assigned = "FOO=1 npm --prefix opencode ci --ignore-scripts";
|
|
805
|
+
fs.writeFileSync(path.join(root, relative), `${JSON.stringify(packageData)}\n`);
|
|
806
|
+
assert.deepEqual(checkSupplyChain(root), VALID);
|
|
807
|
+
});
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
test("surface validation rejects conditional npm ci without ignore-scripts", () => {
|
|
811
|
+
withSurfaceFixture((root) => {
|
|
812
|
+
fs.writeFileSync(
|
|
813
|
+
path.join(root, "scripts/conditional.sh"),
|
|
814
|
+
"#!/usr/bin/env bash\nif test -f package-lock.json; then npm ci; fi\n",
|
|
815
|
+
{ mode: 0o755 },
|
|
816
|
+
);
|
|
817
|
+
assert.throws(() => checkSupplyChain(root), /npm ci must include --ignore-scripts/);
|
|
818
|
+
});
|
|
819
|
+
});
|
|
820
|
+
|
|
821
|
+
test("surface validation accepts frozen npm ci after a workflow shell prefix", () => {
|
|
822
|
+
withSurfaceFixture((root) => {
|
|
823
|
+
const relative = ".github/workflows/check.yml";
|
|
824
|
+
const workflow = fs.readFileSync(path.join(root, relative), "utf8").replace(
|
|
825
|
+
"working-directory: opencode\n run: npm ci --ignore-scripts",
|
|
826
|
+
"run: cd opencode && npm ci --ignore-scripts",
|
|
827
|
+
);
|
|
828
|
+
fs.writeFileSync(path.join(root, relative), workflow);
|
|
829
|
+
assert.deepEqual(checkSupplyChain(root), VALID);
|
|
830
|
+
});
|
|
831
|
+
});
|
|
832
|
+
|
|
833
|
+
test("surface validation ignores comments and quoted npm command examples", () => {
|
|
834
|
+
withSurfaceFixture((root) => {
|
|
835
|
+
fs.writeFileSync(
|
|
836
|
+
path.join(root, "scripts/examples.sh"),
|
|
837
|
+
"#!/usr/bin/env bash\n# npm install\necho 'npm install'\nprintf '%s\\n' \"npm ci\"\n",
|
|
838
|
+
{ mode: 0o755 },
|
|
839
|
+
);
|
|
840
|
+
assert.deepEqual(checkSupplyChain(root), VALID);
|
|
841
|
+
});
|
|
842
|
+
});
|
|
843
|
+
|
|
844
|
+
test("surface validation requires the frozen root audit commands", () => {
|
|
845
|
+
withSurfaceFixture((root) => {
|
|
846
|
+
const relative = "package.json";
|
|
847
|
+
const packageData = JSON.parse(fs.readFileSync(path.join(root, relative), "utf8"));
|
|
848
|
+
packageData.scripts["dependency-audit"] = "npm --prefix opencode audit --omit=dev --audit-level=moderate";
|
|
849
|
+
fs.writeFileSync(path.join(root, relative), `${JSON.stringify(packageData)}\n`);
|
|
850
|
+
assert.throws(() => checkSupplyChain(root), /package\.json dependency-audit/);
|
|
851
|
+
});
|
|
852
|
+
});
|
|
853
|
+
|
|
854
|
+
test("surface validation requires the exact npm package allowlist", () => {
|
|
855
|
+
withSurfaceFixture((root) => {
|
|
856
|
+
const relative = "package.json";
|
|
857
|
+
const packageData = JSON.parse(fs.readFileSync(path.join(root, relative), "utf8"));
|
|
858
|
+
packageData.files = [...PACKAGE_FILES, ".github/"];
|
|
859
|
+
fs.writeFileSync(path.join(root, relative), `${JSON.stringify(packageData)}\n`);
|
|
860
|
+
assert.throws(() => checkSupplyChain(root), /package\.json files must be exactly/i);
|
|
861
|
+
});
|
|
862
|
+
});
|
|
863
|
+
|
|
864
|
+
test("surface validation requires the package smoke command", () => {
|
|
865
|
+
withSurfaceFixture((root) => {
|
|
866
|
+
const relative = "package.json";
|
|
867
|
+
const packageData = JSON.parse(fs.readFileSync(path.join(root, relative), "utf8"));
|
|
868
|
+
delete packageData.scripts["package-smoke"];
|
|
869
|
+
fs.writeFileSync(path.join(root, relative), `${JSON.stringify(packageData)}\n`);
|
|
870
|
+
assert.throws(() => checkSupplyChain(root), /package-smoke must be exactly/i);
|
|
871
|
+
});
|
|
872
|
+
});
|
|
873
|
+
|
|
874
|
+
test("surface validation rejects root publication lifecycle hooks", () => {
|
|
875
|
+
for (const hook of ["prepack", "prepare", "prepublish", "prepublishOnly"]) {
|
|
876
|
+
withSurfaceFixture((root) => {
|
|
877
|
+
const relative = "package.json";
|
|
878
|
+
const packageData = JSON.parse(fs.readFileSync(path.join(root, relative), "utf8"));
|
|
879
|
+
packageData.scripts[hook] = "exit 0";
|
|
880
|
+
fs.writeFileSync(path.join(root, relative), `${JSON.stringify(packageData)}\n`);
|
|
881
|
+
assert.throws(() => checkSupplyChain(root), new RegExp(`forbidden root lifecycle hook ${hook}`));
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
});
|
|
885
|
+
|
|
886
|
+
test("surface validation requires an executable package smoke wrapper", () => {
|
|
887
|
+
withSurfaceFixture((root) => {
|
|
888
|
+
fs.chmodSync(path.join(root, "scripts/package-smoke.sh"), 0o644);
|
|
889
|
+
assert.throws(() => checkSupplyChain(root), /package-smoke\.sh must be executable/i);
|
|
890
|
+
});
|
|
891
|
+
});
|
|
892
|
+
|
|
893
|
+
for (const relative of ["scripts/package-smoke.sh", "scripts/package-smoke.mjs"]) {
|
|
894
|
+
test(`surface validation rejects a symlinked ${relative}`, () => {
|
|
895
|
+
withSurfaceFixture((root) => {
|
|
896
|
+
const full = path.join(root, relative);
|
|
897
|
+
const target = path.join(root, `${relative}.target`);
|
|
898
|
+
fs.renameSync(full, target);
|
|
899
|
+
fs.symlinkSync(target, full);
|
|
900
|
+
assert.throws(() => checkSupplyChain(root), /must be a regular non-symlink file/i);
|
|
901
|
+
});
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
test("rejects a symlinked canonical inventory", () => {
|
|
906
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), "supply-chain-link-test-"));
|
|
907
|
+
const target = path.join(root, "target.json");
|
|
908
|
+
try {
|
|
909
|
+
fs.writeFileSync(target, `${JSON.stringify(VALID)}\n`);
|
|
910
|
+
fs.symlinkSync(target, path.join(root, "supply-chain.json"));
|
|
911
|
+
assert.throws(
|
|
912
|
+
() => checkSupplyChain(root, { surfaces: false }),
|
|
913
|
+
(error) => error.code === "INVALID_SUPPLY_CHAIN"
|
|
914
|
+
&& error.message.includes("supply-chain.json must be a safe regular file"),
|
|
915
|
+
);
|
|
916
|
+
} finally {
|
|
917
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
918
|
+
}
|
|
919
|
+
});
|
|
920
|
+
|
|
921
|
+
test("direct execution prints the exact staged success contract", () => {
|
|
922
|
+
withCliFixture(VALID, (result) => {
|
|
923
|
+
assert.equal(result.status, 0);
|
|
924
|
+
assert.equal(result.stdout, "supply chain contract ok: immutable external refs and exact npm overrides\n");
|
|
925
|
+
assert.equal(result.stderr, "");
|
|
926
|
+
});
|
|
927
|
+
});
|
|
928
|
+
|
|
929
|
+
test("direct execution reports malformed inventory on stderr", () => {
|
|
930
|
+
withCliFixture("{", (result) => {
|
|
931
|
+
assert.notEqual(result.status, 0);
|
|
932
|
+
assert.equal(result.stdout, "");
|
|
933
|
+
assert.match(result.stderr, /^supply chain contract invalid: supply-chain\.json is invalid JSON:/);
|
|
934
|
+
});
|
|
935
|
+
});
|
|
936
|
+
|
|
937
|
+
test("missing inventory has a dedicated relative-file diagnostic", () => {
|
|
938
|
+
withCliFixture(undefined, (result) => {
|
|
939
|
+
assert.notEqual(result.status, 0);
|
|
940
|
+
assert.equal(result.stdout, "");
|
|
941
|
+
assert.equal(result.stderr, "supply chain contract invalid: supply-chain.json is missing\n");
|
|
942
|
+
assert.doesNotMatch(result.stderr, /supply-chain-cli-test-/);
|
|
943
|
+
});
|
|
944
|
+
});
|