Sentinel · security scanner
static-link-sentinel
Fail CI on broken links before you deploy.
npm i -D static-link-sentinelWhat it checks
broken-linkLink (a,area, canonical/alternate) to a path with no filemissing-assetScript, stylesheet, image, media, iframe, icon, manifest icon or CSSurl()missingcase-mismatch/img/Logo.pngvsimg/logo.png: works on macOS, 404s on Linux/CDNsbase-pathRoot-relative link escapes the configuredbasePathmixed-contenthttp://asset on an https sitesitemap-url<loc>with no matching pagerobots-sitemaprobots.txtpoints at a sitemap that isn't builtinvalid-urlUnparseable URL
Quick usage
CLI
npm run build
npx static-link-sentinel # auto-detects dist/ build/ out/ public/ _site/
npx static-link-sentinel dist --external --site-url https://example.com
API
import { check, shouldFail, pretty, toMarkdown, toSarif } from 'static-link-sentinel';
const report = await check({ dir: 'dist', siteUrl: 'https://example.com', external: true });
console.log(pretty(report));
for (const f of report.findings) console.log(f.severity, f.ruleId, `${f.file}:${f.line}`, f.url, f.fix);
if (shouldFail(report, 'error')) process.exit(1);
Every option is documented in the static-link-sentinel docs.
CI / GitHub Action
name: Links
on: [push, pull_request]
jobs:
links:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20 }
- run: npm ci && npm run build
- uses: MrLouisWright/static-link-sentinel@v1
with:
dir: dist
site-url: https://example.com
external: ${{ github.event_name == 'push' }}
fail-on: error
sarif: links.sarif
- if: always()
uses: github/codeql-action/upload-sarif@v3
with: { sarif_file: links.sarif }