Sentinel · security scanner
license-sentinel
A license compliance gate for npm projects, plus CycloneDX/SPDX SBOMs and a NOTICES file.
npm i -D license-sentinelWhat it checks
- Dependency sources
node_modules(npm, yarn and pnpm.pnpmlayouts, nested and scoped packages, symlinks),package-lock.json/npm-shrinkwrap.json(v1–v3),pnpm-lock.yaml(v5, v6 and v9) andyarn.lock(v1 and Berry)… - License resolutionreads
license, legacylicense: {type}andlicenses: [...],SEE LICENSE IN <file>and lockfile license fields. When there is no usable field, it identifies the LICENSE/COPYING text: MIT, MIT-0, ISC, 0BSD, BSD-2/3/4-Clause… - SPDX expressions
AND,OR,WITHand parentheses, withORchoosing any allowed option (the least restrictive). Deprecated ids (GPL-2.0+,GPL-3.0) and common non-SPDX spellings (Apache 2.0,MIT/Apache-2.0… - Policyallow and deny lists (SPDX ids, globs like
GPL-*, or categories likecategory:permissive), the presetspermissive,weak-copyleftandstrong-copyleft, and a category check against the project's own license… - Monorepos
--workspacesruns a separate audit per workspace package (npmworkspaces,pnpm-workspace.yaml);--workspace-report-dirwrites one JSON file per package. Hoisted installs at the repo root are supported. - Outputtext, JSON, SARIF 2.1.0 and Markdown reports; CycloneDX 1.6 JSON and SPDX 2.3 JSON SBOMs; CSV inventory; HTML and Markdown attribution pages; custom
--templatefiles; third-party NOTICES.--fail-onand exit codes 0/1/2.
Quick usage
CLI
npx license-sentinel # audit the current project (production deps)
npx license-sentinel --preset permissive --fail-on medium
npx license-sentinel --deny "GPL-*,AGPL-*,SSPL-1.0" --include-dev
npx license-sentinel --source lockfile --registry # no node_modules: use the lockfile + npm registry
npx license-sentinel --cyclonedx bom.cdx.json --spdx bom.spdx.json --notices THIRD_PARTY_NOTICES.txt
npx license-sentinel --omit=dev --csv licenses.csv --html attribution.html
npx license-sentinel --workspaces --workspace-report-dir reports/
API
import { audit, auditAsync, auditWorkspaces, toCycloneDX, toSPDX, toNotices, formatText, parseSpdx } from 'license-sentinel';
const { audit: auditCjs } = require('license-sentinel'); // dist/index.cjs after npm install
const report = audit('.', { preset: 'permissive', deny: ['AGPL-*'] });
console.log(formatText(report, { failOn: 'high' }));
fs.writeFileSync('bom.cdx.json', toCycloneDX(report));
const mono = auditWorkspaces('.', { includeDev: false });
const lockOnly = await auditAsync('.', { source: 'lockfile', registry: true });
Every option is documented in the license-sentinel docs.
CI / GitHub Action
permissions:
contents: read
jobs:
licenses:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@<sha> # v4
with: { persist-credentials: false }
- run: npm ci --ignore-scripts
- uses: MrLouisWright/license-sentinel@<sha> # v1
with:
preset: permissive
deny: 'AGPL-*,SSPL-1.0'
fail-on: medium
cyclonedx: bom.cdx.json
notices: THIRD_PARTY_NOTICES.txt