Pin dependency policy exceptions to versions
This commit is contained in:
+5
-3
@@ -20,14 +20,16 @@ export async function readProject(projectPath) {
|
||||
return { manifest, lock, direct };
|
||||
}
|
||||
|
||||
export function inspectLock(lock, policy) {
|
||||
export function inspectLock(lock, policy, now = Date.now()) {
|
||||
const failures = [];
|
||||
let registryEntries = 0;
|
||||
for (const [lockPath, entry] of Object.entries(lock.packages)) {
|
||||
if (!lockPath || entry.link) continue;
|
||||
const name = packageNameFromLockPath(lockPath, entry) ?? lockPath;
|
||||
if (entry.hasInstallScript && !policy.allowInstallScripts.includes(name)) {
|
||||
failures.push(`${name}: lock entry declares hasInstallScript; add a reviewed allowInstallScripts exception if intentional`);
|
||||
const scriptException = policy.allowInstallScripts[name];
|
||||
const scriptAllowed = scriptException?.versions.includes(entry.version) && Date.parse(scriptException.expiresAt) > now;
|
||||
if (entry.hasInstallScript && !scriptAllowed) {
|
||||
failures.push(`${name}@${entry.version ?? "unknown"}: lock entry declares hasInstallScript; add a reviewed, version-pinned allowInstallScripts exception if intentional`);
|
||||
}
|
||||
if (!lockPath.includes("node_modules/")) continue;
|
||||
registryEntries += 1;
|
||||
|
||||
Reference in New Issue
Block a user