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
110 changes: 110 additions & 0 deletions .github/workflows/privacy-guard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Copyable Privacy Guard workflow for a public repository (or one about to
# become public). Required status check name: "Privacy Guard".
#
# Copy into the consuming repo:
# .github/workflows/privacy-guard.yml (this file)
# scripts/check-commit-emails.sh
# scripts/privacy-denylist.sh
# scripts/test-privacy-denylist.sh
# scripts/test-check-commit-emails.sh
# .privacy-denylist
# .privacy-allowlist
# And optionally:
# .githooks/pre-push (see pre-push in this directory)
#
# Then add "Privacy Guard" as a required status check on the default branch.
# Do not print secret or personal values in logs. This file contains no
# personal data and no account-specific addresses.

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
- 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: Test commit-metadata email check
run: bash scripts/test-check-commit-emails.sh
- name: Check denylist
env:
PRIVACY_DENYLIST_EXTRA: ${{ secrets.PRIVACY_DENYLIST_EXTRA }}
run: |
set -euo pipefail
code=0
bash scripts/privacy-denylist.sh || code=$?
if [[ "$code" -eq 0 ]]; then
exit 0
fi
if [[ "$code" -eq 2 && -n "${PRIVACY_DENYLIST_EXTRA:-}" ]]; then
echo "::warning title=Privacy guard::PRIVACY_DENYLIST_EXTRA has invalid regex line(s) for git grep -E. Re-running with the tracked denylist only. Fix the Actions secret."
unset PRIVACY_DENYLIST_EXTRA
bash scripts/privacy-denylist.sh
exit $?
fi
exit "$code"
- name: Check commit emails and trailers
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 }}
REF_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail
# Pull requests: the commits this PR adds. Push to the default
# branch: the full history. Other pushes: the pushed range.
if [[ "$EVENT_NAME" == "pull_request" ]]; then
export PRIVACY_COMMIT_RANGE="${PR_BASE}..${PR_HEAD}"
elif [[ "$EVENT_NAME" == "push" && "$REF_NAME" == "$DEFAULT_BRANCH" ]]; then
export PRIVACY_COMMIT_RANGE="--all"
elif [[ "$EVENT_NAME" == "push" && "${BEFORE:-}" != "" && "$BEFORE" != 0000000000000000000000000000000000000000 ]]; then
export PRIVACY_COMMIT_RANGE="${BEFORE}..HEAD"
else
export PRIVACY_COMMIT_RANGE="--all"
fi
bash scripts/check-commit-emails.sh
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: pnpm
- name: Install and build package
run: |
set -euo pipefail
pnpm install --frozen-lockfile
if node -p "Boolean(require('./package.json').scripts && require('./package.json').scripts.build)" | grep -q true; then
pnpm build
fi
- name: Check package contents
run: bash scripts/check-package-contents.sh
6 changes: 6 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ jobs:
- name: Build
run: pnpm build

- name: Check package contents
working-directory: ${{ github.workspace }}
run: bash scripts/check-package-contents.sh
- name: Publish canary
run: |
sed -i '/_authToken/d' "$NPM_CONFIG_USERCONFIG"
Expand Down Expand Up @@ -176,6 +179,9 @@ jobs:
git tag -a "v${{ steps.version.outputs.version }}" -m "v${{ steps.version.outputs.version }}"
git push origin "v${{ steps.version.outputs.version }}"

- name: Check package contents
working-directory: ${{ github.workspace }}
run: bash scripts/check-package-contents.sh
- name: Publish to npm
run: |
sed -i '/_authToken/d' "$NPM_CONFIG_USERCONFIG"
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ next-env.d.ts
.vllnt/
test-results/
scripts/
!scripts/check-commit-emails.sh
!scripts/privacy-denylist.sh
!scripts/test-privacy-denylist.sh
!scripts/test-check-commit-emails.sh
!scripts/check-package-contents.sh
!scripts/test-check-package-contents.sh

# analysis + coverage artifacts
.codebase-intelligence/
Expand All @@ -25,3 +31,4 @@ coverage/
GEMINI.md
CONVENTIONS.md
.github/copilot-instructions.md
.privacy-denylist.local
10 changes: 10 additions & 0 deletions .gitleaks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title = "gitleaks"

[extend]
useDefault = true

[[allowlists]]
description = "synthetic test fixtures"
paths = [
'''tests/roadmap-2-5-e2e.test.ts''',
]
12 changes: 12 additions & 0 deletions .privacy-allowlist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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)$
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)
Loading
Loading