Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/privacy-guard.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ __pycache__/
*.pyc
.vstack-stage-*/
.DS_Store
.privacy-denylist.local
14 changes: 14 additions & 0 deletions .privacy-allowlist
Original file line number Diff line number Diff line change
@@ -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$
37 changes: 37 additions & 0 deletions .privacy-denylist
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
117 changes: 117 additions & 0 deletions scripts/privacy-denylist.sh
Original file line number Diff line number Diff line change
@@ -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 <file>: the file with a guaranteed final newline.
lines() { cat "$1"; printf '\n'; }

# valid_regexes <file> <label>: every line must compile and must not match the empty string.
valid_regexes() {
local file="$1" label="$2" n=0 line status probe
while IFS= read -r line || [[ -n "$line" ]]; do
n=$((n + 1))
printf '\n' | grep -qE -e "$line" 2> /dev/null
status=$?
if (( status > 1 )); then
echo "error: $label pattern #$n is not a valid regex" >&2
return 1
fi
if (( status == 0 )); then
echo "error: $label pattern #$n matches the empty string" >&2
return 1
fi
# Zero-width patterns (\b, ^, $) match inside real text but report nothing.
probe="$(printf 'a b\n' | grep -oE -e "$line" 2> /dev/null)"
if [[ -z "$probe" ]] && printf 'a b\n' | grep -qE -e "$line" 2> /dev/null; then
echo "error: $label pattern #$n is zero-width" >&2
return 1
fi
done < "$file"
}

if [[ ! -f "$DENY" ]]; then
echo "error: $DENY is required" >&2
exit 2
fi
lines "$DENY" | strip > "$tracked"
{
[[ -f "$DENY.local" ]] && lines "$DENY.local"
[[ -n "${PRIVACY_DENYLIST_EXTRA:-}" ]] && printf '%s\n' "$PRIVACY_DENYLIST_EXTRA"
} | strip > "$extra"
cat "$tracked" "$extra" > "$patterns"
[[ -f "$ALLOW" ]] && lines "$ALLOW" | strip > "$allow_patterns"

if [[ ! -s "$tracked" ]]; then
echo "error: $DENY has no patterns" >&2
exit 2
fi
valid_regexes "$patterns" "denylist" || exit 2
valid_regexes "$allow_patterns" "allowlist" || exit 2
if [[ -s "$allow_patterns" ]] && [[ -z "$(printf '%s\n' 'zz/canary.md:1:canary.ts''.net' | grep -avEf "$allow_patterns")" ]]; then
echo "error: allowlist is too broad; it would hide an obvious match" >&2
exit 2
fi

# -a scans binary files as text; -o reports each matched token on its own line.
git grep -naoiE -f "$patterns" -- . ":(exclude)$DENY" ":(exclude)$ALLOW" ":(exclude)$SELF" > "$hits" 2> /dev/null
status=$?
if (( status > 1 )); then
echo "error: git grep failed" >&2
exit 2
fi

if [[ -s "$allow_patterns" ]]; then
grep -avEf "$allow_patterns" "$hits" > "$kept"
status=$?
if (( status > 1 )); then
echo "error: allowlist filtering failed" >&2
exit 2
fi
mv "$kept" "$hits"
fi

if [[ -s "$hits" ]]; then
echo "FAIL privacy denylist: $(wc -l < "$hits" | tr -d ' ') match(es); content withheld"
cut -d: -f1,2 "$hits" | sort -u | sed 's/^/ /'
exit 1
fi

extra_count="$(wc -l < "$extra" | tr -d ' ')"
if [[ "${CI:-}" == "true" && "$extra_count" == "0" ]]; then
echo "::warning title=Privacy guard::No private patterns loaded; only the tracked structural patterns were checked."
fi
echo "OK privacy denylist: no matches ($(wc -l < "$tracked" | tr -d ' ') tracked + $extra_count private patterns)"
143 changes: 143 additions & 0 deletions scripts/test-privacy-denylist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#!/usr/bin/env bash
#
# test-privacy-denylist.sh — success and failure paths of privacy-denylist.sh
# in a throwaway repository. Fixtures are assembled from fragments (adjacent
# quoted strings) so this file never matches the denylist itself.

set -u

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
REPO="$(mktemp -d)"
trap 'rm -rf "$REPO"' EXIT

mkdir -p "$REPO/scripts"
cp "$ROOT/scripts/privacy-denylist.sh" "$REPO/scripts/"
cp "$ROOT/.privacy-denylist" "$ROOT/.privacy-allowlist" "$REPO/"
git -C "$REPO" init -q
git -C "$REPO" config user.email test@example.invalid
git -C "$REPO" config user.name test

failures=0
LAST_OUTPUT=""

# plant <text>: write a one-line fixture.
plant() { printf '%s\n' "$1" > "$REPO/doc.md"; }

# check <name> <expected exit> [VAR=value ...]
check() {
local name="$1" expected="$2"; shift 2
git -C "$REPO" add -A
local status
LAST_OUTPUT="$(cd "$REPO" && env "$@" bash scripts/privacy-denylist.sh 2>&1)"
status=$?
if [[ "$status" != "$expected" ]]; then
printf 'FAIL %s: expected exit %s, got %s\n%s\n' "$name" "$expected" "$status" "$LAST_OUTPUT" >&2
failures=$((failures + 1))
return
fi
printf 'OK %s\n' "$name"
}

