diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a56a2e9..37f08dff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,3 +17,42 @@ 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 + permissions: + contents: read + 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 + persist-credentials: false + - 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 + range=() + if [ "$EVENT" = "pull_request" ]; then + 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 new file mode 100644 index 00000000..47607996 --- /dev/null +++ b/.gitleaks.toml @@ -0,0 +1,26 @@ +# 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" +# \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]] +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..4edc01a6 --- /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: 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). +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..8a0a827d --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,17 @@ +# Local secret scan on staged changes (TOM-1257); CI runs the same rules. +# Setup (install gitleaks, then `pre-commit install`): see README.md. +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..150fae78 100644 --- a/README.md +++ b/README.md @@ -55,4 +55,6 @@ 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 +[pre-commit](https://pre-commit.com) and [gitleaks](https://github.com/gitleaks/gitleaks), then run +`pre-commit install` — this repo is public.