retention-warden

Warden · privacy & compliance

retention-warden

Lint your data-retention policy as code: every data category gets a period, a legal basis and an action at expiry.

npm i -D @mrlouiswright/retention-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

  • Coverageevery category held in a system needs a rule (category-wide or system-specific); undeclared categories and systems are reported; unused categories are noted.
  • PeriodsISO 8601 (P30D, P6M, P2Y) or plain words (90 days, 6 years); invalid periods, missing periods and indefinite retention of personal data (without justification) are high severity.
  • Limitsdefaults.maxPeriod and defaults.specialMaxPeriod (for special: true categories such as health data).
  • Consistencyconflicting rules for the same category and system, and exact duplicates.
  • Accountabilitylegal basis, action at expiry (delete, anonymise, archive, review, ...), trigger (when the clock starts), owner, and a reviewed date checked against reviewEveryMonths (default 12).
  • Precise locationsfindings carry the line in your YAML file, so SARIF annotations land on the right rule.

Quick usage

CLI

npx retention-warden
npx retention-warden policies/retention.yml --fail-on medium
npx retention-warden . --max-period P7Y --special-max-period P1Y
npx retention-warden --format sarif > retention.sarif

API

import { check, lintPolicy, parsePeriod } from "retention-warden";
parsePeriod("P2Y"); // { days: 730.5 }
const report = check("retention.yml");
console.log(report.counts, report.findings);

Every option is documented in the retention-warden docs.

CI / GitHub Action

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