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
86 changes: 86 additions & 0 deletions .github/workflows/privacy-guard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Privacy Guard for a public fork of an upstream we do not control.
# Required status check name: "Privacy Guard".
#
# Copied from vllnt/skills references/capabilities/release-readiness/templates/privacy-guard.yml
# and scoped: full-history gitleaks and the working-tree denylist fail on
# upstream fixtures and test data (they are not in our control). This job
# still runs the template's tests, gitleaks over the new-commit range, and
# check-commit-emails.sh over the new-commit range (PR or pushed range).
# Do not print secret or personal values in logs.

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@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: Resolve new-commit range
id: range
env:
EVENT_NAME: ${{ github.event_name }}
PR_BASE: ${{ github.event.pull_request.base.sha }}
PR_HEAD: ${{ github.event.pull_request.head.sha }}
BEFORE: ${{ github.event.before }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
run: |
set -euo pipefail
# This repo is a public fork. The template default of --all on the
# default branch would scan upstream history we do not control.
# Never use a bare HEAD for gitleaks --log-opts: `git log HEAD`
# walks every reachable commit.
if [[ "$EVENT_NAME" == "pull_request" ]]; then
RANGE="${PR_BASE}..${PR_HEAD}"
elif [[ "${BEFORE:-}" != "" && "$BEFORE" != 0000000000000000000000000000000000000000 ]]; then
RANGE="${BEFORE}..HEAD"
else
RANGE="origin/${DEFAULT_BRANCH}..HEAD"
fi
echo "range=$RANGE" >> "$GITHUB_OUTPUT"
echo "Using commit range $RANGE"
- name: Scan new commits for secrets
run: |
set -euo pipefail
range="${{ steps.range.outputs.range }}"
if [[ "$range" == "HEAD" ]]; then
git rev-list -n 1 HEAD >/dev/null
elif ! git rev-list "$range" | grep -q .; then
echo "No new commits in range; skipping gitleaks"
exit 0
fi
gitleaks detect --source . --log-opts="$range" --redact --no-banner --exit-code 1
- name: Test denylist guard
run: bash scripts/test-privacy-denylist.sh
- name: Test commit-metadata email check
run: bash scripts/test-check-commit-emails.sh
- name: Check commit emails and trailers
env:
PRIVACY_COMMIT_RANGE: ${{ steps.range.outputs.range }}
run: bash scripts/check-commit-emails.sh
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ docker-compose.override.yml

# Local LLM Wiki vault
.llm-wiki

# Private privacy-guard patterns (never commit)
.privacy-denylist.local
15 changes: 15 additions & 0 deletions .privacy-allowlist
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 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]+: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$
42 changes: 42 additions & 0 deletions .privacy-denylist
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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:]+

# Provider-assigned VPS hostnames (not the vendor name itself)
[a-z0-9-]+\.vps\.ovh\.(net|ca)\b
[a-z0-9.-]+\.your-server\.de\b
[a-z0-9-]+\.hetzner\.cloud\b

# 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)
187 changes: 187 additions & 0 deletions scripts/check-commit-emails.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
#!/usr/bin/env bash
#
# check-commit-emails.sh — fail when a commit in the scan range uses a
# disallowed author, committer, Co-authored-by, or Signed-off-by email,
# or when commit metadata contains a private hostname or internal IP.
#
# Matched values are never printed. Findings are reported as
# <short-sha> <field> <category>
# only. Public CI logs are public.
#
# Range (first match wins):
# $PRIVACY_COMMIT_RANGE a git revision range, or the token --all
# --range <rev> | --all command-line flags
# otherwise --all
#
# Allowed emails (override with $ALLOWED_EMAIL_PATTERN):
# *@users.noreply.github.com and noreply@github.com
#
# Exit codes: 0 clean, 1 finding, 2 misuse.

set -u

cd "$(git rev-parse --show-toplevel)" || exit 2

ALLOWED_EMAIL_PATTERN="${ALLOWED_EMAIL_PATTERN:-(@users\.noreply\.github\.com|^noreply@github\.com)$}"

# Hostname and address patterns, assembled from fragments so this file does
# not itself match a tree denylist. Keep them generic: no personal names.
TS_NET='[a-z0-9-]+\.ts''\.net\b'
OVH_VPS='[a-z0-9-]+\.vps\.ovh''\.net\b'
OVH_VPS_CA='[a-z0-9-]+\.vps\.ovh''\.ca\b'
HETZNER_DED='[a-z0-9.-]+\.your-server''\.de\b'
HETZNER_CLOUD='[a-z0-9-]+\.hetzner''\.cloud\b'
# Tailnet CGNAT (100.64/10) and RFC1918
CGNAT='\b100\.(6[4-9]|[7-9][0-9]|1[01][0-9]|12[0-7])\.[0-9]{1,3}\.[0-9]{1,3}\b'
RFC10='\b10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\b'
RFC192='\b192\.168\.[0-9]{1,3}\.[0-9]{1,3}\b'
RFC172='\b172\.(1[6-9]|2[0-9]|3[01])\.[0-9]{1,3}\.[0-9]{1,3}\b'

HOSTNAME_PATTERN="${TS_NET}|${OVH_VPS}|${OVH_VPS_CA}|${HETZNER_DED}|${HETZNER_CLOUD}"
IP_PATTERN="${CGNAT}|${RFC10}|${RFC192}|${RFC172}"

usage() {
echo "usage: $0 [--all] [--range <rev>]" >&2
exit 2
}

