From e3261364bdd67b9140ce0bb1103bfc09f8559070 Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Wed, 4 Nov 2026 21:34:10 -0800 Subject: [PATCH 1/4] 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 | 34 ++++++++++++++++++++++++++++++++++ AGENTS.md | 2 ++ scripts/check-private-links.sh | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 69 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 000000000..4ebcbe6c3 --- /dev/null +++ b/.github/workflows/privacy.yml @@ -0,0 +1,34 @@ +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: + branches: [main] + types: [opened, edited, synchronize, reopened] + +permissions: + contents: read + +jobs: + private-links: + name: Private links + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + 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/AGENTS.md b/AGENTS.md index 1cfc90850..7f1bbfe33 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -39,6 +39,8 @@ - Keep credentials, private telemetry, local workstation paths, and private AI session links out of tracked files, commit messages, and pull request descriptions. + The Privacy workflow (`scripts/check-private-links.sh`) enforces this; squash + merges take the pull request title and description, not branch commit messages. - Keep local agent caches, indexes, evaluation records, and browser evidence out of both Git and the Docker build context. Git ignores do not exclude Docker inputs. - Design proposals live in `docs/proposals/NNNN-slug.md` and decision records diff --git a/scripts/check-private-links.sh b/scripts/check-private-links.sh new file mode 100755 index 000000000..e51673ab8 --- /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 f407e823265f40c1d6d4fc9a8f29c81c6cace45a Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Wed, 4 Nov 2026 21:51:08 -0800 Subject: [PATCH 2/4] build: check for private links before each commit and push CI runs only after a branch is public, so lefthook runs the same check on each commit message and before each push. --- lefthook.yml | 9 +++++++++ scripts/check-private-links.sh | 12 +++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lefthook.yml b/lefthook.yml index cab4a0eba..c4e598e24 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -39,8 +39,17 @@ pre-commit: glob: "{ui/host/**/*.{ts,tsx},ui/panels/**/*.{ts,tsx},ui/*.ts}" run: cd ui/host && bun run lint +commit-msg: + jobs: + - name: private-links + run: bash scripts/check-private-links.sh --message {1} + pre-push: jobs: + # Runs on every push, before anything is public: a private session link or + # local path in a pushed commit cannot be taken back. CI repeats it. + - name: private-links + run: bash scripts/check-private-links.sh origin/main HEAD - name: check # Observed to skip with "no matching push files" on some pushes: lefthook # filters pre-push jobs by its own changed-file detection and skips when diff --git a/scripts/check-private-links.sh b/scripts/check-private-links.sh index e51673ab8..90e657d0c 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 a05d151ecffba51d4231a02176d632cf422e9600 Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Thu, 5 Nov 2026 07:31:44 -0800 Subject: [PATCH 3/4] 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/ci.yml | 13 --------- .github/workflows/leaks.yml | 49 ++++++++++++++++++++++++++++++++++ .github/workflows/privacy.yml | 34 ----------------------- .gitleaks.toml | 34 ++++++++++++----------- AGENTS.md | 4 +-- lefthook.yml | 12 ++++----- scripts/check-private-links.sh | 43 ----------------------------- 7 files changed, 76 insertions(+), 113 deletions(-) create mode 100644 .github/workflows/leaks.yml delete mode 100644 .github/workflows/privacy.yml delete mode 100755 scripts/check-private-links.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f45b60a7..b6de6b39b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,19 +48,6 @@ jobs: with: persist-credentials: false - # Keep source scanning in the required Gate job so a finding blocks merge. - # Scan docs and generated assets too; the container only sees runtime files. - - name: Scan repository for secrets - uses: aquasecurity/trivy-action@a9c7b0f06e461e9d4b4d1711f154ee024b8d7ab8 # v0.36.0 - with: - scan-type: fs - scan-ref: . - version: v0.74.0 - scanners: secret - exit-code: 1 - format: table - cache: false - - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: go-version-file: go.mod diff --git a/.github/workflows/leaks.yml b/.github/workflows/leaks.yml new file mode 100644 index 000000000..ed0a0dc21 --- /dev/null +++ b/.github/workflows/leaks.yml @@ -0,0 +1,49 @@ +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: + branches: [main] + types: [opened, edited, synchronize, reopened] + +permissions: + contents: read + +env: + GITLEAKS_VERSION: 8.30.1 + GITLEAKS_SHA256: 551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb + +jobs: + leaks: + name: Leaks + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + 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 4ebcbe6c3..000000000 --- a/.github/workflows/privacy.yml +++ /dev/null @@ -1,34 +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: - branches: [main] - types: [opened, edited, synchronize, reopened] - -permissions: - contents: read - -jobs: - private-links: - name: Private links - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - 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 index 4466753f5..08a57e3e0 100644 --- a/.gitleaks.toml +++ b/.gitleaks.toml @@ -1,20 +1,24 @@ -# Default rules, plus known non-secrets: a fixed test-only auth code secret, -# a redaction fixture, a cache key name, and content hashes in fixtures. +# 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 -[[allowlists]] -description = "test-only fake secrets and cache key names" -regexes = [ - '''^0123456789abcdef0123456789abcdef$''', - '''^sk-live-abc123$''', - '''^edge_rollup_v2_rawmax$''', -] +[[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/"] +# Test fixtures hold content hashes and fake secrets, not credentials. Only the +# generic key rule is relaxed there; the privacy rules still apply. [[allowlists]] -description = "content hashes in fixtures and the retired Atlas checksum file" -paths = [ - '''^ui/host/e2e/data/mcp\.json$''', - '''^ui/host/tests/go-fragments/[^/]+\.json$''', - '''^internal/db/migrations/atlas\.sum$''', -] +description = "Test fixtures" +targetRules = ["generic-api-key"] +paths = ['''_test\.go$''', '''ui/host/e2e/data/''', '''ui/host/tests/go-fragments/'''] diff --git a/AGENTS.md b/AGENTS.md index 7f1bbfe33..3fa15c313 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -39,8 +39,8 @@ - Keep credentials, private telemetry, local workstation paths, and private AI session links out of tracked files, commit messages, and pull request descriptions. - The Privacy workflow (`scripts/check-private-links.sh`) enforces this; squash - merges take the pull request title and description, not branch commit messages. + `.gitleaks.toml` holds the rules; lefthook and the Leaks workflow enforce them. + Squash merges take the pull request title and description. - Keep local agent caches, indexes, evaluation records, and browser evidence out of both Git and the Docker build context. Git ignores do not exclude Docker inputs. - Design proposals live in `docs/proposals/NNNN-slug.md` and decision records diff --git a/lefthook.yml b/lefthook.yml index c4e598e24..c4ca6fc70 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -12,6 +12,10 @@ pre-commit: parallel: false jobs: + # Secrets, private AI session links and local paths, by .gitleaks.toml. + - name: leaks + run: gitleaks git --pre-commit --staged --redact --no-banner + - name: merge-conflict glob: "*" # Minified single-file bundles legitimately contain long runs of `=`, so @@ -41,15 +45,11 @@ pre-commit: commit-msg: jobs: - - name: private-links - run: bash scripts/check-private-links.sh --message {1} + - name: leaks + run: gitleaks stdin --redact --no-banner < {1} pre-push: jobs: - # Runs on every push, before anything is public: a private session link or - # local path in a pushed commit cannot be taken back. CI repeats it. - - name: private-links - run: bash scripts/check-private-links.sh origin/main HEAD - name: check # Observed to skip with "no matching push files" on some pushes: lefthook # filters pre-push jobs by its own changed-file detection and skips when diff --git a/scripts/check-private-links.sh b/scripts/check-private-links.sh deleted file mode 100755 index 90e657d0c..000000000 --- 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" From dcf87f70905ecaf79f68b90f3838f7321966c537 Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Thu, 5 Nov 2026 07:32:27 -0800 Subject: [PATCH 4/4] ci: keep the existing gitleaks allowlists Add the privacy rules to the existing .gitleaks.toml instead of replacing it, and drop the allowlist entry for the removed Atlas checksum file. --- .gitleaks.toml | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/.gitleaks.toml b/.gitleaks.toml index 08a57e3e0..28487fb2a 100644 --- a/.gitleaks.toml +++ b/.gitleaks.toml @@ -1,9 +1,25 @@ -# 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). +# Default secret rules, plus links and paths this public repository must never +# publish, and known non-secrets: a fixed test-only auth code secret, a +# redaction fixture, a cache key name, and content hashes in fixtures. +# Lefthook and the Leaks workflow read this file; add a rule here to extend both. [extend] useDefault = true +[[allowlists]] +description = "test-only fake secrets and cache key names" +regexes = [ + '''^0123456789abcdef0123456789abcdef$''', + '''^sk-live-abc123$''', + '''^edge_rollup_v2_rawmax$''', +] + +[[allowlists]] +description = "content hashes in fixtures" +paths = [ + '''^ui/host/e2e/data/mcp\.json$''', + '''^ui/host/tests/go-fragments/[^/]+\.json$''', +] + [[rules]] id = "private-ai-session-link" description = "Private AI session link or session trailer" @@ -15,10 +31,3 @@ id = "local-workstation-path" description = "Local workstation home directory path" regex = '''(/Users|/home)/[A-Za-z0-9_.-]+/''' keywords = ["/users/", "/home/"] - -# Test fixtures hold content hashes and fake secrets, not credentials. Only the -# generic key rule is relaxed there; the privacy rules still apply. -[[allowlists]] -description = "Test fixtures" -targetRules = ["generic-api-key"] -paths = ['''_test\.go$''', '''ui/host/e2e/data/''', '''ui/host/tests/go-fragments/''']