From ab928f94e71d58f0afa2f08df319e7ab435b2553 Mon Sep 17 00:00:00 2001 From: Tomasz Wilczega <90728533+tomlupo@users.noreply.github.com> Date: Mon, 28 Sep 2026 18:29:09 +0200 Subject: [PATCH 1/3] chore(ci): gitleaks secret scan in CI and a local pre-commit hook (TOM-1257) The repo is public, so nothing checked that a commit carries no secret or private infra detail. Adds: - .gitleaks.toml: default rules plus tailnet/CGNAT IPv4 (100.64.0.0/10) and the /home/prod/ path. The path rule captures "home/prod/" without its leading slash, because the default global allowlist drops any secret shaped like ^/home/... and the rule would otherwise never fire. - .gitleaksignore: the four findings already in public history, one exact fingerprint each (a revoked Firecrawl key, a tailnet IP on two lines, a prod path in prose). No path- or rule-wide allow. - ci.yml secret-scan job: gitleaks v8.30.1, sha256 pinned from the official checksums file; PR commits on pull_request, full history on push to main. - .pre-commit-config.yaml: staged-changes scan; a missing binary fails with an install hint instead of passing. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_015Q48fmG4d2ZB2DJP3B4o2x --- .github/workflows/ci.yml | 37 +++++++++++++++++++++++++++++++++++++ .gitleaks.toml | 25 +++++++++++++++++++++++++ .gitleaksignore | 13 +++++++++++++ .pre-commit-config.yaml | 18 ++++++++++++++++++ README.md | 3 ++- 5 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 .gitleaks.toml create mode 100644 .gitleaksignore create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a56a2e9..f8b3b102 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,3 +17,40 @@ jobs: run: >- uvx --with pandas --with numpy --with plotly pytest claude/skills/quant/investment-research-dashboard/reporting/test_reporting.py -q + + secret-scan: + # No secrets or private infra details in a public repo (TOM-1257). + # Rules: .gitleaks.toml. Known public-history findings: .gitleaksignore. + # pull_request scans only the PR's commits; push to main scans all history. + runs-on: ubuntu-latest + env: + GITLEAKS_VERSION: 8.30.1 + # From the release's official gitleaks_8.30.1_checksums.txt. + GITLEAKS_SHA256: 551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: install gitleaks (pinned, checksum-verified) + run: | + set -euo pipefail + tarball="gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" + curl -fsSL -o "$tarball" \ + "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/${tarball}" + echo "${GITLEAKS_SHA256} ${tarball}" | sha256sum -c - + mkdir -p "$RUNNER_TEMP/bin" + tar -xzf "$tarball" -C "$RUNNER_TEMP/bin" gitleaks + echo "$RUNNER_TEMP/bin" >> "$GITHUB_PATH" + - name: gitleaks + env: + EVENT: ${{ github.event_name }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: | + set -euo pipefail + if [ "$EVENT" = "pull_request" ]; then + gitleaks git --no-banner --redact --config .gitleaks.toml \ + --log-opts="${BASE_SHA}..${HEAD_SHA}" . + else + gitleaks git --no-banner --redact --config .gitleaks.toml . + fi diff --git a/.gitleaks.toml b/.gitleaks.toml new file mode 100644 index 00000000..d6a92f61 --- /dev/null +++ b/.gitleaks.toml @@ -0,0 +1,25 @@ +# Secret / confidential-data scan (TOM-1257). Run by CI (.github/workflows/ci.yml) +# and by the local pre-commit hook (.pre-commit-config.yaml). +# Default gitleaks rules, plus two leaks the defaults do not know about. +# Known historical findings are suppressed one fingerprint at a time in +# .gitleaksignore -- never by path or rule here. + +[extend] +useDefault = true + +[[rules]] +id = "tailnet-ip" +description = "Tailscale / CGNAT IPv4 address (100.64.0.0/10) -- a private network address" +regex = '''(?:^|[^0-9.])(100\.(?:6[4-9]|[7-9][0-9]|1[01][0-9]|12[0-7])\.[0-9]{1,3}\.[0-9]{1,3})(?:[^0-9]|$)''' +secretGroup = 1 +keywords = ["100."] + +[[rules]] +id = "prod-home-path" +description = "Path under the production user's home (/home/prod/)" +# The leading slash sits outside the captured secret on purpose: the default +# global allowlist drops any secret matching ^/(?:bin|etc|home|...)/..., so a +# secret that starts with "/home/" would never be reported. +regex = '''/(home/prod/)''' +secretGroup = 1 +keywords = ["/home/prod/"] diff --git a/.gitleaksignore b/.gitleaksignore new file mode 100644 index 00000000..cbbc161d --- /dev/null +++ b/.gitleaksignore @@ -0,0 +1,13 @@ +# Findings already in PUBLIC history, one exact fingerprint each +# (commit:file:rule:line). Rewriting history cannot un-publish them, so they +# are acknowledged here instead. Never add a path- or rule-wide entry. + +# TOM-1257: revoked key, history is public (Firecrawl API key, file deleted since). +326a7127073dab2974a610350ef5927bd5f893ae:project-templates/default-quant/.mcp/firecrawl/.mcp.json:generic-api-key:10 + +# TOM-1257: tailnet address, history is public (removed in 28110dd). +3de3320003f7b9852f26d479b070b77e97b80f64:plugins/qute-essentials/scripts/tasks/lib.sh:tailnet-ip:56 +3de3320003f7b9852f26d479b070b77e97b80f64:plugins/qute-essentials/scripts/tasks/lib.sh:tailnet-ip:65 + +# TOM-1257: prod home path in prose, history is public (file moved out since). +6e0735787739b69e344d38ed6f4cb57770e48e47:plugins/qute-essentials/skills/wtf/SKILL.md:prod-home-path:97 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..b267aae5 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +# Local secret scan on staged changes (TOM-1257); CI runs the same rules. +# Setup, once per clone: install gitleaks (https://github.com/gitleaks/gitleaks), +# then `pre-commit install`. +repos: + - repo: local + hooks: + - id: gitleaks + name: gitleaks (staged changes) + language: system + stages: [pre-commit] + pass_filenames: false + always_run: true + # A missing binary FAILS: "could not check" must never look clean. + entry: >- + bash -c 'command -v gitleaks >/dev/null 2>&1 || { + echo "gitleaks not found: install it (https://github.com/gitleaks/gitleaks#installing) + or this commit cannot be checked for secrets." >&2; exit 1; }; + exec gitleaks git --pre-commit --staged --redact --no-banner --config .gitleaks.toml .' diff --git a/README.md b/README.md index 109e55bb..4fe758da 100644 --- a/README.md +++ b/README.md @@ -55,4 +55,5 @@ qute-research plugin (`templates/research-scaffold/`), stamped by `onboard repo` - [`docs/adr/`](docs/adr/) — pointer to the plugin ADRs (history stays in git) - [`docs/resources.md`](docs/resources.md) — curated external links (interesting repos, tools, reading) -See [`CLAUDE.md`](CLAUDE.md) for repo conventions. +See [`CLAUDE.md`](CLAUDE.md) for repo conventions. Before committing here, install +[gitleaks](https://github.com/gitleaks/gitleaks) and run `pre-commit install` — this repo is public. From 2ef732ebb18b3e6be967d41a66c6f281bbbd4c7c Mon Sep 17 00:00:00 2001 From: Tomasz Wilczega <90728533+tomlupo@users.noreply.github.com> Date: Mon, 28 Sep 2026 18:33:00 +0200 Subject: [PATCH 2/3] fix(ci): tailnet rule catches adjacent addresses; read-only scan job (TOM-1257) Review round 1: the tailnet rule consumed the character after an address, and since matches never overlap, a second address separated by one character was missed. Use \b boundaries instead. The secret-scan job now runs with contents: read and no persisted credentials, and makes a single gitleaks call. Setup hint lives in the README only. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_015Q48fmG4d2ZB2DJP3B4o2x --- .github/workflows/ci.yml | 10 ++++++---- .gitleaks.toml | 5 +++-- .pre-commit-config.yaml | 3 +-- README.md | 3 ++- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8b3b102..37f08dff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,8 @@ jobs: # Rules: .gitleaks.toml. Known public-history findings: .gitleaksignore. # pull_request scans only the PR's commits; push to main scans all history. runs-on: ubuntu-latest + permissions: + contents: read env: GITLEAKS_VERSION: 8.30.1 # From the release's official gitleaks_8.30.1_checksums.txt. @@ -31,6 +33,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + persist-credentials: false - name: install gitleaks (pinned, checksum-verified) run: | set -euo pipefail @@ -48,9 +51,8 @@ jobs: HEAD_SHA: ${{ github.event.pull_request.head.sha }} run: | set -euo pipefail + range=() if [ "$EVENT" = "pull_request" ]; then - gitleaks git --no-banner --redact --config .gitleaks.toml \ - --log-opts="${BASE_SHA}..${HEAD_SHA}" . - else - gitleaks git --no-banner --redact --config .gitleaks.toml . + range=(--log-opts="${BASE_SHA}..${HEAD_SHA}") fi + gitleaks git --no-banner --redact --config .gitleaks.toml "${range[@]}" . diff --git a/.gitleaks.toml b/.gitleaks.toml index d6a92f61..47607996 100644 --- a/.gitleaks.toml +++ b/.gitleaks.toml @@ -10,8 +10,9 @@ useDefault = true [[rules]] id = "tailnet-ip" description = "Tailscale / CGNAT IPv4 address (100.64.0.0/10) -- a private network address" -regex = '''(?:^|[^0-9.])(100\.(?:6[4-9]|[7-9][0-9]|1[01][0-9]|12[0-7])\.[0-9]{1,3}\.[0-9]{1,3})(?:[^0-9]|$)''' -secretGroup = 1 +# \b, not a consumed boundary char: matches never overlap, so consuming the +# separator would hide an address that follows another one. +regex = '''\b100\.(?:6[4-9]|[7-9][0-9]|1[01][0-9]|12[0-7])\.[0-9]{1,3}\.[0-9]{1,3}\b''' keywords = ["100."] [[rules]] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b267aae5..8a0a827d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,5 @@ # Local secret scan on staged changes (TOM-1257); CI runs the same rules. -# Setup, once per clone: install gitleaks (https://github.com/gitleaks/gitleaks), -# then `pre-commit install`. +# Setup (install gitleaks, then `pre-commit install`): see README.md. repos: - repo: local hooks: diff --git a/README.md b/README.md index 4fe758da..150fae78 100644 --- a/README.md +++ b/README.md @@ -56,4 +56,5 @@ qute-research plugin (`templates/research-scaffold/`), stamped by `onboard repo` - [`docs/resources.md`](docs/resources.md) — curated external links (interesting repos, tools, reading) See [`CLAUDE.md`](CLAUDE.md) for repo conventions. Before committing here, install -[gitleaks](https://github.com/gitleaks/gitleaks) and run `pre-commit install` — this repo is public. +[pre-commit](https://pre-commit.com) and [gitleaks](https://github.com/gitleaks/gitleaks), then run +`pre-commit install` — this repo is public. From 9c267ef6945f80a57fe99943ba2d4a84bddf82c7 Mon Sep 17 00:00:00 2001 From: Tomasz Wilczega <90728533+tomlupo@users.noreply.github.com> Date: Tue, 29 Sep 2026 05:38:50 +0200 Subject: [PATCH 3/3] docs(ci): the Firecrawl key is accepted, not revoked (TOM-1257) Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_016XFtDJbpgD12enJgui1yar --- .gitleaksignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitleaksignore b/.gitleaksignore index cbbc161d..4edc01a6 100644 --- a/.gitleaksignore +++ b/.gitleaksignore @@ -2,7 +2,7 @@ # (commit:file:rule:line). Rewriting history cannot un-publish them, so they # are acknowledged here instead. Never add a path- or rule-wide entry. -# TOM-1257: revoked key, history is public (Firecrawl API key, file deleted since). +# TOM-1257: free-tier Firecrawl key, not revoked by decision (Tom, 2026-09-29, TOM-1257); history is public (file deleted since). 326a7127073dab2974a610350ef5927bd5f893ae:project-templates/default-quant/.mcp/firecrawl/.mcp.json:generic-api-key:10 # TOM-1257: tailnet address, history is public (removed in 28110dd).