pii-log-warden

Warden · privacy & compliance

pii-log-warden

Find and redact personal data in log files: emails, phone numbers, IP addresses, card numbers and national IDs.

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

  • Detectorsemail addresses, phone numbers (E.164, UK, North American), public IPv4/IPv6 addresses, payment card numbers (Luhn-checked, issuer prefixes), US SSNs, UK National Insurance numbers, IBANs (mod-97 checked)…
  • Low noiseprivate and loopback IPs, example.com, masked values (`, [REDACTED]), version strings, timestamps and UUIDs are ignored; add your own service domains with --ignore-email-domains`.
  • Inputsfiles, directories (log-like files by default: *.log, rotated *.log.1, *.txt, *.jsonl, *.json, *.csv, *.out, *.err), or - for stdin (e.g. kubectl logs … | pii-log-warden -). Binary files are skipped.
  • Redaction--redact rewrites files with [REDACTED:email] placeholders (or --mask for j*@acme.io), --redact-dir writes clean copies instead.

Quick usage

CLI

npx pii-log-warden logs/
npx pii-log-warden app.log --fail-on medium
kubectl logs deploy/api | npx pii-log-warden - --format json
npx pii-log-warden logs/ --redact-dir logs-clean --mask

API

import { scanText, redactText, check } from "pii-log-warden";
scanText("login jane@acme.io from 81.2.69.142"); // [{ rule, line, column, value, masked }]
redactText(line).text; // "login [REDACTED:email] from [REDACTED:ip-address]"
const report = check(["logs"]);

Every option is documented in the pii-log-warden docs.

CI / GitHub Action

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