diff --git a/.github/workflows/privacy-guard.yml b/.github/workflows/privacy-guard.yml new file mode 100644 index 0000000..a1de8a2 --- /dev/null +++ b/.github/workflows/privacy-guard.yml @@ -0,0 +1,42 @@ +name: Privacy Guard + +on: + push: + pull_request: + +permissions: + contents: read + +concurrency: + group: privacy-guard-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + privacy-guard: + name: Privacy Guard + runs-on: ubuntu-latest + env: + GITLEAKS_VERSION: "8.30.1" + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + with: + fetch-depth: 0 + persist-credentials: false + - name: Install gitleaks + run: | + set -euo pipefail + base="https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}" + archive="gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" + curl -sSfL -o "$RUNNER_TEMP/$archive" "$base/$archive" + curl -sSfL -o "$RUNNER_TEMP/checksums.txt" "$base/gitleaks_${GITLEAKS_VERSION}_checksums.txt" + (cd "$RUNNER_TEMP" && grep " ${archive}\$" checksums.txt | sha256sum -c -) + tar -xzf "$RUNNER_TEMP/$archive" -C "$RUNNER_TEMP" gitleaks + echo "$RUNNER_TEMP" >> "$GITHUB_PATH" + - name: Scan history for secrets + run: gitleaks detect --source . --log-opts=--all --redact --no-banner --exit-code 1 + - name: Test denylist guard + run: bash scripts/test-privacy-denylist.sh + - name: Check denylist + env: + PRIVACY_DENYLIST_EXTRA: ${{ secrets.PRIVACY_DENYLIST_EXTRA }} + run: bash scripts/privacy-denylist.sh diff --git a/.gitignore b/.gitignore index a4eaa34..f9e6277 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ __pycache__/ *.pyc .vstack-stage-*/ .DS_Store +.privacy-denylist.local diff --git a/.privacy-allowlist b/.privacy-allowlist new file mode 100644 index 0000000..c65f78f --- /dev/null +++ b/.privacy-allowlist @@ -0,0 +1,14 @@ +# Regexes matched against "path:line:token" of each denylist hit. Keep entries narrow +# and anchor them: a token is allowed only if the whole token matches. + +# Addresses on reserved or noreply domains, and the SSH remote user +:[0-9]+:[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+\.(test|invalid|example)$ +:[0-9]+:[A-Za-z0-9._%+-]+@example\.(com|org|net)$ +:[0-9]+:[A-Za-z0-9._%+-]+@users\.noreply\.github\.com$ +:[0-9]+:git@github\.com$ + +# CI runner home directories +:[0-9]+:.?/home/(runner|user)$ + +# Generic copywriting example, not a real figure +^(plugins/[a-z]+/skills/)?(workflows/)?build-landing-page/references/copywriting-formulas\.md:[0-9]+:\$10k MRR$ diff --git a/.privacy-denylist b/.privacy-denylist new file mode 100644 index 0000000..88e5608 --- /dev/null +++ b/.privacy-denylist @@ -0,0 +1,37 @@ +# Structural privacy patterns (extended regex, case-insensitive). Generic only: +# never put names, clients, hosts, or credentials here; this file is public. +# Private terms go in the untracked .privacy-denylist.local or the +# PRIVACY_DENYLIST_EXTRA CI secret. See scripts/privacy-denylist.sh. + +# Tailnet hostnames and addresses (CGNAT range, IPv6 ULA) +[a-z0-9-]+\.ts\.net\b +\b100\.(6[4-9]|[7-9][0-9]|1[01][0-9]|12[0-7])\.[0-9]{1,3}\.[0-9]{1,3}\b +\bfd7a:115c:a1e0:[0-9a-f:]+ + +# Private network addresses +\b10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\b +\b192\.168\.[0-9]{1,3}\.[0-9]{1,3}\b +\b172\.(1[6-9]|2[0-9]|3[01])\.[0-9]{1,3}\.[0-9]{1,3}\b + +# Machine-specific home and editor store paths (a path root, not a URL segment) +(^|[^A-Za-z0-9_./-])/(home|Users)/[A-Za-z0-9._-]+ +[A-Za-z]:\\Users\\[A-Za-z0-9._-]+ +/cursor/stores + +# UUIDs (account, bot, and device ids) +\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b + +# Email addresses; a version suffix such as pkg@1.2.3-canary.abc1234 is not one +[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}\b + +# Phone numbers: international, US-style grouped, French-style grouped, 00-prefixed +(^|[^0-9A-Za-z])\+[0-9]{1,3}[ .-]?[0-9]([ .-]?[0-9]){7,12}\b +\(?[0-9]{3}\)?[ .-][0-9]{3}[ .-][0-9]{4}\b +\b0[1-9]([ .-][0-9]{2}){4}\b +\b00[0-9]{10,13}\b + +# Revenue and pricing figures +\bMRR\b[^.]{0,20}[0-9] +\b(revenue|turnover|pricing)\b[^.]{0,24}[$€£][0-9] +[$€£][0-9][0-9,.]*[kKmM]?[ ]?(MRR|ARR)\b +\b[0-9][0-9,.]*[kKmM]?[ ]?(€|EUR\b|USD\b) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ee3901..3d32859 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Add a `Privacy Guard` workflow: gitleaks over full history plus a structural denylist check with an allowlist, optional private patterns, and withheld match content. + ## 0.1.0-canary.6 - Fix the Claude plugin icon being rejected as `ICON_INVALID`: ship the vllnt logo as `.claude-plugin/icon.png`, named by `icon` in `plugin.json`, instead of an SVG that embedded the PNG. diff --git a/README.md b/README.md index 0195ae8..55a5d18 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,8 @@ python3 scripts/sync.py --source /path/to/skills python3 scripts/sync.py --check --source /path/to/skills ``` +The `Privacy Guard` workflow also runs gitleaks over full history and `scripts/privacy-denylist.sh`, which checks tracked files against the structural patterns in `.privacy-denylist` minus the narrow `.privacy-allowlist`. Matches report `path:line` only. Run it locally with `bash scripts/privacy-denylist.sh`; `scripts/test-privacy-denylist.sh` covers its failure paths. Names that must stay private go in an untracked `.privacy-denylist.local` or the optional `PRIVACY_DENYLIST_EXTRA` repository secret, never in the tracked file. + `--source` reads committed objects at the lock's SHA, ignoring working-tree edits. `--check` rebuilds expected bytes in memory and reports missing, stale, extra, or changed generated files without writing outputs. Its default path downloads the pin; network/access failures are failures, never a successful empty result. The generator accepts only regular archive files/directories, validates skill identities and local dependency links, and bounds archive bytes, expanded bytes, file size, member count, and total payload. It rejects symlink output paths before writing. It stages output and replaces only the three generated host directories and three catalog files, rolling back ordinary replacement errors. Run only one writer at a time in a trusted checkout: this is not a filesystem sandbox or a crash-proof transaction across all targets. diff --git a/scripts/privacy-denylist.sh b/scripts/privacy-denylist.sh new file mode 100755 index 0000000..d9d2e5d --- /dev/null +++ b/scripts/privacy-denylist.sh @@ -0,0 +1,117 @@ +#!/usr/bin/env bash +# +# privacy-denylist.sh — fail when a tracked file matches a denylist pattern +# outside the allowlist. +# +# Patterns (extended regex, one per line, '#' comments; matched case-insensitively): +# .privacy-denylist required, tracked, structural patterns only +# .privacy-denylist.local optional, untracked, for names that must stay private +# $PRIVACY_DENYLIST_EXTRA optional, newline-separated; set it from a CI secret +# Allowlist (.privacy-allowlist): regexes matched against "path:line:token" for each +# matched token, so an allowed token never hides another match on the same line. +# +# Matched content and pattern text are never printed: CI logs of a public +# repository are public. +# +# Limits: only tracked files at the checked-out revision are scanned, not the +# commits of a pull request (gitleaks covers secret-shaped data in all history). +# UTF-16 text is not matched, and the allowlist file itself is not scanned. +# +# Exit codes: 0 clean, 1 match found, 2 misuse or invalid pattern. + +set -u + +cd "$(git rev-parse --show-toplevel)" || exit 2 + +DENY=.privacy-denylist +ALLOW=.privacy-allowlist +SELF=scripts/privacy-denylist.sh + +tracked="$(mktemp)" +extra="$(mktemp)" +patterns="$(mktemp)" +allow_patterns="$(mktemp)" +hits="$(mktemp)" +kept="$(mktemp)" +trap 'rm -f "$tracked" "$extra" "$patterns" "$allow_patterns" "$hits" "$kept"' EXIT + +strip() { sed -E '/^[[:space:]]*(#|$)/d'; } +# lines : the file with a guaranteed final newline. +lines() { cat "$1"; printf '\n'; } + +# valid_regexes