Sentinel · security scanner
sri-sentinel
Subresource Integrity for your built site: generate, write and check it in CI.
npm i -D sri-sentinelWhat it checks
integrity-mismatchThe integrity value doesn't match the file: wrong, or stale after a rebuildmissing-integrityA script, stylesheet, modulepreload, or import map entry with no integrityinvalid-integrityMalformed value, wrong digest length or unsupported algorithm (sha1-,md5-)missing-crossoriginCross-origin resource withintegritybut nocrossorigin. The browser will block itunresolved-resourceLocal file not found or outside the site root, so it can't be hashedfetch-failed--remotecouldn't download the resource (HTTP error, timeout)weak-algorithmValid hash, but weaker than the configured algorithm (e.g. sha256 when sha384 is set)remote-unverifiedRemote resource has integrity, but you didn't pass--remote, so it wasn't verified
Quick usage
CLI
npx sri-sentinel dist --write # add integrity attributes to dist/**/*.html
npx sri-sentinel dist --check # CI: fail on missing, wrong or stale integrity
npx sri-sentinel dist --write --remote # also fetch and hash CDN resources
npx sri-sentinel dist --manifest sri.json # JSON manifest of resource -> integrity
API
import { scan, computeIntegrity, verifyIntegrity, formatSarif, exitCode } from 'sri-sentinel';
Every option is documented in the sri-sentinel docs.
CI / GitHub Action
- uses: MrLouisWright/sri-sentinel@v1
with:
paths: dist
mode: check # or write
remote: 'true'
fail-on: high
sarif: sri.sarif