diff --git a/ATTRIBUTIONS-Node.md b/ATTRIBUTIONS-Node.md index 467f2bb85..1254cc08c 100644 --- a/ATTRIBUTIONS-Node.md +++ b/ATTRIBUTIONS-Node.md @@ -36985,7 +36985,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` -## tar - 7.5.21 +## tar - 7.5.24 **Repository URL**: https://github.com/isaacs/node-tar **License Type(s)**: BlueOak-1.0.0 diff --git a/adapters/typescript/package-lock.json b/adapters/typescript/package-lock.json index c73ae25cd..85ce8cb02 100644 --- a/adapters/typescript/package-lock.json +++ b/adapters/typescript/package-lock.json @@ -232,15 +232,6 @@ "node": ">=14.17" } }, - "kilo/node_modules/undici": { - "version": "8.12.3", - "resolved": "https://registry.npmjs.org/undici/-/undici-8.12.3.tgz", - "integrity": "sha512-+fdndUTwBP86cVjihTp21hZHo7d6oj1c/47XPA3lL8mM0XHs+C4EkcjmgRsFnFk2f/UONGDy9ItBItmXsLOQHw==", - "license": "MIT", - "engines": { - "node": ">=22.19.0" - } - }, "kilo/node_modules/undici-types": { "version": "7.16.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", @@ -8295,9 +8286,9 @@ } }, "node_modules/tar": { - "version": "7.5.21", - "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.21.tgz", - "integrity": "sha512-XdhtCvlMywwxpCW8YEq3lOXBJpUPTR2OHHcwLPO3HwsJqOHa2Ok/oJ7ruGzp+JrKoRPVCzJwAdEjqLW/vNRPHA==", + "version": "7.5.24", + "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.24.tgz", + "integrity": "sha512-to/OxuCk5DeVONcjjODT7aeoRq5NIPPlfPc0tNML+wLlnf6u5BcJz97Uukv3pT3jzorkFhUevylkAiBr+ZmV2w==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -8510,7 +8501,6 @@ "version": "8.12.3", "resolved": "https://registry.npmjs.org/undici/-/undici-8.12.3.tgz", "integrity": "sha512-+fdndUTwBP86cVjihTp21hZHo7d6oj1c/47XPA3lL8mM0XHs+C4EkcjmgRsFnFk2f/UONGDy9ItBItmXsLOQHw==", - "dev": true, "license": "MIT", "engines": { "node": ">=22.19.0" diff --git a/adapters/typescript/package.json b/adapters/typescript/package.json index 587aabe47..a596bbf0a 100644 --- a/adapters/typescript/package.json +++ b/adapters/typescript/package.json @@ -22,7 +22,7 @@ "pack:install-check": "node scripts/check-install.mjs", "test": "npm run test:units && npm run test:dependencies && npm run pack:check", "test:dependencies": "npm ls --all && node scripts/audit-dependencies.mjs", - "test:units": "node --test scripts/audit-dependencies.test.mjs && npm test --workspace nemo-fabric-adapters-common && npm test --workspace nemo-fabric-adapters-cline && npm test --workspace nemo-fabric-adapters-droid && npm test --workspace nemo-fabric-adapters-pi && npm test --workspace nemo-fabric-adapters-opencode && npm test --workspace nemo-fabric-adapters-qwen && npm test --workspace nemo-fabric-adapters-kilo && npm test --workspace nemo-fabric-adapters-kiro && npm run test --workspace nemo-fabric-adapters-strands" + "test:units": "node --test scripts/audit-dependencies.test.mjs scripts/dependency-compatibility.test.mjs && npm test --workspace nemo-fabric-adapters-common && npm test --workspace nemo-fabric-adapters-cline && npm test --workspace nemo-fabric-adapters-droid && npm test --workspace nemo-fabric-adapters-pi && npm test --workspace nemo-fabric-adapters-opencode && npm test --workspace nemo-fabric-adapters-qwen && npm test --workspace nemo-fabric-adapters-kilo && npm test --workspace nemo-fabric-adapters-kiro && npm run test --workspace nemo-fabric-adapters-strands" }, "devDependencies": { "nemo-fabric-adapter-contract": "file:../../adapter-contract/typescript", @@ -63,7 +63,7 @@ "undici": "8.12.3" }, "ws": "8.23.0", - "tar": "7.5.21" + "tar": "7.5.24" }, "engines": { "node": ">=22.19.0" diff --git a/adapters/typescript/scripts/audit-dependencies.test.mjs b/adapters/typescript/scripts/audit-dependencies.test.mjs index 4d7b114d2..572326ad0 100644 --- a/adapters/typescript/scripts/audit-dependencies.test.mjs +++ b/adapters/typescript/scripts/audit-dependencies.test.mjs @@ -315,3 +315,230 @@ test("rejects a lockfile from the other TypeScript scope", () => { assert.throws(() => checkAudit(contract.audit, adapters.lock, "contract")); assert.throws(() => checkAudit(adapters.audit, contract.lock, "adapters")); }); + +const tarNow = Date.parse("2026-12-02T12:00:00Z"); +const tarDeadline = Date.parse("2026-12-10T00:00:00Z"); +const tarAdvisory = { + name: "tar", + severity: "high", + url: "https://github.com/advisories/GHSA-mhqm-9wj8-w7r4", + range: "<8.0.0", +}; + +function tarFixture() { + const audit = structuredClone(report); + const lock = { packages: {} }; + for (const [name, version, via] of [ + [ + "tar", + "7.5.24", + [ + tarAdvisory, + { + ...tarAdvisory, + url: "https://github.com/advisories/GHSA-7c32-79xj-j3jp", + range: "<8.0.2", + }, + { + ...tarAdvisory, + url: "https://github.com/advisories/GHSA-p96f-8xj2-g85p", + range: ">=7.0.0 <8.0.0", + severity: "moderate", + }, + ], + ], + ["pacote", "21.5.1", ["tar"]], + ["node-gyp", "12.4.0", ["tar"]], + ["@opencode/util", "2.0.23", ["pacote"]], + ]) { + const path = `node_modules/${name}`; + audit.vulnerabilities[name] = structuredClone({ + name, + severity: "high", + nodes: [path], + via, + }); + lock.packages[path] = { version, dev: true }; + audit.metadata.vulnerabilities.high++; + } + return { audit, lock }; +} + +test("tar: allows the enumerated advisories and exact development parent paths before expiry", () => { + const { audit, lock } = tarFixture(); + assert.equal(checkAudit(audit, lock, "adapters", tarNow).high, 4); + assert.equal(checkAudit(audit, lock, "adapters", tarDeadline - 1).high, 4); +}); + +for (const now of [tarDeadline, tarDeadline + 1, NaN]) { + test(`tar: rejects an expired exception or invalid clock (${now})`, () => { + const { audit, lock } = tarFixture(); + assert.throws(() => checkAudit(audit, lock, "adapters", now), /expired/); + }); +} + +test("tar: removing all affected findings needs no exception after expiry", () => { + assert.equal(checkAudit(report, {}, "adapters", tarDeadline).high, 0); +}); + +test("tar: never extends the contract audit policy", () => { + const { audit, lock } = tarFixture(); + assert.throws(() => checkAudit(audit, lock, "contract", tarNow)); +}); + +for (const [description, mutate] of [ + [ + "a new high advisory", + (r) => + r.vulnerabilities.tar.via.push({ + ...tarAdvisory, + url: "https://github.com/advisories/OTHER", + }), + ], + [ + "a new moderate advisory on tar", + (r) => + r.vulnerabilities.tar.via.push({ + ...tarAdvisory, + severity: "moderate", + url: "https://github.com/advisories/OTHER", + }), + ], + [ + "a changed advisory range", + (r) => { + r.vulnerabilities.tar.via[0].range = "*"; + }, + ], + [ + "a changed advisory name", + (r) => { + r.vulnerabilities.tar.via[0].name = "other"; + }, + ], + [ + "a changed moderate advisory severity", + (r) => { + r.vulnerabilities.tar.via[2].severity = "high"; + }, + ], + [ + "a new advisory on an approved parent", + (r) => r.vulnerabilities.pacote.via.push(tarAdvisory), + ], + [ + "an unknown dependency reference", + (r) => r.vulnerabilities.pacote.via.push("missing"), + ], + [ + "a parent cycle without tar", + (r) => { + r.vulnerabilities.pacote.via = ["@opencode/util"]; + }, + ], + [ + "a missing advisory root", + (r) => { + delete r.vulnerabilities.tar; + r.metadata.vulnerabilities.high--; + }, + ], + [ + "a missing root advisory", + (r) => { + r.vulnerabilities.tar.via = []; + }, + ], + [ + "an unrelated high finding", + (r) => { + r.vulnerabilities.other = { + name: "other", + severity: "high", + nodes: ["node_modules/other"], + via: ["tar"], + }; + r.metadata.vulnerabilities.high++; + }, + ], + [ + "a critical root finding", + (r) => { + r.vulnerabilities.tar.severity = "critical"; + r.metadata.vulnerabilities.high--; + r.metadata.vulnerabilities.critical++; + }, + ], + [ + "a critical advisory hidden under a high finding", + (r) => { + r.vulnerabilities.tar.via[0].severity = "critical"; + }, + ], + [ + "an audit error", + (r) => { + r.error = { code: "E503" }; + }, + ], + [ + "an inconsistent high count", + (r) => { + r.metadata.vulnerabilities.high--; + }, + ], +]) { + test(`tar: rejects ${description}`, () => { + const { audit, lock } = tarFixture(); + mutate(audit); + assert.throws(() => checkAudit(audit, lock, "adapters", tarNow)); + }); +} + +test("tar: rejects changed versions, missing entries, non-dev entries and additional paths for every package", () => { + const { audit, lock } = tarFixture(); + for (const [path, entry] of Object.entries(lock.packages)) { + for (const replacement of [ + undefined, + { ...entry, version: "99.0.0" }, + { ...entry, dev: false }, + { version: entry.version }, + ]) { + const changed = structuredClone(lock); + changed.packages[path] = replacement; + assert.throws(() => checkAudit(audit, changed, "adapters", tarNow), path); + } + const changed = structuredClone(audit); + const name = path.slice("node_modules/".length); + changed.vulnerabilities[name].nodes.push(`node_modules/other/${path}`); + assert.throws(() => checkAudit(changed, lock, "adapters", tarNow), path); + } +}); + +test("tar: coexists with existing Zod and picomatch exceptions, including the shared node-gyp parent", () => { + const tar = tarFixture(); + const picomatch = picomatchFixture("adapters"); + const audit = exceptionReport(); + Object.assign( + audit.vulnerabilities, + picomatch.audit.vulnerabilities, + tar.audit.vulnerabilities, + ); + audit.vulnerabilities["node-gyp"].via.push("tinyglobby"); + audit.vulnerabilities["@opencode/core"].via.push("@opencode/util"); + audit.metadata.vulnerabilities.high = Object.values( + audit.vulnerabilities, + ).filter((v) => v.severity === "high").length; + const lock = { + packages: { + ...exceptionLock.packages, + ...picomatch.lock.packages, + ...tar.lock.packages, + }, + }; + assert.equal(checkAudit(audit, lock, "adapters", tarNow).high, 13); + assert.throws( + () => checkAudit(audit, lock, "adapters", tarDeadline), + /expired/, + ); +}); diff --git a/adapters/typescript/scripts/dependency-compatibility.test.mjs b/adapters/typescript/scripts/dependency-compatibility.test.mjs new file mode 100644 index 000000000..4510d5444 --- /dev/null +++ b/adapters/typescript/scripts/dependency-compatibility.test.mjs @@ -0,0 +1,35 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. +// SPDX-License-Identifier: Apache-2.0 + +import assert from "node:assert/strict"; +import { mkdtemp, mkdir, readFile, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { test } from "node:test"; + +import pacote from "pacote"; +import * as tar from "tar"; + +test("the resolved tar supports pacote package extraction", async () => { + const root = await mkdtemp(join(tmpdir(), "fabric-pacote-")); + try { + const fixture = join(root, "package"); + await mkdir(fixture); + const manifest = { name: "fabric-extraction-fixture", version: "1.0.0" }; + await writeFile(join(fixture, "package.json"), JSON.stringify(manifest)); + const archive = join(root, "fixture.tgz"); + await tar.c({ cwd: root, file: archive, gzip: true }, ["package"]); + + const destination = join(root, "extracted"); + await pacote.extract(archive, destination, { cache: join(root, "cache") }); + assert.deepEqual( + JSON.parse(await readFile(join(destination, "package.json"), "utf8")), + manifest, + ); + } finally { + await rm(root, { recursive: true, force: true }); + } +}); diff --git a/scripts/ci/audit_typescript_dependencies.mjs b/scripts/ci/audit_typescript_dependencies.mjs index 5999312da..53ea8183e 100644 --- a/scripts/ci/audit_typescript_dependencies.mjs +++ b/scripts/ci/audit_typescript_dependencies.mjs @@ -56,7 +56,56 @@ const picomatchPackages = { }, }; -export function checkAudit(report, lockfile = {}, scope = "adapters") { +// Temporary repository-only risk acceptance: NVIDIA/NeMo-Fabric#735. +// Owner: AnuradhaKaruppiah. Review by 2026-12-09; hard expiry below. +// tar 8 breaks pacote/node-gyp's stream API. This does not approve runtime +// consumers or release images. Keep IDs, ranges, severities and dev paths exact. +const tarExpires = "2026-12-10T00:00:00Z"; +const tarAdvisories = { + "GHSA-25mm-r35j-6hgm": [">=7.5.22 <8.0.0", "high"], + "GHSA-mhqm-9wj8-w7r4": ["<8.0.0", "high"], + "GHSA-jmj2-9c5q-vw73": [">=7.5.5 <8.0.0", "high"], + "GHSA-hqgx-p3r3-2cfg": ["<8.0.0", "high"], + "GHSA-gvrf-jx37-rjv5": ["<8.0.0", "high"], + "GHSA-6wwr-g865-f46r": [">=7.5.22 <8.0.0", "high"], + "GHSA-4pf9-5fpx-xmr6": [">=7.5.5 <8.0.0", "high"], + "GHSA-3wwj-8j6r-q339": [">=7.5.5 <8.0.0", "high"], + "GHSA-98v3-7xjr-fg83": [">=7.5.22 <8.0.0", "high"], + "GHSA-wpwg-r92p-fjjh": ["<8.0.0", "high"], + "GHSA-rgjp-p5j7-w36x": [">=7.5.0 <8.0.0", "high"], + "GHSA-qv2w-fc3h-pm27": ["<8.0.0", "high"], + "GHSA-p96f-8xj2-g85p": [">=7.0.0 <8.0.0", "moderate"], + "GHSA-mpg7-vg3p-wc3m": ["<8.0.0", "high"], + "GHSA-ffhw-4r4q-5cwv": ["<8.0.0", "high"], + "GHSA-7c32-79xj-j3jp": ["<8.0.2", "high"], + "GHSA-72fp-85cc-g945": [">=7.5.22 <8.0.0", "high"], +}; +const tarPackages = { + tar: { "node_modules/tar": "7.5.24" }, + pacote: { "node_modules/pacote": "21.5.1" }, + "node-gyp": { "node_modules/node-gyp": "12.4.0" }, + "@opencode/util": { "node_modules/@opencode/util": "2.0.23" }, +}; + +function matchesAdvisory(exception, cause) { + if (cause.name !== exception.root) return false; + if (exception.root !== "tar") { + return cause.url === exception.advisory && cause.range === exception.range; + } + return Object.entries(tarAdvisories).some( + ([id, [range, severity]]) => + cause.url === `https://github.com/advisories/${id}` && + cause.range === range && + cause.severity === severity, + ); +} + +export function checkAudit( + report, + lockfile = {}, + scope = "adapters", + now = Date.now(), +) { if (!Object.hasOwn(picomatchPackages, scope)) { throw new Error(`Unknown audit scope: ${scope}`); } @@ -75,6 +124,7 @@ export function checkAudit(report, lockfile = {}, scope = "adapters") { range: "<4.6.6", packages: zodPackages, }); + exceptions.push({ root: "tar", packages: tarPackages }); } if ( report.error || @@ -111,8 +161,9 @@ export function checkAudit(report, lockfile = {}, scope = "adapters") { ); } for (const [name, finding] of severe) { - const exception = exceptions.find((entry) => - Object.hasOwn(entry.packages, name), + const exception = exceptions.find( + (entry) => + Object.hasOwn(entry.packages, name) && reachesRoot(name, entry.root), ); const allowedNodes = exception?.packages[name]; if ( @@ -125,11 +176,20 @@ export function checkAudit(report, lockfile = {}, scope = "adapters") { finding.nodes.some( (path) => !Object.hasOwn(allowedNodes, path) || - lockfile.packages?.[path]?.version !== allowedNodes[path], + lockfile.packages?.[path]?.version !== allowedNodes[path] || + (exception.root === "tar" && lockfile.packages[path].dev !== true), ) ) { throw new Error(`Unapproved audit package, path or version: ${name}`); } + if ( + exception.root === "tar" && + (!Number.isFinite(now) || now >= Date.parse(tarExpires)) + ) { + throw new Error( + `Temporary tar audit exception expired (${tarExpires}); see #735`, + ); + } for (const cause of finding.via) { if (typeof cause === "string") { if (!report.vulnerabilities[cause] || name === exception.root) { @@ -137,11 +197,8 @@ export function checkAudit(report, lockfile = {}, scope = "adapters") { } } else if ( cause.severity === "critical" || - (cause.severity === "high" && - (name !== exception.root || - cause.name !== exception.root || - cause.url !== exception.advisory || - cause.range !== exception.range)) + ((cause.severity === "high" || exception.root === "tar") && + (name !== exception.root || !matchesAdvisory(exception, cause))) ) { throw new Error( `Advisory outside the temporary audit exception: ${name}`, @@ -153,7 +210,7 @@ export function checkAudit(report, lockfile = {}, scope = "adapters") { (name === exception.root && !finding.via.some( (cause) => - cause.severity === "high" && cause.url === exception.advisory, + cause.severity === "high" && matchesAdvisory(exception, cause), )) ) { throw new Error( @@ -188,7 +245,9 @@ export function auditDependencies(packageRoot, scope) { ); const counts = checkAudit(report, lockfile, scope); const exceptionNames = - scope === "adapters" ? "Zod (#485) and picomatch" : "picomatch"; + scope === "adapters" + ? "Zod (#485), picomatch and tar (#735, expires 2026-12-10 UTC)" + : "picomatch"; console.log( `npm audit: ${counts.high} high covered by temporary ${exceptionNames} CI exceptions (picomatch review 2026-11-24); ` + `${counts.critical} critical; ` +