From 6943cc86ac854c2049245d2fd19349af90047be7 Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Wed, 4 Nov 2026 21:34:28 -0800 Subject: [PATCH 1/3] ci: reject private session links and local paths A privacy workflow checks tracked files, the pull request's commit messages and its title and description. Squash merges now take the pull request title and description. --- .github/workflows/privacy.yml | 32 ++++++++++++++++++++++++++++++++ scripts/check-private-links.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 .github/workflows/privacy.yml create mode 100755 scripts/check-private-links.sh diff --git a/.github/workflows/privacy.yml b/.github/workflows/privacy.yml new file mode 100644 index 0000000..4609a0d --- /dev/null +++ b/.github/workflows/privacy.yml @@ -0,0 +1,32 @@ +name: privacy + +# This repository is public. Private AI session links and local workstation +# paths stay out of tracked files, commit messages and pull request text. +on: + push: + branches: [main] + pull_request: + types: [opened, edited, synchronize, reopened] + +permissions: + contents: read + +jobs: + private-links: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + - name: Check for private session links and local paths + env: + PR_TEXT: ${{ github.event.pull_request.title }}${{ '\n' }}${{ github.event.pull_request.body }} + BASE: ${{ github.event.pull_request.base.sha || github.event.before }} + HEAD: ${{ github.event.pull_request.head.sha || github.sha }} + run: | + if git cat-file -e "$BASE^{commit}" 2>/dev/null; then + bash scripts/check-private-links.sh "$BASE" "$HEAD" + else + bash scripts/check-private-links.sh + fi diff --git a/scripts/check-private-links.sh b/scripts/check-private-links.sh new file mode 100755 index 0000000..e51673a --- /dev/null +++ b/scripts/check-private-links.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# Fails when tracked files, commit messages or pull request text name a private +# AI session link or a local workstation path. This repository is public. +# +# scripts/check-private-links.sh [ ] +# +# With and , commit messages in base..head are checked too. +# PR_TEXT, when set, is the pull request title and description. +set -euo pipefail + +pattern='claude\.ai/(code|chat|share|project)|Claude-Session:|chatgpt\.com/(c|share|codex)/|/Users/[A-Za-z0-9_.-]+/|/home/[A-Za-z0-9_.-]+/' +found=0 + +if git grep -nIE "$pattern" -- . ':!scripts/check-private-links.sh'; then + echo "error: tracked files name a private session link or local path" >&2 + found=1 +fi + +if [[ $# -eq 2 ]]; then + while read -r sha; do + if git log -1 --format=%B "$sha" | grep -qE "$pattern"; then + echo "error: commit $sha message names a private session link or local path" >&2 + found=1 + fi + done < <(git rev-list "$1..$2") +fi + +if [[ -n "${PR_TEXT:-}" ]] && grep -qE "$pattern" <<<"$PR_TEXT"; then + echo "error: pull request title or description names a private session link or local path" >&2 + found=1 +fi + +exit "$found" From 4b674c568cb2685badffd6f5c9891f1fead71eef Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Wed, 4 Nov 2026 21:51:18 -0800 Subject: [PATCH 2/3] build: let the private link check read one commit message Same script as Fanout: --message checks a commit message, for use as a local commit-msg hook. --- scripts/check-private-links.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/check-private-links.sh b/scripts/check-private-links.sh index e51673a..90e657d 100755 --- a/scripts/check-private-links.sh +++ b/scripts/check-private-links.sh @@ -3,14 +3,24 @@ # AI session link or a local workstation path. This repository is public. # # scripts/check-private-links.sh [ ] +# scripts/check-private-links.sh --message # # With and , commit messages in base..head are checked too. -# PR_TEXT, when set, is the pull request title and description. +# PR_TEXT, when set, is the pull request title and description. --message +# checks one commit message file only (the commit-msg hook). set -euo pipefail pattern='claude\.ai/(code|chat|share|project)|Claude-Session:|chatgpt\.com/(c|share|codex)/|/Users/[A-Za-z0-9_.-]+/|/home/[A-Za-z0-9_.-]+/' found=0 +if [[ "${1:-}" == --message ]]; then + if grep -nE "$pattern" "$2"; then + echo "error: commit message names a private session link or local path" >&2 + exit 1 + fi + exit 0 +fi + if git grep -nIE "$pattern" -- . ':!scripts/check-private-links.sh'; then echo "error: tracked files name a private session link or local path" >&2 found=1 From f0f05629585577c555cb1ce5682b6d9bcc40f048 Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Thu, 5 Nov 2026 07:31:47 -0800 Subject: [PATCH 3/3] ci: scan for secrets, session links and local paths with gitleaks CI: one gitleaks rules file in place of the custom script. .gitleaks.toml extends gitleaks's default secret rules with private AI session links and local workstation paths. A Leaks workflow scans files, and on pull requests also the title, description and commit messages. Lefthook runs the same rules on staged changes and commit messages. --- .github/workflows/leaks.yml | 48 ++++++++++++++++++++++++++++++++++ .github/workflows/privacy.yml | 32 ----------------------- .gitleaks.toml | 17 ++++++++++++ lefthook.yml | 11 ++++++++ scripts/check-private-links.sh | 43 ------------------------------ 5 files changed, 76 insertions(+), 75 deletions(-) create mode 100644 .github/workflows/leaks.yml delete mode 100644 .github/workflows/privacy.yml create mode 100644 .gitleaks.toml create mode 100644 lefthook.yml delete mode 100755 scripts/check-private-links.sh diff --git a/.github/workflows/leaks.yml b/.github/workflows/leaks.yml new file mode 100644 index 0000000..cb31c43 --- /dev/null +++ b/.github/workflows/leaks.yml @@ -0,0 +1,48 @@ +name: leaks + +# Secrets, private AI session links and local workstation paths stay out of +# this public repository. The rules live in .gitleaks.toml. +on: + push: + branches: [main] + pull_request: + types: [opened, edited, synchronize, reopened] + +permissions: + contents: read + +env: + GITLEAKS_VERSION: 8.30.1 + GITLEAKS_SHA256: 551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb + +jobs: + leaks: + name: leaks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Install gitleaks + run: | + archive="$RUNNER_TEMP/gitleaks.tar.gz" + curl -fsSLo "$archive" "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" + echo "${GITLEAKS_SHA256} $archive" | sha256sum -c - + tar -xzf "$archive" -C "$RUNNER_TEMP" gitleaks + + - name: Scan files + run: '"$RUNNER_TEMP/gitleaks" dir . --redact --no-banner' + + # Edits to the description rerun this job, so the text is checked as posted. + - name: Scan pull request text and commit messages + if: github.event_name == 'pull_request' + env: + TITLE: ${{ github.event.pull_request.title }} + BODY: ${{ github.event.pull_request.body }} + BASE: ${{ github.event.pull_request.base.sha }} + HEAD: ${{ github.event.pull_request.head.sha }} + run: | + { printf '%s\n%s\n' "$TITLE" "$BODY"; git log --format=%B "$BASE..$HEAD"; } | + "$RUNNER_TEMP/gitleaks" stdin --redact --no-banner diff --git a/.github/workflows/privacy.yml b/.github/workflows/privacy.yml deleted file mode 100644 index 4609a0d..0000000 --- a/.github/workflows/privacy.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: privacy - -# This repository is public. Private AI session links and local workstation -# paths stay out of tracked files, commit messages and pull request text. -on: - push: - branches: [main] - pull_request: - types: [opened, edited, synchronize, reopened] - -permissions: - contents: read - -jobs: - private-links: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - persist-credentials: false - - name: Check for private session links and local paths - env: - PR_TEXT: ${{ github.event.pull_request.title }}${{ '\n' }}${{ github.event.pull_request.body }} - BASE: ${{ github.event.pull_request.base.sha || github.event.before }} - HEAD: ${{ github.event.pull_request.head.sha || github.sha }} - run: | - if git cat-file -e "$BASE^{commit}" 2>/dev/null; then - bash scripts/check-private-links.sh "$BASE" "$HEAD" - else - bash scripts/check-private-links.sh - fi diff --git a/.gitleaks.toml b/.gitleaks.toml new file mode 100644 index 0000000..0a72adf --- /dev/null +++ b/.gitleaks.toml @@ -0,0 +1,17 @@ +# Secret and privacy rules for this public repository: gitleaks's default +# secret rules plus links and paths that must never be published. Add a rule +# here to extend every check (lefthook and CI read this file). +[extend] +useDefault = true + +[[rules]] +id = "private-ai-session-link" +description = "Private AI session link or session trailer" +regex = '''(?i)(claude\.ai/(code|chat|share|project)/|Claude-Session:|chatgpt\.com/(c|share|codex)/)''' +keywords = ["claude", "chatgpt"] + +[[rules]] +id = "local-workstation-path" +description = "Local workstation home directory path" +regex = '''(/Users|/home)/[A-Za-z0-9_.-]+/''' +keywords = ["/users/", "/home/"] diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 0000000..99e289e --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,11 @@ +# Secrets, private AI session links and local paths, by .gitleaks.toml. +# Install with `lefthook install`; CI runs the same rules. +pre-commit: + jobs: + - name: leaks + run: gitleaks git --pre-commit --staged --redact --no-banner + +commit-msg: + jobs: + - name: leaks + run: gitleaks stdin --redact --no-banner < {1} diff --git a/scripts/check-private-links.sh b/scripts/check-private-links.sh deleted file mode 100755 index 90e657d..0000000 --- a/scripts/check-private-links.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash -# Fails when tracked files, commit messages or pull request text name a private -# AI session link or a local workstation path. This repository is public. -# -# scripts/check-private-links.sh [ ] -# scripts/check-private-links.sh --message -# -# With and , commit messages in base..head are checked too. -# PR_TEXT, when set, is the pull request title and description. --message -# checks one commit message file only (the commit-msg hook). -set -euo pipefail - -pattern='claude\.ai/(code|chat|share|project)|Claude-Session:|chatgpt\.com/(c|share|codex)/|/Users/[A-Za-z0-9_.-]+/|/home/[A-Za-z0-9_.-]+/' -found=0 - -if [[ "${1:-}" == --message ]]; then - if grep -nE "$pattern" "$2"; then - echo "error: commit message names a private session link or local path" >&2 - exit 1 - fi - exit 0 -fi - -if git grep -nIE "$pattern" -- . ':!scripts/check-private-links.sh'; then - echo "error: tracked files name a private session link or local path" >&2 - found=1 -fi - -if [[ $# -eq 2 ]]; then - while read -r sha; do - if git log -1 --format=%B "$sha" | grep -qE "$pattern"; then - echo "error: commit $sha message names a private session link or local path" >&2 - found=1 - fi - done < <(git rev-list "$1..$2") -fi - -if [[ -n "${PR_TEXT:-}" ]] && grep -qE "$pattern" <<<"$PR_TEXT"; then - echo "error: pull request title or description names a private session link or local path" >&2 - found=1 -fi - -exit "$found"