CI / Lint (eslint) (pull_request) Successful in 20s
CI / Test (jest) (pull_request) Successful in 25s
CI / Security (npm audit) (pull_request) Successful in 52s
CI / Test (Node 22) (pull_request) Successful in 1m37s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 2m21s
CI / Integration (api) (pull_request) Successful in 3m17s
CI / UI screenshots (before/after) (pull_request) Successful in 12s
CI / UI (playwright) (pull_request) Successful in 2m41s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
- Test (Node 22): the unit tests on node:22-bookworm (pinned by digest), as a separate job so the required "Test (jest)" context is unchanged. Not required and not a deploy prerequisite: a heads-up before production moves to Node 22. - Security job: npm ci --ignore-scripts, then `npm audit signatures` (every installed package's registry signature and attestations) and scripts/ci/licenses.js, which fails when a production dependency's licence is not on the allowlist (MIT, ISC, BSD-2/3, Apache-2.0, 0BSD, BlueOak-1.0.0, CC0-1.0, Unlicense, Python-2.0). Licences missing from the lockfile are read from the installed package.json. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
52 lines
2.0 KiB
JavaScript
Executable File
52 lines
2.0 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
'use strict';
|
|
|
|
// Licence review for production dependencies (#45): every package that ships with Pulse
|
|
// must use a licence on the allowlist. Run after `npm ci`. The lockfile records most
|
|
// licences; for the rest, the installed package's own package.json is read.
|
|
// An SPDX "A OR B" passes when either side is allowed; "A AND B" needs both.
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const ALLOWED = new Set([
|
|
'MIT', 'ISC', 'BSD-2-Clause', 'BSD-3-Clause', 'Apache-2.0', '0BSD',
|
|
'BlueOak-1.0.0', 'CC0-1.0', 'Unlicense', 'Python-2.0',
|
|
]);
|
|
|
|
const root = path.join(__dirname, '..', '..');
|
|
const lock = JSON.parse(fs.readFileSync(path.join(root, 'package-lock.json'), 'utf8'));
|
|
|
|
function licenceOf(key, entry) {
|
|
if (entry.license) return entry.license;
|
|
try {
|
|
const pkg = JSON.parse(fs.readFileSync(path.join(root, key, 'package.json'), 'utf8'));
|
|
if (typeof pkg.license === 'string') return pkg.license;
|
|
if (pkg.license && pkg.license.type) return pkg.license.type;
|
|
if (Array.isArray(pkg.licenses)) return pkg.licenses.map(l => l.type || l).join(' OR ');
|
|
} catch (e) { /* not installed or unreadable: reported below */ }
|
|
return null;
|
|
}
|
|
|
|
function allowed(expr) {
|
|
const clean = expr.replace(/[()]/g, ' ').trim();
|
|
return clean.split(/\s+OR\s+/).some(alt => alt.split(/\s+AND\s+/).every(id => ALLOWED.has(id.trim())));
|
|
}
|
|
|
|
const problems = [];
|
|
let checked = 0;
|
|
for (const [key, entry] of Object.entries(lock.packages || {})) {
|
|
if (!key || entry.dev || entry.link) continue; // the root, dev-only and workspace links
|
|
checked++;
|
|
const lic = licenceOf(key, entry);
|
|
if (!lic) problems.push(`${key}: no licence found`);
|
|
else if (!allowed(lic)) problems.push(`${key}: ${lic}`);
|
|
}
|
|
|
|
if (problems.length) {
|
|
console.error(`Licences not on the allowlist (${[...ALLOWED].join(', ')}):`);
|
|
for (const p of problems) console.error(' ' + p);
|
|
process.exit(1);
|
|
}
|
|
console.log(`${checked} production packages, all with allowed licences.`);
|