fix(ci): keep scheduled provenance audits on the verified npm toolchain

This commit is contained in:
haelyra committed 2026-11-16 14:38:50 -05:00
1 parent f7aa27b657
commit f17308d50f
3 files changed
+47

No files matched your search

+9
View File
@@ -34,7 +34,16 @@ jobs:
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '20.x'
- name: Install pinned npm provenance verifier
env:
npm_config_cache: ${{ runner.temp }}/ecc-security-npm-cache
run: |
npm install --global npm@11.21.2 --ignore-scripts --no-audit --no-fund
test "$(npm --version)" = "11.21.2"
- name: Run security audit
env:
npm_config_cache: ${{ runner.temp }}/ecc-security-npm-cache
run: |
if [ -f package-lock.json ]; then
npm ci --ignore-scripts
+11
View File
@@ -29,10 +29,21 @@ jobs:
with:
node-version: '20.x'
- name: Install pinned npm provenance verifier
env:
npm_config_cache: ${{ runner.temp }}/ecc-security-npm-cache
run: |
npm install --global npm@11.21.2 --ignore-scripts --no-audit --no-fund
test "$(npm --version)" = "11.21.2"
- name: Install dependencies without lifecycle scripts
env:
npm_config_cache: ${{ runner.temp }}/ecc-security-npm-cache
run: npm ci --ignore-scripts
- name: Verify registry signatures and advisories
env:
npm_config_cache: ${{ runner.temp }}/ecc-security-npm-cache
run: |
npm audit signatures
npm audit --omit=dev --audit-level=high
@@ -6,6 +6,7 @@
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');
const WORKFLOW_PATH = path.join(
__dirname,
@@ -55,6 +56,32 @@ function run() {
assert.match(source, /npm audit --omit=dev --audit-level=high/);
})) passed++; else failed++;
// Keep a green PR audit from masking an outdated scheduled verifier.
if (test('every signature audit uses a pinned keyless-capable verifier first', () => {
let checked = 0;
for (const file of ['ci.yml', 'supply-chain-watch.yml', 'maintenance.yml']) {
const workflow = yaml.load(fs.readFileSync(path.join(path.dirname(WORKFLOW_PATH), file), 'utf8'),
{ schema: yaml.CORE_SCHEMA });
for (const [name, job] of Object.entries(workflow.jobs)) {
const steps = job.steps || [];
const audit = steps.findIndex(step => /^\s*npm audit signatures\s*$/m.test(step.run || ''));
if (audit < 0) continue;
const verifier = steps.slice(0, audit).find(step => /npm install --global npm@/.test(step.run || ''));
const label = file + ':' + name;
assert.ok(verifier, label + ' audits without its pinned verifier');
const version = /npm install --global npm@(\d+\.\d+\.\d+)\b/.exec(verifier.run)?.[1];
assert.ok(version, label + ' must pin an exact verifier version');
const [major, minor, patch] = version.split('.').map(Number);
assert.ok(major > 11 || (major === 11 && (minor > 21 || (minor === 21 && patch >= 2))),
label + ' verifier predates the keyless-attestation fix');
assert.match(verifier.run, /--ignore-scripts\b/);
assert.ok(verifier.run.includes('test "$(npm --version)" = "' + version + '"'));
checked++;
}
}
assert.ok(checked >= 3, 'PR, scheduled watch, and maintenance audit jobs must be covered');
})) passed++; else failed++;
if (test('runs IOC fixtures, emits JSON report, and uploads the artifact', () => {
assert.match(source, /node tests\/ci\/scan-supply-chain-iocs\.test\.js/);
assert.match(source, /node scripts\/ci\/scan-supply-chain-iocs\.js --json > artifacts\/supply-chain-ioc-report\.json/);