Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,18 @@ jobs:
shell: pwsh
run: pnpm run test:ci

- name: Install the minimum supported Node.js for the built CLI
if: matrix.suite == 'regular' && matrix.lane == 'linux-22'
shell: bash
run: node scripts/setup/node.mts --version 18.20.8

- name: Check CLI startup on Node.js 18
if: matrix.suite == 'regular' && matrix.lane == 'linux-22'
shell: bash
run: |
test "$(node --version)" = v18.20.8
test "$(node bin/cli.js --version)" = "$(node -p "require('./package.json').version")"

- name: Build for E2E tests
if: matrix.suite == 'e2e'
run: pnpm run build
Expand Down
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ module.exports = [
'src/*/*/*.test.mts',
// Allow paths like src/commands/manifest/bazel/*.test.mts.
'src/*/*/*/*.test.mts',
'test/patches/*.test.mts',
'test/unit/*.test.mts',
'test/*.mts',
'test/src/utils/*.test.mts',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
"semver": "7.7.2",
"svgo": "4.1.0",
"synp": "1.9.14",
"tar": "7.5.23",
"tar": "8.0.5",
Comment thread
jdalton marked this conversation as resolved.
Resolved
"taze": "21.3.0",
"terminal-link": "2.1.1",
"tiny-updater": "3.5.3",
Expand Down
117 changes: 117 additions & 0 deletions patches/@cyclonedx__cdxgen@12.9.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
diff --git a/lib/managers/docker.js b/lib/managers/docker.js
--- a/lib/managers/docker.js
+++ b/lib/managers/docker.js
@@ -1,6 +1,5 @@
import { Buffer } from "node:buffer";
import {
- createReadStream,
lstatSync,
readdirSync,
readFileSync,
@@ -8,7 +7,6 @@
import { platform as _platform, userInfo as _userInfo, homedir } from "node:os";
import { basename, join, resolve, win32 } from "node:path";
import process from "node:process";
-import stream from "node:stream/promises";
import { URL } from "node:url";

import { x } from "tar";
@@ -1481,23 +1479,18 @@
return await safeExtractArchive(
fullImageName,
dir,
- async () =>
- await stream.pipeline(
- createReadStream(fullImageName),
- x({
- sync: false,
- preserveOwner: false,
- noMtime: true,
- noChmod: true,
- strict: !NON_STRICT_TAR_EXTRACT,
- C: dir,
- portable: true,
- unlink: true,
- onwarn: handleTarWarning,
- onReadEntry: handleAbsolutePath,
- filter: tarFilter,
- }),
- ),
+ () =>
+ x({
+ file: fullImageName,
+ preserveOwner: false,
+ noMtime: true,
+ strict: !NON_STRICT_TAR_EXTRACT,
+ cwd: dir,
+ unlink: true,
+ onwarn: handleTarWarning,
+ onEntry: handleAbsolutePath,
+ filter: tarFilter,
+ }),
"untar",
{
blockedReason:
@@ -1956,41 +1949,31 @@
console.log(`About to export image ${fullImageName} to ${tempDir}`);
}
}
- await stream.pipeline(
- client.stream(`images/${fullImageName}/get`),
- x({
- sync: false,
- preserveOwner: false,
- noMtime: true,
- noChmod: true,
- strict: !NON_STRICT_TAR_EXTRACT,
- C: tempDir,
- portable: true,
- unlink: true,
- onwarn: handleTarWarning,
- onReadEntry: handleAbsolutePath,
- filter: tarFilter,
- }),
- );
+ await x({
+ input: client.stream(`images/${fullImageName}/get`),
+ preserveOwner: false,
+ noMtime: true,
+ strict: !NON_STRICT_TAR_EXTRACT,
+ cwd: tempDir,
+ unlink: true,
+ onwarn: handleTarWarning,
+ onEntry: handleAbsolutePath,
+ filter: tarFilter,
+ });
} catch (_err) {
if (localData?.Id) {
console.log(`Retrying with ${localData.Id}`);
try {
- await stream.pipeline(
- client.stream(`images/${localData.Id}/get`),
- x({
- sync: true,
- preserveOwner: false,
- noMtime: true,
- noChmod: true,
- strict: !NON_STRICT_TAR_EXTRACT,
- C: tempDir,
- portable: true,
- onwarn: handleTarWarning,
- onReadEntry: handleAbsolutePath,
- filter: tarFilter,
- }),
- );
+ await x({
+ input: client.stream(`images/${localData.Id}/get`),
+ preserveOwner: false,
+ noMtime: true,
+ strict: !NON_STRICT_TAR_EXTRACT,
+ cwd: tempDir,
+ onwarn: handleTarWarning,
+ onEntry: handleAbsolutePath,
+ filter: tarFilter,
+ });
} catch (_err) {
// ignore
}
33 changes: 33 additions & 0 deletions patches/@socketregistry__packageurl-js@1.7.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
diff --git a/dist/index.js b/dist/index.js
--- a/dist/index.js
+++ b/dist/index.js
@@ -1046,7 +1046,7 @@
const ArrayPrototypeSplice = require_primordials_uncurry.uncurryThis(Array.prototype.splice);
const ArrayPrototypeToLocaleString = require_primordials_uncurry.uncurryThis(Array.prototype.toLocaleString);
const ArrayPrototypeToReversed = require_primordials_uncurry.uncurryThis(Array.prototype.toReversed);
- const ArrayPrototypeToSorted = require_primordials_uncurry.uncurryThis(Array.prototype.toSorted);
+ const ArrayPrototypeToSorted = typeof Array.prototype.toSorted === 'function' ? require_primordials_uncurry.uncurryThis(Array.prototype.toSorted) : ((values, compareFn) => ArrayPrototypeSort(ArrayFrom(values), compareFn));
const ArrayPrototypeToSpliced = require_primordials_uncurry.uncurryThis(Array.prototype.toSpliced);
const ArrayPrototypeToString = require_primordials_uncurry.uncurryThis(Array.prototype.toString);
const ArrayPrototypeUnshift = require_primordials_uncurry.uncurryThis(Array.prototype.unshift);
diff --git a/dist/exists.js b/dist/exists.js
--- a/dist/exists.js
+++ b/dist/exists.js
@@ -1845,7 +1845,7 @@
const ArrayPrototypeSplice = require_primordials_uncurry.uncurryThis(Array.prototype.splice);
const ArrayPrototypeToLocaleString = require_primordials_uncurry.uncurryThis(Array.prototype.toLocaleString);
const ArrayPrototypeToReversed = require_primordials_uncurry.uncurryThis(Array.prototype.toReversed);
- const ArrayPrototypeToSorted = require_primordials_uncurry.uncurryThis(Array.prototype.toSorted);
+ const ArrayPrototypeToSorted = typeof Array.prototype.toSorted === 'function' ? require_primordials_uncurry.uncurryThis(Array.prototype.toSorted) : ((values, compareFn) => ArrayPrototypeSort(ArrayFrom(values), compareFn));
const ArrayPrototypeToSpliced = require_primordials_uncurry.uncurryThis(Array.prototype.toSpliced);
const ArrayPrototypeToString = require_primordials_uncurry.uncurryThis(Array.prototype.toString);
const ArrayPrototypeUnshift = require_primordials_uncurry.uncurryThis(Array.prototype.unshift);
@@ -14080,7 +14080,7 @@
const ArrayPrototypeSplice = require_primordials_uncurry.uncurryThis(Array.prototype.splice);
const ArrayPrototypeToLocaleString = require_primordials_uncurry.uncurryThis(Array.prototype.toLocaleString);
const ArrayPrototypeToReversed = require_primordials_uncurry.uncurryThis(Array.prototype.toReversed);
- const ArrayPrototypeToSorted = require_primordials_uncurry.uncurryThis(Array.prototype.toSorted);
+ const ArrayPrototypeToSorted = typeof Array.prototype.toSorted === 'function' ? require_primordials_uncurry.uncurryThis(Array.prototype.toSorted) : ((values, compareFn) => ArrayPrototypeSort(ArrayFrom(values), compareFn));
const ArrayPrototypeToSpliced = require_primordials_uncurry.uncurryThis(Array.prototype.toSpliced);
const ArrayPrototypeToString = require_primordials_uncurry.uncurryThis(Array.prototype.toString);
const ArrayPrototypeUnshift = require_primordials_uncurry.uncurryThis(Array.prototype.unshift);
21 changes: 21 additions & 0 deletions patches/@socketsecurity__sdk@4.3.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/dist/index.js b/dist/index.js
--- a/dist/index.js
+++ b/dist/index.js
@@ -1937,7 +1937,7 @@
const ArrayPrototypeSplice = require_primordials_uncurry.uncurryThis(Array.prototype.splice);
const ArrayPrototypeToLocaleString = require_primordials_uncurry.uncurryThis(Array.prototype.toLocaleString);
const ArrayPrototypeToReversed = require_primordials_uncurry.uncurryThis(Array.prototype.toReversed);
- const ArrayPrototypeToSorted = require_primordials_uncurry.uncurryThis(Array.prototype.toSorted);
+ const ArrayPrototypeToSorted = typeof Array.prototype.toSorted === 'function' ? require_primordials_uncurry.uncurryThis(Array.prototype.toSorted) : ((values, compareFn) => ArrayPrototypeSort(ArrayFrom(values), compareFn));
const ArrayPrototypeToSpliced = require_primordials_uncurry.uncurryThis(Array.prototype.toSpliced);
const ArrayPrototypeToString = require_primordials_uncurry.uncurryThis(Array.prototype.toString);
const ArrayPrototypeUnshift = require_primordials_uncurry.uncurryThis(Array.prototype.unshift);
@@ -3981,7 +3981,7 @@
const ArrayPrototypeSplice = require_primordials_uncurry.uncurryThis(Array.prototype.splice);
const ArrayPrototypeToLocaleString = require_primordials_uncurry.uncurryThis(Array.prototype.toLocaleString);
const ArrayPrototypeToReversed = require_primordials_uncurry.uncurryThis(Array.prototype.toReversed);
- const ArrayPrototypeToSorted = require_primordials_uncurry.uncurryThis(Array.prototype.toSorted);
+ const ArrayPrototypeToSorted = typeof Array.prototype.toSorted === 'function' ? require_primordials_uncurry.uncurryThis(Array.prototype.toSorted) : ((values, compareFn) => ArrayPrototypeSort(ArrayFrom(values), compareFn));
const ArrayPrototypeToSpliced = require_primordials_uncurry.uncurryThis(Array.prototype.toSpliced);
const ArrayPrototypeToString = require_primordials_uncurry.uncurryThis(Array.prototype.toString);
const ArrayPrototypeUnshift = require_primordials_uncurry.uncurryThis(Array.prototype.unshift);
13 changes: 13 additions & 0 deletions patches/node-gyp@13.1.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/lib/install.js b/lib/install.js
--- a/lib/install.js
+++ b/lib/install.js
@@ -231,7 +231,8 @@
contentShasums[filename] = checksum
log.verbose('content checksum', filename, checksum)
}),
- tar.extract({
+ async input => tar.extract({
+ input,
strip: 1,
cwd: tarExtractDir,
filter: isValid,
132 changes: 132 additions & 0 deletions patches/pacote@22.0.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
diff --git a/lib/dir.js b/lib/dir.js
--- a/lib/dir.js
+++ b/lib/dir.js
@@ -1,6 +1,5 @@
-const { resolve, join } = require('node:path')
-const { mkdtemp, writeFile, rm } = require('node:fs/promises')
-const { tmpdir } = require('node:os')
+const { resolve } = require('node:path')
+const { Readable } = require('node:stream')
const packlist = require('npm-packlist')
const runScript = require('@npmcli/run-script')
const tar = require('tar')
@@ -82,11 +81,8 @@
return packlist(this.tree, { path: this.resolved, prefix, workspaces, globalIgnoreFile })
})
.then(async files => {
- const { options, cleanup } = await this.#tarOptions()
- const source = tar.c(options, files)
- // the strip temp file must outlive content consumption, so clean up once the stream is done
- source.once('end', cleanup)
- source.once('error', cleanup)
+ const options = await this.#tarOptions()
+ const source = Readable.fromWeb(tar.c(options, files))
return source.on('error', er => stream.emit('error', er)).pipe(stream)
})
.catch(er => stream.emit('error', er))
@@ -94,7 +90,7 @@
}

// Build the tar create options.
- // When the packed package.json declares patchedDependencies, redirect it to a stripped copy so project-local patches never ship.
+ // When the packed package.json declares patchedDependencies, replace its archive body with a stripped copy so project-local patches never ship.
// Non-patched packs are unchanged.
async #tarOptions () {
const options = tarCreateOptions(this.package)
@@ -102,7 +98,7 @@
// read package.json from disk after prepare so the strip reflects the actually-packed manifest.
const pkgJson = await PackageJson.load(this.resolved)
if (!('patchedDependencies' in pkgJson.content)) {
- return { options, cleanup: () => {} }
+ return options
}

// serialize the package.json minus patchedDependencies, preserving its indent and newline.
@@ -113,30 +109,22 @@
const newline = content[Symbol.for('newline')]
const stripped = `${JSON.stringify(content, null, indent)}\n`.replace(/\n/g, newline)

- // write the stripped copy to a temp dir, removing it if the write itself fails.
- const dir = await mkdtemp(join(tmpdir(), 'pacote-pack-'))
- const strippedPath = join(dir, 'package.json')
- try {
- await writeFile(strippedPath, stripped)
- } catch (er) {
- /* istanbul ignore next - writing to a freshly created temp dir is not deterministically failable */
- await rm(dir, { recursive: true, force: true })
- /* istanbul ignore next */
- throw er
+ const body = Buffer.from(stripped)
+ const filter = options.filter
+ options.filter = (path, stat) => {
+ // Keep hard links to the original manifest independent of the stripped entry.
+ if (path === 'package.json') {
+ stat.nlink = 1
+ }
+ return filter(path, stat)
}
- const size = Buffer.byteLength(stripped)
-
- // point only the top-level package.json entry at the stripped copy; every other file is untouched.
- // onWriteEntry runs before the tar header and the file's hardlink check, so size and nlink here are honored.
- options.onWriteEntry = (entry) => {
+ options.onWriteEntry = entry => {
if (entry.path === 'package.json') {
- entry.absolute = strippedPath
- entry.stat.size = size
- entry.stat.nlink = 1
+ entry.body = body
+ entry.size = body.length
}
}
-
- return { options, cleanup: () => rm(dir, { recursive: true, force: true }) }
+ return options
}

manifest () {
diff --git a/lib/fetcher.js b/lib/fetcher.js
--- a/lib/fetcher.js
+++ b/lib/fetcher.js
@@ -385,28 +385,19 @@
return this.#toFile(dest)
}

- #extract (dest, tarball) {
- const extractor = tar.x(this.#tarxOptions({ cwd: dest }))
- const p = new Promise((resolve, reject) => {
- extractor.on('end', () => {
- resolve({
- resolved: this.resolved,
- integrity: this.integrity && String(this.integrity),
- from: this.from,
- })
- })
-
- extractor.on('error', er => {
- log.warn('tar', er.message)
- log.silly('tar', er)
- reject(er)
- })
-
- tarball.on('error', er => reject(er))
- })
-
- tarball.pipe(extractor)
- return p
+ async #extract (dest, tarball) {
+ try {
+ await tar.x({ ...this.#tarxOptions({ cwd: dest }), input: tarball })
+ } catch (er) {
+ log.warn('tar', er.message)
+ log.silly('tar', er)
+ throw er
+ }
+ return {
+ resolved: this.resolved,
+ integrity: this.integrity && String(this.integrity),
+ from: this.from,
+ }
}

// always ensure that entries are at least as permissive as our configured
Loading
Loading