policy-drift-warden

Warden · privacy & compliance

policy-drift-warden

Compare the trackers and third parties your built site actually loads with what its privacy policy says, and fail CI when they drift apart.

npm i -D @mrlouiswright/policy-drift-warden

Published to GitHub Packages: add @mrlouiswright:registry=https://npm.pkg.github.com to .npmrc first (installing needs a token with read:packages).

What it checks

  • Vendor disclosureeach loaded vendor must be named in the policy by name, company alias ("Facebook" for Meta Pixel) or domain. Unknown third-party domains must be named too.
  • Category disclosureadvertising, session recording/heatmaps, analytics and social plugins must be described.
  • Sale/sharingif vendors that sell or share data for advertising are present, the policy must mention selling, sharing or targeted advertising.
  • Stale disclosurestracking vendors named in the policy that the site no longer loads.
  • Freshness"Last updated" / effective date present (ISO, 3 March 2025, January 5, 2024, 01.02.2023) and not older than --max-age-days (365).
  • Reachabilityevery page links to the policy.

Quick usage

CLI

npx policy-drift-warden dist
npx policy-drift-warden dist --policy legal/privacy.md --fail-on medium
npx policy-drift-warden public --trackers-only --max-age-days 180
npx policy-drift-warden out --policy-pages "/legal/privacy/**" --format sarif > policy.sarif

API

import { check, policyDate } from "policy-drift-warden";
const report = check("dist", { policyFile: "legal/privacy.md" });
console.log(report.info.policy, report.findings);

Every option is documented in the policy-drift-warden docs.

CI / GitHub Action

permissions:
  contents: read
  security-events: write   # only needed for the SARIF upload
jobs:
  policy-drift-warden:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
        with: { persist-credentials: false }
      - run: npm ci && npm run build   # produce the static site first
      - uses: MrLouisWright/policy-drift-warden@v1
        with:
          path: dist
          fail-on: high
          sarif: policy-drift-warden.sarif
      - uses: github/codeql-action/upload-sarif@v3
        if: always()
        with: { sarif_file: policy-drift-warden.sarif }