Files
ruvnet--ruflo/scripts/audit-supply-chain.mjs
wehub-resource-sync 23f7624596
ADR-166 MCP Bridge Security Lock / Static-source security lock (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / Compose default binds loopback + Mongo has auth (push) Failing after 2s
CodeQL Advanced / Analyze (rust) (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / plugin-agent-federation bindHost default (push) Failing after 1s
ADR-166 MCP Bridge Security Lock / Runtime behavior — 401 + terminal gate + fail-closed (push) Failing after 4s
business-pods-smoke / smoke (push) Failing after 1s
all-plugins-smoke / smoke-all (push) Failing after 2s
CI/CD Pipeline / Security & Code Quality (push) Failing after 1s
CI/CD Pipeline / Test Suite (ubuntu-latest) (push) Failing after 1s
CI/CD Pipeline / Build & Package (macos-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (ubuntu-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (windows-latest) (push) Has been skipped
CI/CD Pipeline / Documentation & Examples (push) Failing after 1s
Clone Tracker (14-day rolling) / Snapshot clones for ruflo ecosystem (push) Failing after 1s
CodeQL Advanced / Analyze (actions) (push) Failing after 1s
CodeQL Advanced / Analyze (javascript-typescript) (push) Failing after 1s
federation-peer-rust / stable-noop (push) Failing after 1s
metaharness-ci / score (push) Failing after 1s
metaharness-ci / router-compat (push) Failing after 0s
metaharness-ci / similarity-tests (push) Failing after 0s
no-agentbbs-smoke / smoke-without-agentbbs (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (windows-latest) (push) Has been skipped
codex-integration-audit / Codex integration audit (push) Failing after 1s
helpers-manifest-guard / guard (push) Failing after 1s
🔗 Cross-Agent Integration Tests / 🤝 Agent Coordination Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🧠 Memory Sharing Integration (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🛡️ Fault Tolerance Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / ⚡ Performance Integration Tests (push) Has been skipped
metaharness-ci / mcp-scan (push) Failing after 1s
metaharness-ci / eject-dryrun (push) Failing after 1s
metaharness-ci / metaharness-real-data (push) Failing after 0s
no-cli-optdep-bloat-2561 / guard (push) Failing after 1s
no-metaharness-smoke / smoke-without-metaharness (push) Failing after 1s
no-phantom-agentic-flow-subpath / guard (push) Failing after 1s
🔄 Automated Rollback Manager / 🚨 Failure Detection (push) Failing after 1s
V3 CI/CD Pipeline / Plugin hooks smoke / ubuntu-latest / Node 22 (push) Failing after 1s
V3 CI/CD Pipeline / ruflo-graph-intelligence build + test smoke (#2044, ADR-123) (push) Failing after 1s
CVE Audit Gate / Audit root (critical-blocking) (push) Failing after 2s
cost-tracker-smoke / smoke (push) Failing after 3s
oia-audit-weekly / audit (push) Failing after 2s
ruflo-agent-smoke / ruflo-agent structural smoke (push) Failing after 1s
📊 Status Badges Update / 📊 Update Status Badges (push) Failing after 1s
V3 CI/CD Pipeline / Static regression guards (#2267 YAML + (push) Failing after 1s
V3 CI/CD Pipeline / Test V3 Packages (push) Failing after 0s
V3 CI/CD Pipeline / agent_execute provider routing smoke (#2042) (push) Failing after 0s
CVE Audit Gate / Audit v3 (critical-blocking) (push) Failing after 1s
federation-peer-rust / stable-native (push) Failing after 2s
🔗 Cross-Agent Integration Tests / 🚀 Integration Test Setup (push) Failing after 2s
neural-trader-smoke / runtime-smoke (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (macos-latest) (push) Has been skipped
V3 CI/CD Pipeline / Build V3 (ubuntu-latest) (push) Has been skipped
V3 CI/CD Pipeline / Type Check V3 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 24 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 22 (push) Failing after 2s
V3 CI/CD Pipeline / browser rvf create flag smoke (#2015) (push) Failing after 0s
V3 CI/CD Pipeline / Dependency review (#2046) (push) Has been skipped
V3 CI/CD Pipeline / Supply-chain audit (#2046) (push) Failing after 0s
V3 CI/CD Pipeline / witness marker drift smoke (#2021) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader portfolio CG smoke (#2068, ADR-126 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader backtest signing smoke (#2068, ADR-126 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / kg-extract type-import classification smoke (#2049) (push) Failing after 0s
V3 CI/CD Pipeline / witness verify precondition smoke (#1880) (push) Failing after 2s
V3 CI/CD Pipeline / neural-trader pipeline risk-gate smoke (#2068, ADR-126 Phase 5) (push) Failing after 0s
V3 CI/CD Pipeline / neural-trader feature attribution smoke (#2068, ADR-126 Phase 6) (push) Failing after 0s
V3 CI/CD Pipeline / plugin-registry signature verification smoke (#1922, CWE-347) (push) Failing after 4s
V3 CI/CD Pipeline / memory stats legacy-DB smoke (#2120) (push) Failing after 4s
V3 CI/CD Pipeline / github deprecated actions smoke (#2089, ADR-127 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / graph query + pathfinder smoke (ADR-130 P2+P5) (push) Has been skipped
V3 CI/CD Pipeline / graph trajectory hooks smoke (ADR-130 P3) (push) Has been skipped
V3 CI/CD Pipeline / graph plugin adapter smoke (ADR-130 P4) (push) Has been skipped
V3 CI/CD Pipeline / graph benchmark (ADR-130 P6) (push) Has been skipped
V3 CI/CD Pipeline / statusline generator delegation smoke (#2195) (push) Failing after 1s
V3 CI/CD Pipeline / wizard init regression guard (#2206 (push) Failing after 1s
V3 CI/CD Pipeline / memory no-stray-db smoke (ADR-125 P7) (push) Failing after 1s
V3 CI/CD Pipeline / github-safe injection smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github actions pin smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github attribution opt-in smoke (#2089, ADR-127 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / pre-bash hook safety smoke (#2017) (push) Failing after 1s
V3 CI/CD Pipeline / Memory import smoke / ubuntu-latest (push) Failing after 0s
V3 CI/CD Pipeline / MCP protocol smoke / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / ruvllm WASM auto-init smoke (#2086) (push) Failing after 4s
V3 CI/CD Pipeline / MCP paired-tool round-trip smoke (#1889) (push) Failing after 1s
V3 CI/CD Pipeline / Plugin package install-safety (#1902/#1903/#1904) (push) Failing after 1s
V3 CI/CD Pipeline / Tool description discoverability (ADR-112) (push) Failing after 3s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (22) (push) Failing after 1s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (24) (push) Failing after 1s
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Vector-index dimension audit (#1947) (push) Failing after 0s
V3 CI/CD Pipeline / Hook-command install safety (#1921) (push) Failing after 1s
V3 CI/CD Pipeline / ToolOutputGuardrail smoke (ADR-131, (push) Failing after 1s
V3 CI/CD Pipeline / init-bundle invariants smoke (#2095, ADR-128 Phase 5) (push) Failing after 1s
V3 CI/CD Pipeline / wasm provider bridge smoke (ADR-129 P1) (push) Failing after 2s
V3 CI/CD Pipeline / wasm gallery CRUD smoke (ADR-129 P3) (push) Failing after 1s
V3 CI/CD Pipeline / wasm plugin bridge smoke (ADR-129 P4) (push) Failing after 0s
V3 CI/CD Pipeline / wasm compose smoke (ADR-129 P2) (push) Failing after 4s
V3 CI/CD Pipeline / graph schema smoke (ADR-130 P1) (push) Failing after 0s
Validate Marketplace / validate (push) Failing after 1s
🔍 Verification Pipeline / 🚀 Setup Verification (push) Failing after 1s
🔍 Verification Pipeline / 🛡️ Security Verification (push) Has been skipped
🔍 Verification Pipeline / 📝 Code Quality (push) Has been skipped
🔍 Verification Pipeline / 🧪 Test Verification (${{ matrix.os }}, Node ${{ matrix.node }}) (push) Has been skipped
🔍 Verification Pipeline / 🏗️ Build Verification (push) Has been skipped
🔍 Verification Pipeline / 📚 Documentation Verification (push) Has been skipped
CVE Audit Gate / High-severity report (warn only) (push) Has been cancelled
🔄 Automated Rollback Manager / 🔄 Execute Rollback (push) Has been cancelled
🔄 Automated Rollback Manager / ✅ Post-Rollback Verification (push) Has been cancelled
🔄 Automated Rollback Manager / 📊 Rollback Monitoring (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / windows-latest (push) Has been cancelled
🔄 Automated Rollback Manager / ⏳ Manual Rollback Approval (push) Has been cancelled
V3 CI/CD Pipeline / MCP protocol smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Memory import smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / ubuntu-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Publish to npm (alpha) (push) Has been cancelled
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / macos-latest / Node 22 (push) Has been cancelled
V3 CI/CD Pipeline / Plugin hooks smoke / macos-latest / Node 22 (push) Has been cancelled
CI/CD Pipeline / Deploy & Release (push) Has been cancelled
CI/CD Pipeline / CI Status (push) Has been cancelled
🔗 Cross-Agent Integration Tests / 📊 Integration Test Report (push) Has been cancelled
🔄 Automated Rollback Manager / 🔍 Pre-Rollback Validation (push) Has been cancelled
🔍 Verification Pipeline / ⚡ Performance Verification (push) Has been cancelled
🔍 Verification Pipeline / 📊 Verification Report (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:02:19 +08:00

379 lines
14 KiB
JavaScript

#!/usr/bin/env node
/**
* Supply chain audit (#2046, ADR-123 supply-chain hardening).
*
* Three layers of defence, run on every push and PR via .github/workflows/v3-ci.yml:
*
* 1. **CVE audit** — `npm audit --json --audit-level=high` for every package
* we publish or consume directly. Fails on any HIGH or CRITICAL finding
* in a DIRECT dep. Transitives are reported but only fail when CVE is in
* this repo's allowlist of "must-block" identifiers.
*
* 2. **Lockfile integrity** — every entry in package-lock.json must carry a
* SHA-512 `integrity` field. Missing or weak hashes are a tamper vector
* (a registry-mitm could swap a tarball without npm noticing).
*
* 3. **Top-level allowlist** — see .github/supply-chain/allowed-deps.json.
* New top-level deps require an explicit allowlist addition. This blocks
* a compromised maintainer (or a typo'd PR) from quietly adding a
* malicious dep.
*
* Plus, on a separate stage:
*
* 4. **Typosquat reject** — if any package.json declares a dependency name
* that matches an entry in `policies.rejectInRegistry`, fail immediately.
*
* Usage:
* node scripts/audit-supply-chain.mjs # full audit
* node scripts/audit-supply-chain.mjs --json # machine-readable
* node scripts/audit-supply-chain.mjs --scope cve # only the CVE pass
* node scripts/audit-supply-chain.mjs --scope lockfile
* node scripts/audit-supply-chain.mjs --scope allowlist
*/
import { readFileSync, existsSync } from 'node:fs';
import { execFileSync } from 'node:child_process';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const REPO_ROOT = join(__dirname, '..');
const ALLOWLIST_PATH = join(REPO_ROOT, '.github', 'supply-chain', 'allowed-deps.json');
const ACCEPTED_PATH = join(REPO_ROOT, '.github', 'supply-chain', 'accepted-findings.json');
const PACKAGES_TO_AUDIT = [
'plugins/ruflo-graph-intelligence',
'v3/@claude-flow/browser',
// Add more as supply-chain coverage expands. Existing packages with their
// own already-passing CVE story (memory, hooks, etc.) can come online by
// adding them here.
];
const ARGS = new Set(process.argv.slice(2));
const JSON_OUTPUT = ARGS.has('--json');
const SCOPE = (() => {
const scopeArg = process.argv.find((a) => a.startsWith('--scope'));
if (!scopeArg) return 'all';
const eqIndex = scopeArg.indexOf('=');
if (eqIndex !== -1) return scopeArg.slice(eqIndex + 1);
const i = process.argv.indexOf('--scope');
return process.argv[i + 1] ?? 'all';
})();
const results = {
cve: [],
lockfile: [],
allowlist: [],
typosquat: [],
publisherTrust: [],
};
function log(msg) {
if (!JSON_OUTPUT) console.log(msg);
}
function loadAllowlist() {
if (!existsSync(ALLOWLIST_PATH)) {
throw new Error(`allowlist not found at ${ALLOWLIST_PATH}`);
}
return JSON.parse(readFileSync(ALLOWLIST_PATH, 'utf8'));
}
function loadAcceptedFindings() {
if (!existsSync(ACCEPTED_PATH)) {
return { cve: [], lockfile: [] };
}
const data = JSON.parse(readFileSync(ACCEPTED_PATH, 'utf8'));
// Reject expired entries — they must be re-triaged.
const today = new Date().toISOString().slice(0, 10);
const expired = (data.cve ?? []).filter((e) => e.expiresAt && e.expiresAt < today);
if (expired.length > 0) {
console.warn(`WARN: ${expired.length} accepted-findings entries are EXPIRED and will not be honoured.`);
for (const e of expired) console.warn(` - ${e.package}/${e.depName} expired ${e.expiresAt}`);
}
return {
cve: (data.cve ?? []).filter((e) => !e.expiresAt || e.expiresAt >= today),
lockfile: data.lockfile ?? [],
};
}
function isAcceptedCve(finding, accepted) {
return accepted.cve.some(
(a) => a.package === finding.package && a.depName === finding.depName,
);
}
function isAcceptedLockfile(packagePath, entryPath, accepted) {
return accepted.lockfile.some(
(a) => a.package === packagePath && entryPath.includes(a.pattern),
);
}
// ---------------------------------------------------------------------------
// 1. CVE audit — fail on HIGH or CRITICAL in DIRECT deps
// ---------------------------------------------------------------------------
function runCveAudit(packageDir, accepted) {
const pkgPath = join(REPO_ROOT, packageDir, 'package.json');
if (!existsSync(pkgPath)) return;
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
const directDeps = new Set([
...Object.keys(pkg.dependencies ?? {}),
...Object.keys(pkg.devDependencies ?? {}),
...Object.keys(pkg.peerDependencies ?? {}),
]);
let audit;
try {
const out = execFileSync('npm', ['audit', '--json', '--audit-level=high'], {
cwd: join(REPO_ROOT, packageDir),
stdio: ['ignore', 'pipe', 'pipe'],
timeout: 60_000,
});
audit = JSON.parse(out.toString());
} catch (err) {
// `npm audit` exits non-zero when it finds vulnerabilities — that's
// still useful output; parse it.
if (err.stdout) {
try {
audit = JSON.parse(err.stdout.toString());
} catch {
results.cve.push({
package: packageDir,
failure: 'audit threw and stdout not JSON: ' + (err.message ?? String(err)),
});
return;
}
} else {
results.cve.push({ package: packageDir, failure: err.message ?? String(err) });
return;
}
}
const advisories = audit?.vulnerabilities ?? {};
const directHighCritical = [];
let acceptedCount = 0;
for (const [name, info] of Object.entries(advisories)) {
if (!directDeps.has(name)) continue;
if (info.severity === 'high' || info.severity === 'critical') {
const finding = {
package: packageDir,
depName: name,
severity: info.severity,
via: info.via,
fixAvailable: info.fixAvailable,
};
if (isAcceptedCve(finding, accepted)) {
acceptedCount++;
} else {
directHighCritical.push(finding);
}
}
}
if (directHighCritical.length > 0) {
results.cve.push(...directHighCritical);
}
log(` [cve] ${packageDir}: ${directHighCritical.length} HIGH/CRITICAL unaccepted, ${acceptedCount} accepted`);
}
// ---------------------------------------------------------------------------
// 2. Lockfile integrity — every entry must carry a SHA-512 hash
// ---------------------------------------------------------------------------
function runLockfileAudit(packageDir, accepted) {
const lockPath = join(REPO_ROOT, packageDir, 'package-lock.json');
if (!existsSync(lockPath)) {
log(` [lockfile] ${packageDir}: no package-lock.json — skipped`);
return;
}
const lock = JSON.parse(readFileSync(lockPath, 'utf8'));
let missing = 0;
let weak = 0;
let acceptedCount = 0;
// npm v7+ lockfile format: `packages` (path → metadata)
const packages = lock.packages ?? {};
for (const [path, meta] of Object.entries(packages)) {
// Root package entry has no integrity; skip
if (path === '') continue;
// Optional + workspace-link entries also legitimately have no integrity
if (meta.link) continue;
// Entries without `resolved` are dependency declarations (not downloads)
// and don't carry integrity in the npm v9+ lockfile format.
if (!meta.resolved) continue;
if (!meta.integrity) {
if (isAcceptedLockfile(packageDir, path, accepted)) {
acceptedCount++;
} else {
missing++;
}
continue;
}
if (!meta.integrity.startsWith('sha512-')) {
weak++;
}
}
if (missing > 0 || weak > 0) {
results.lockfile.push({
package: packageDir,
missing,
weak,
});
}
log(` [lockfile] ${packageDir}: ${missing} missing, ${weak} weak, ${acceptedCount} accepted`);
}
// ---------------------------------------------------------------------------
// 3. Top-level allowlist — fail if a package declares a dep not in allowlist
// ---------------------------------------------------------------------------
function runAllowlistAudit(allowlist) {
for (const [pkgName, expected] of Object.entries(allowlist.packages)) {
// Find this package's package.json by scanning known locations
const candidates = [
join(REPO_ROOT, 'plugins', pkgName, 'package.json'),
join(REPO_ROOT, 'v3', pkgName, 'package.json'), // e.g. v3/@claude-flow/browser
];
let pkgPath;
for (const c of candidates) {
if (existsSync(c)) { pkgPath = c; break; }
}
if (!pkgPath) {
results.allowlist.push({
package: pkgName,
failure: 'allowlist references a package whose package.json was not found',
});
continue;
}
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
const buckets = ['dependencies', 'devDependencies', 'peerDependencies'];
for (const bucket of buckets) {
const declared = Object.keys(pkg[bucket] ?? {});
const allowed = new Set(expected[bucket] ?? []);
const extra = declared.filter((d) => !allowed.has(d));
if (extra.length > 0) {
results.allowlist.push({
package: pkgName,
bucket,
extraDeps: extra,
remediation: `Add to .github/supply-chain/allowed-deps.json under "packages"."${pkgName}"."${bucket}" or remove from package.json`,
});
}
}
}
log(` [allowlist] checked ${Object.keys(allowlist.packages).length} packages`);
}
// ---------------------------------------------------------------------------
// 4. Typosquat reject — block known typosquat names
// ---------------------------------------------------------------------------
function runTyposquatAudit(allowlist) {
const banned = new Set(allowlist.policies?.rejectInRegistry ?? []);
if (banned.size === 0) return;
for (const packageDir of PACKAGES_TO_AUDIT) {
const pkgPath = join(REPO_ROOT, packageDir, 'package.json');
if (!existsSync(pkgPath)) continue;
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
for (const bucket of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {
for (const dep of Object.keys(pkg[bucket] ?? {})) {
if (banned.has(dep)) {
results.typosquat.push({
package: packageDir,
bucket,
depName: dep,
severity: 'critical',
reason: 'known typosquat — blocked by allowlist policy',
});
}
}
}
}
log(` [typosquat] checked ${PACKAGES_TO_AUDIT.length} packages against ${banned.size} blocked names`);
}
// ---------------------------------------------------------------------------
// 5. Publisher trust — log who currently owns each critical upstream
// ---------------------------------------------------------------------------
function runPublisherTrustAudit(allowlist) {
const critical = allowlist.publisherTrust?.criticalUpstreamPackages ?? [];
for (const name of critical) {
try {
// Use execFileSync + array args to prevent shell injection through
// package names sourced from the allowlist JSON (CWE-78 mitigation).
const out = execFileSync('npm', ['view', name, 'maintainers', '--json'], {
stdio: ['ignore', 'pipe', 'pipe'],
timeout: 10_000,
});
const maintainers = JSON.parse(out.toString());
const names = Array.isArray(maintainers)
? maintainers.map((m) => (typeof m === 'string' ? m : m.name ?? m.email ?? '?'))
: [];
results.publisherTrust.push({ package: name, maintainers: names });
log(` [publisher-trust] ${name}: ${names.join(', ') || '(none reported)'}`);
} catch (err) {
results.publisherTrust.push({
package: name,
warning: 'npm view failed: ' + (err.message ?? String(err)),
});
}
}
}
// ---------------------------------------------------------------------------
// Main
// ---------------------------------------------------------------------------
function main() {
log('=== ruflo supply-chain audit ===');
log(`scope: ${SCOPE}`);
const allowlist = loadAllowlist();
const accepted = loadAcceptedFindings();
log(`accepted-findings: ${accepted.cve.length} CVE, ${accepted.lockfile.length} lockfile`);
if (SCOPE === 'all' || SCOPE === 'cve') {
log('\n[1/5] CVE audit');
for (const p of PACKAGES_TO_AUDIT) runCveAudit(p, accepted);
}
if (SCOPE === 'all' || SCOPE === 'lockfile') {
log('\n[2/5] Lockfile integrity');
for (const p of PACKAGES_TO_AUDIT) runLockfileAudit(p, accepted);
}
if (SCOPE === 'all' || SCOPE === 'allowlist') {
log('\n[3/5] Top-level allowlist');
runAllowlistAudit(allowlist);
}
if (SCOPE === 'all' || SCOPE === 'typosquat') {
log('\n[4/5] Typosquat reject');
runTyposquatAudit(allowlist);
}
if (SCOPE === 'all' || SCOPE === 'publisher-trust') {
log('\n[5/5] Publisher trust snapshot');
runPublisherTrustAudit(allowlist);
}
// Anything in cve / lockfile / allowlist / typosquat is a hard fail.
// publisher-trust is informational (logs only).
const hardFails =
results.cve.length + results.lockfile.length + results.allowlist.length + results.typosquat.length;
if (JSON_OUTPUT) {
console.log(JSON.stringify(results, null, 2));
} else {
log('\n=== summary ===');
log(` CVE direct-dep findings: ${results.cve.length}`);
log(` lockfile integrity issues: ${results.lockfile.length}`);
log(` allowlist violations: ${results.allowlist.length}`);
log(` typosquat hits: ${results.typosquat.length}`);
log(` publisher-trust entries: ${results.publisherTrust.length}`);
if (hardFails > 0) {
log('\nFAIL: see above. Resolve before merging.');
} else {
log('\nOK: no hard-fail findings.');
}
}
process.exit(hardFails > 0 ? 1 : 0);
}
main();