# refute <name> <text>: the last output must not contain the text.
refute() {
if grep -qF -- "$2" <<< "$LAST_OUTPUT"; then
printf 'FAIL %s\n' "$1" >&2
failures=$((failures + 1))
fi
}

TAILNET="box.example-net.ts"".net"

plant "Plain documentation."
check "clean tree passes" 0 NOOP=1

plant "host: $TAILNET"
check "tailnet hostname fails" 1 NOOP=1
grep -q 'doc.md:1' <<< "$LAST_OUTPUT" || { echo "FAIL hit location not reported" >&2; failures=$((failures + 1)); }
refute "matched content leaked to output" "example-net"

plant "id 123e4567-e89b-12d3-a456-4266""14174000"
check "uuid fails" 1 NOOP=1

plant "path /ho""me/someone/project/"
check "home path fails" 1 NOOP=1
plant "HOME=/ho""me/someone"
check "home path without trailing slash fails" 1 NOOP=1
plant "GET /api/us""ers/123/posts"
check "url route segment passes" 0 NOOP=1
plant "cwd /ho""me/runner/work/x"
check "allowlisted runner home passes" 0 NOOP=1

plant "mail fixture@example.test"
check "reserved-domain address passes" 0 NOOP=1
plant "mail someone@""company.io"
check "real-looking address fails" 1 NOOP=1
plant "mail fixture@acme.test"".com"
check "reserved label inside a real domain fails" 1 NOOP=1
plant "git clone git@github.com:owner/repo.git"
check "ssh remote user passes" 0 NOOP=1
plant "pnpm add @scope/pkg@0.1.0-canary.bca5ab7"
check "package version pin passes" 0 NOOP=1

plant "call 415-555-""0132"
check "grouped phone number fails" 1 NOOP=1
plant "MR""R is 12k"
check "bare revenue figure fails" 1 NOOP=1

plant "ssh admin@example.com $TAILNET"
check "allowed token does not hide another match on the line" 1 NOOP=1

printf '\0host %s\n' "$TAILNET" > "$REPO/doc.md"
check "binary file is scanned" 1 NOOP=1
rm -f "$REPO/doc.md"
plant "Plain documentation."

printf 'acme-widget appears here\n' >> "$REPO/doc.md"
check "extra pattern from environment fails" 1 'PRIVACY_DENYLIST_EXTRA=acme-widget'
check "extra pattern is not echoed" 1 'PRIVACY_DENYLIST_EXTRA=acme-widget'
refute "extra pattern text leaked to output" "acme-widget"
plant "Plain documentation."
check "extra pattern not present passes" 0 'PRIVACY_DENYLIST_EXTRA=acme-widget'
check "missing private patterns warn under CI" 0 CI=true
grep -q '::warning' <<< "$LAST_OUTPUT" || { echo "FAIL no warning when private patterns are absent in CI" >&2; failures=$((failures + 1)); }

check "invalid private pattern is an error" 2 'PRIVACY_DENYLIST_EXTRA=Acme[Corp'
refute "invalid pattern text leaked to output" "Acme"
check "private pattern matching empty string is an error" 2 'PRIVACY_DENYLIST_EXTRA=acme|'

cp "$REPO/.privacy-allowlist" "$REPO/allow.bak"
plant "host: $TAILNET"
printf '[unclosed\n' > "$REPO/.privacy-allowlist"
check "invalid allowlist regex is an error, not a pass" 2 NOOP=1
printf 'zzz|\n' > "$REPO/.privacy-allowlist"
check "allowlist matching empty string is an error, not a pass" 2 NOOP=1
cp "$REPO/allow.bak" "$REPO/.privacy-allowlist"

plant "host: $TAILNET"
printf '.*' > "$REPO/.privacy-allowlist"
check "unterminated last allowlist line is still validated" 2 NOOP=1
printf '^.+$\n' > "$REPO/.privacy-allowlist"
check "over-broad allowlist entry is an error, not a pass" 2 NOOP=1
mv "$REPO/allow.bak" "$REPO/.privacy-allowlist"

check "zero-width private pattern is an error" 2 'PRIVACY_DENYLIST_EXTRA=\b'
printf '\\b' > "$REPO/.privacy-denylist.local"
check "unterminated zero-width local pattern is an error" 2 NOOP=1
rm "$REPO/.privacy-denylist.local"

printf '\0/ho''me/someone\n' > "$REPO/doc.md"
check "nul-delimited token is not dropped by the allowlist filter" 1 NOOP=1

printf 'acme' > "$REPO/.privacy-denylist.local"
plant "only foo here"
check "local file and secret patterns stay separate" 1 PRIVACY_DENYLIST_EXTRA=foo
rm "$REPO/.privacy-denylist.local"

rm "$REPO/.privacy-denylist"
check "missing denylist file is an error" 2 NOOP=1

if (( failures > 0 )); then
printf '%s failure(s)\n' "$failures" >&2
exit 1
fi
echo "OK privacy denylist tests passed"
Loading