Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
#
# One `extra-command`, so they're chained. `&&` short-circuits, which is
# what we want: either failing fails the job.
extra-command: npm pack --dry-run && pnpm run changelog:check
extra-command: npm pack --dry-run && pnpm run changelog:check && pnpm run security:check
# Nothing here uses turbo.
turbo-cache: false

Expand Down
2 changes: 2 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ Development installs use basic-ftp 6, Zod 4, minimatch 11 and glob 14 for their
Use Node 24 and the pinned pnpm version. We use Jest 30 with a TypeScript transformer for these Node-based config-plugin tests. Type checking runs separately. The old expo-module-scripts package and its `expo-module` command are removed; use `pnpm run build`, `pnpm run clean` and `pnpm run test` directly. Jest mocks that require Babel hoisting need explicit setup before importing the module under test.

These are contributor tooling changes. Consumers keep the same plugin options. Security commits under `build(deps)` deliberately recommend a patch release under our changelog policy; ordinary chore, build and docs commits alone recommend no release. Public breaking changes still require a conventional breaking-change note with migration instructions, which the shared preset carries into the changelog, release body and annotated tag.

Picomatch 2.3.2 and 4.0.5 have candidate local parser patches for GHSA-fc5q-39xc-vjpf. These candidates restrict repeated extglob grammar while preserving tested benign cases, including nested star reduction. Installed parser hashes and each reported dependency path are checked. Independent security review is blocked, so the candidate audit gate fails regardless of the current registry status. The candidate is not approved for merge or release.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"test": "node tools/dependency-security-check.mjs && node tools/release-check.mjs && jest",
"prepare": "pnpm run build",
"release": "release-it",
"security:check": "node tools/dependency-security-check.mjs && pnpm audit --audit-level high"
"security:check": "node tools/dependency-security-check.mjs && node tools/security-audit.mjs"
},
"devDependencies": {
"@babel/core": "^7.29.7",
Expand Down
56 changes: 56 additions & 0 deletions patches/picomatch@2.3.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -292,6 +292,30 @@

const branches = splitTopLevel(body).map(branch => branch.trim());

+ // Wildcard operands inside a repeated branch introduce nested quantifiers.
+ // Escaped tokens and ordinary character classes do not.
+ let nested = false;
+ let bracket = false;
+ let escaped = false;
+ let quoted = false;
+ for (let index = 0; index < body.length; index++) {
+ const ch = body[index];
+ if (escaped) { escaped = false; continue; }
+ if (ch === '\\') { escaped = true; continue; }
+ if (!bracket && ch === '"') { quoted = !quoted; continue; }
+ if (quoted) continue;
+ if (bracket && ch === '[' && body[index + 1] === ':') {
+ const end = body.indexOf(':]', index + 2);
+ if (end !== -1) { index = end + 1; continue; }
+ }
+ if (ch === '[') { bracket = true; continue; }
+ if (ch === ']') { bracket = false; continue; }
+ if (!bracket && (ch === '(' || ch === '{')) nested = true;
+ if (!bracket && ch === '*' && body[index + 1] !== '(') {
+ return { risky: true };
+ }
+ }
+
if (branches.length > 1) {
if (
branches.some(branch => branch === '') ||
@@ -304,7 +328,7 @@

for (const branch of branches) {
const safeOutput = getStarExtglobSequenceOutput(branch);
- if (safeOutput) {
+ if (safeOutput && branches.length === 1) {
return { risky: true, safeOutput };
}

@@ -313,6 +337,13 @@
}
}

+ // Preserve flat literal alternatives with disjoint initial characters.
+ // Other nested/alternative grammar is matched literally unless the existing
+ // character-sequence reduction above already proved a safe output.
+ if (nested || (branches.length > 1 && (
+ branches.some(branch => !/^[a-zA-Z0-9_/-]+$/.test(branch)) ||
+ new Set(branches.map(branch => branch[0])).size !== branches.length
+ ))) return { risky: true };
return { risky: false };
};

47 changes: 47 additions & 0 deletions patches/picomatch@4.0.5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -296,6 +296,30 @@

const branches = splitTopLevel(body).map(branch => branch.trim());

+ // Wildcard operands inside a repeated branch introduce nested quantifiers.
+ // Escaped tokens and ordinary character classes do not.
+ let nested = false;
+ let bracket = false;
+ let escaped = false;
+ let quoted = false;
+ for (let index = 0; index < body.length; index++) {
+ const ch = body[index];
+ if (escaped) { escaped = false; continue; }
+ if (ch === '\\') { escaped = true; continue; }
+ if (!bracket && ch === '"') { quoted = !quoted; continue; }
+ if (quoted) continue;
+ if (bracket && ch === '[' && body[index + 1] === ':') {
+ const end = body.indexOf(':]', index + 2);
+ if (end !== -1) { index = end + 1; continue; }
+ }
+ if (ch === '[') { bracket = true; continue; }
+ if (ch === ']') { bracket = false; continue; }
+ if (!bracket && (ch === '(' || ch === '{')) nested = true;
+ if (!bracket && ch === '*' && body[index + 1] !== '(') {
+ return { risky: true };
+ }
+ }
+
if (branches.length > 1) {
if (
branches.some(branch => branch === '') ||
@@ -343,6 +367,13 @@
: { risky: true };
}

+ // Preserve flat literal alternatives with disjoint initial characters.
+ // Other nested/alternative grammar is matched literally unless the existing
+ // character-sequence reduction above already proved a safe output.
+ if (nested || (branches.length > 1 && (
+ branches.some(branch => !/^[a-zA-Z0-9_/-]+$/.test(branch)) ||
+ new Set(branches.map(branch => branch[0])).size !== branches.length
+ ))) return { risky: true };
return { risky: false };
};

34 changes: 18 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,5 @@ patchedDependencies:
deepmerge@4.3.1: patches/deepmerge@4.3.1.patch
image-size@1.2.1: patches/image-size@1.2.1.patch
minimatch@11.0.4: patches/minimatch@11.0.4.patch
picomatch@2.3.2: patches/picomatch@2.3.2.patch
picomatch@4.0.5: patches/picomatch@4.0.5.patch
1 change: 1 addition & 0 deletions tools/dependency-security-check.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "./picomatch-security-check.mjs";
import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";
import {
Expand Down
82 changes: 82 additions & 0 deletions tools/picomatch-security-check.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";
import { createHash } from "node:crypto";
import { readFileSync, readdirSync, realpathSync } from "node:fs";
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);
const hashes = {
"2.3.2": "296547ec9d733720b648854bc52a4cfa1c255247336c10b0f6745433bd9e01f2",
"4.0.5": "86a303b54f309277db4070784c140f955e4e73e5dd9862b813985c4e392ffd32",
};
export const picomatchEntries = new Map();
const store = new URL("../node_modules/.pnpm/", import.meta.url);
for (const directory of readdirSync(store).filter((name) =>
name.startsWith("picomatch@"),
)) {
const root = new URL(`${directory}/node_modules/picomatch/`, store);
const { version } = JSON.parse(
readFileSync(new URL("package.json", root), "utf8"),
);
assert.ok(hashes[version], `Unverified picomatch version: ${version}`);
const digest = createHash("sha256")
.update(readFileSync(new URL("lib/parse.js", root)))
.digest("hex");
assert.equal(digest, hashes[version], `Unpatched picomatch: ${directory}`);
const entry = realpathSync(require.resolve(root.pathname));
picomatchEntries.set(entry, version);
const probe = spawnSync(
process.execPath,
[
"-e",
`
const p = require(${JSON.stringify(entry)});
const a = require('node:assert/strict');
a.equal(p('+(a|b)')('abba'), true);
a.equal(p('+(*(a))')('aaaa'), true);
a.equal(p('+([ab])')('abba'), true);
a.equal(p('+([*?])')('*?*'), true);
a.equal(p(String.raw\`+(\\*)\`)('***'), true);
a.equal(p('src/**/*.ts')('src/a/b.ts'), true);
a.equal(p('+(file?.ts)')('file1.tsfile2.ts'), true);
a.equal(p('+("*")')('***'), true);
a.equal(p('+([[:alpha:]*])')('a*a'), true);
`,
],
{ timeout: 3000, killSignal: "SIGKILL", encoding: "utf8" },
);
assert.equal(probe.status, 0, probe.stderr || String(probe.error));
console.log(
`picomatch ${version}: exact parser hash and benign compatibility probes passed`,
);
}
assert.deepEqual(
new Set(picomatchEntries.values()),
new Set(Object.keys(hashes)),
);

// Resolve every edge from the project, including packages with only type exports.
export const verifyPicomatchFinding = (finding) => {
assert.ok(finding.paths.length > 0, "Missing audit dependency paths");
for (const path of finding.paths) {
const names = path.split(">");
assert.equal(names.shift(), ".");
assert.equal(names.at(-1), "picomatch");
let entry = new URL("../package.json", import.meta.url).pathname;
for (const name of names) {
const from = createRequire(entry);
try {
entry = from.resolve(`${name}/package.json`);
} catch {
entry = from.resolve(name);
}
}
// Normalize package.json to its public entry before comparing real paths.
const resolved = createRequire(entry).resolve("picomatch");
assert.equal(
picomatchEntries.get(realpathSync(resolved)),
finding.version,
`Unverified audit path: ${path}`,
);
}
};
39 changes: 39 additions & 0 deletions tools/security-audit.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";

import { verifyPicomatchFinding } from "./picomatch-security-check.mjs";

// Validate the candidate without accepting the advisory while independent
// security review is blocked. Existing workspace exceptions remain unchanged.
const result = spawnSync("pnpm", ["audit", "--json"], {
encoding: "utf8",
timeout: 60000,
maxBuffer: 10 * 1024 * 1024,
});
assert.ok(
result.status === 0 || result.status === 1,
result.stderr || String(result.error),
);
const audit = JSON.parse(result.stdout);
assert.ok(audit.metadata && audit.advisories, "Missing audit response");
let paths = 0;
for (const advisory of Object.values(audit.advisories)) {
assert.equal(
advisory.github_advisory_id,
"GHSA-fc5q-39xc-vjpf",
`Unmitigated advisory: ${advisory.github_advisory_id}`,
);
assert.equal(advisory.module_name, "picomatch");
assert.ok(advisory.findings.length > 0);
for (const finding of advisory.findings) {
verifyPicomatchFinding(finding);
paths += finding.paths.length;
}
}
console.log(
`Validated ${paths} candidate picomatch audit paths; security review remains blocked.`,
);
// Keep the candidate blocked even when the registry withdraws or omits a finding.
assert.fail(
"Independent parser security review is blocked; do not merge or release this candidate.",
);
Loading