fix: harden windows npm runtime path

This commit is contained in:
Peter Steinberger
2026-03-12 22:03:10 +00:00
parent 92191fcd68
commit 86a3149b2e
7 changed files with 81 additions and 8 deletions

View File

@@ -218,6 +218,16 @@ function runPackDry(): PackResult[] {
return JSON.parse(raw) as PackResult[];
}
export function collectForbiddenPackPaths(paths: Iterable<string>): string[] {
return [...paths]
.filter(
(path) =>
forbiddenPrefixes.some((prefix) => path.startsWith(prefix)) ||
/(^|\/)node_modules\//.test(path),
)
.toSorted();
}
function checkPluginVersions() {
const rootPackagePath = resolve("package.json");
const rootPackage = JSON.parse(readFileSync(rootPackagePath, "utf8")) as PackageJson;
@@ -422,9 +432,7 @@ function main() {
return paths.has(group) ? [] : [group];
})
.toSorted();
const forbidden = [...paths].filter((path) =>
forbiddenPrefixes.some((prefix) => path.startsWith(prefix)),
);
const forbidden = collectForbiddenPackPaths(paths);
if (missing.length > 0 || forbidden.length > 0) {
if (missing.length > 0) {