RANGE="${PRIVACY_COMMIT_RANGE:-}"
while [[ $# -gt 0 ]]; do
case "$1" in
--all) RANGE="--all"; shift ;;
--range)
[[ $# -ge 2 ]] || usage
RANGE="$2"
shift 2
;;
-h|--help) usage ;;
*) usage ;;
esac
done
[[ -n "$RANGE" ]] || RANGE="--all"

# Validate the allowed-email pattern without printing it.
if ! printf 'a@users.noreply.github.com\n' | grep -qE "$ALLOWED_EMAIL_PATTERN"; then
echo "error: ALLOWED_EMAIL_PATTERN does not accept a GitHub noreply address" >&2
exit 2
fi
if ! printf 'noreply@github.com\n' | grep -qE "$ALLOWED_EMAIL_PATTERN"; then
echo "error: ALLOWED_EMAIL_PATTERN does not accept noreply@github.com" >&2
exit 2
fi

# Resolve the commit list. An empty range (no new commits) is clean.
commits="$(mktemp)"
findings="$(mktemp)"
trap 'rm -f "$commits" "$findings"' EXIT

if [[ "$RANGE" == "--all" ]]; then
if ! git rev-list --all > "$commits" 2>/dev/null; then
echo "error: could not list commits for --all" >&2
exit 2
fi
else
if ! git rev-list "$RANGE" > "$commits" 2>/dev/null; then
echo "error: invalid commit range" >&2
exit 2
fi
fi

if [[ ! -s "$commits" ]]; then
echo "OK commit metadata: no commits in range"
exit 0
fi

# classify_email <addr> -> category (or empty if allowed)
classify_email() {
local addr="$1"
[[ -n "$addr" ]] || return 0
if printf '%s\n' "$addr" | grep -qE "$ALLOWED_EMAIL_PATTERN"; then
return 0
fi
if printf '%s\n' "$addr" | grep -qiE "$HOSTNAME_PATTERN"; then
echo "private-hostname"
return 0
fi
if printf '%s\n' "$addr" | grep -qiE "$IP_PATTERN"; then
echo "private-ip"
return 0
fi
echo "disallowed-email"
}

# classify_text <text> -> category (or empty)
classify_text() {
local text="$1"
[[ -n "$text" ]] || return 0
if printf '%s\n' "$text" | grep -qiE "$HOSTNAME_PATTERN"; then
echo "private-hostname"
return 0
fi
if printf '%s\n' "$text" | grep -qiE "$IP_PATTERN"; then
echo "private-ip"
return 0
fi
}

# extract_trailer_email <line> — Co-authored-by / Signed-off-by "Name <email>"
extract_trailer_email() {
local line="$1" addr
addr="$(printf '%s\n' "$line" | sed -n 's/.*<\([^>]*\)>.*/\1/p')"
printf '%s\n' "$addr"
}

while IFS= read -r sha || [[ -n "$sha" ]]; do
[[ -n "$sha" ]] || continue
short="$(git rev-parse --short "$sha")"
author="$(git log -1 --format='%ae' "$sha")"
committer="$(git log -1 --format='%ce' "$sha")"
subject="$(git log -1 --format='%s' "$sha")"
body="$(git log -1 --format='%b' "$sha")"

catg="$(classify_email "$author")"
[[ -n "$catg" ]] && printf '%s\tauthor\t%s\n' "$short" "$catg" >> "$findings"
catg="$(classify_email "$committer")"
[[ -n "$catg" ]] && printf '%s\tcommitter\t%s\n' "$short" "$catg" >> "$findings"

# Trailers only (unfolded). Do not treat the whole body as trailers.
trailers="$(git log -1 --format='%(trailers:only,unfold)' "$sha")"
while IFS= read -r tline || [[ -n "$tline" ]]; do
[[ -n "$tline" ]] || continue
key="$(printf '%s\n' "$tline" | sed -n 's/^\([^:]*\):.*/\1/p' | tr '[:upper:]' '[:lower:]')"
case "$key" in
co-authored-by|signed-off-by)
addr="$(extract_trailer_email "$tline")"
catg="$(classify_email "$addr")"
field="Co-authored-by"
[[ "$key" == "signed-off-by" ]] && field="Signed-off-by"
[[ -n "$catg" ]] && printf '%s\t%s\t%s\n' "$short" "$field" "$catg" >> "$findings"
;;
esac
done <<< "$trailers"

# Subject and body (including non-trailer text) for hostnames and internal IPs.
# Email addresses in the message body that are not trailers are not classified
# here; author/committer/trailer checks cover the metadata leak path.
catg="$(classify_text "$subject")"
[[ -n "$catg" ]] && printf '%s\tmessage\t%s\n' "$short" "$catg" >> "$findings"
# Skip re-reporting the same category already found in the subject.
body_catg="$(classify_text "$body")"
if [[ -n "$body_catg" && "$body_catg" != "$catg" ]]; then
printf '%s\tmessage\t%s\n' "$short" "$body_catg" >> "$findings"
elif [[ -n "$body_catg" && -z "$catg" ]]; then
printf '%s\tmessage\t%s\n' "$short" "$body_catg" >> "$findings"
fi
done < "$commits"

if [[ -s "$findings" ]]; then
count="$(wc -l < "$findings" | tr -d ' ')"
echo "FAIL commit metadata: $count finding(s); values withheld"
# field may contain a hyphen; columns are tab-separated
sort -u "$findings" | awk -F '\t' '{printf " %s %s %s\n", $1, $2, $3}'
exit 1
fi

n="$(wc -l < "$commits" | tr -d ' ')"
echo "OK commit metadata: $n commit(s) in range, no findings"
exit 0
Loading
Loading