Skip to content

feat(#1352): improve(security): enable secret scanning + push protection and add gitleaks with project rules — four manual-caught leaks in a public repo - #1357

Merged
admarble merged 4 commits into
mainfrom
feature/1352-improve-security-enable-secret-scanning-push-prote
Oct 8, 2026
Merged

admarble merged 4 commits into
mainfrom
feature/1352-improve-security-enable-secret-scanning-push-prote

Conversation

@admarble

@admarble admarble commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Tree cleanup: I redacted the owner's home path in evals/results/qa-trust-boundary-{pr-comment,tool-output}.json. I also replaced the real-shaped session URL, cse_ id and project name in scripts/hook-corpus.test.ts and in-place-checkout-skill.integration.test.ts with fake values.
  • Gitleaks config: .gitleaks.toml extends the default rules with three project rules: home-path, claude-session-url and claude-cse-id. Rules match by shape only, and placeholder names are allowlisted by name. I also allowlisted four fake test tokens.
  • CI: .github/workflows/gitleaks.yml runs on pull_request and merge_group. It installs a pinned gitleaks 8.30.1 with a verified checksum and SHA-pins every uses:. It scans the PR range and the working tree, and fails if an entire/* ref exists on origin.
  • Local gate: scripts/gitleaks-precommit.sh is an optional pre-commit hook that also loads an untracked .gitleaks.local.toml, which is now gitignored.
  • Docs: docs/reference/secret-scanning.md and a CHANGELOG entry.

AC verification

AC Status Evidence
AC-1 ✅ gh api repos/sequant-io/sequant --jq .security_and_analysis shows secret_scanning, secret_scanning_push_protection and dependabot_security_updates all enabled.
AC-2 ✅ gitleaks.yml has the triggers and the gitleaks detect --config .gitleaks.toml step, and now also runs the rule tests with SEQUANT_REQUIRE_GITLEAKS=1. Four shape tests in __tests__/gitleaks-config.integration.test.ts cover triggers, checksum, SHA pins and that test step.
AC-3 ✅ The integration test flags a real-shaped home path and a claude.ai/code/session_ URL, and passes the tracked tree. 9 of 9 pass with gitleaks 8.30.1 (SEQUANT_REQUIRE_GITLEAKS=1). The first round's "8 of 8" was wrong: the tree-pass test failed on this PR's own fixtures (fixed in 2119fcea).
AC-4 ✅ The config contains no literal sensitive string. AC-4: every project rule regex is shape-based is the mechanical backstop, not a full check. Reviewer check recorded here.
AC-5 ✅ git grep -nE '/Users/[a-z]+/' on the branch, filtered to non-placeholder names, is empty. Leak-shaped fixtures are built at run time.
AC-6 ✅ The install step runs sha256sum -c - under set -euo pipefail, so a mismatch fails the job.
AC-7 ⚠️ Partial claude plugin eval writes the paths and is outside this repo. I redacted the committed files, and the home-path rule now fails any PR that reintroduces them. A note is in the scanner doc.

Two deviations from the spec:

  • alice is not allowlisted. It's a real-shaped name for the tests. Fixtures build /Users/alice/ at run time so the committed source never holds it.
  • Rule tests skip when gitleaks is missing (locally, and in the main test job). The gitleaks job installs the binary and runs them with SEQUANT_REQUIRE_GITLEAKS=1, so they cannot skip there.

QA round 1 fixes (2119fcea)

  • The gitleaks job failed on this PR's own fixtures (home-path ×3, claude-session-url ×1 in the new test file). Fixtures are now assembled at run time, the same idiom as FAKE_GHP in scripts/hook-corpus.test.ts. No path allowlist was added, since one would also hide a real leak added to that file later.
  • The hook-corpus.test.ts redaction tests had been switched to /Users/user/ input, which made them unable to fail: with the home-path redaction disabled in scripts/hook-corpus.ts, the round-1 tests still passed 13/13. They feed a real-shaped home dir again.
  • The gitleaks job now runs the rule tests itself.

Mutation-verified: AC-2 — removed the "Test the project rules" step from gitleaks.yml; __tests__/gitleaks-config.integration.test.ts > gitleaks workflow shape (#1352 AC-2) > runs the rule tests with gitleaks required, so they cannot skip in CI failed; restored.
Mutation-verified: AC-5 — replaced the home-path redaction regex in scripts/hook-corpus.ts with a never-matching one; scripts/hook-corpus.test.ts > hook-corpus redaction > redacts emails and the home directory of a public repo failed; restored.

CI round fix (b374f18e)

The PR scan checks every commit, so d718c03e's fake fixtures still failed it after 2119fcea rebuilt them at run time. .gitleaksignore lists those four findings by fingerprint (commit:file:rule:line), which can't hide a new leak, and docs/reference/secret-scanning.md says when to add one. After a squash merge the commit isn't on main, so the entries do nothing there.

The owner still has to add the new check to the main ruleset after a green week.

npm run build and npm run lint pass.

Mutation-verified: AC-3 — replaced the home-path regex with a never-matching one; __tests__/gitleaks-config.integration.test.ts > gitleaks project rules (#1352) > flags a real-shaped home path failed; restored.
Mutation-verified: AC-3 — replaced the claude-session-url regex with a never-matching one; __tests__/gitleaks-config.integration.test.ts > gitleaks project rules (#1352) > flags a Claude session URL failed; restored.

Each mutation also failed the tree-pass test and the AC-4 shape test, because the never-matching regex trips both.

Pre-PR Confidence Check

QA round 2 fixes (98f99f6c)

  • github.base_ref and the merge_group SHAs reach the range script through env:, not ${{ }} inside run:. A shape test guards every run: block.
  • The claude-cse-id rule has a fixture test: a real-shaped id is flagged, a cse_FAKE… one is allowed.

Mutation-verified: AC-2 — put ${{ github.base_ref }} back into the range run: script; __tests__/gitleaks-config.integration.test.ts > gitleaks workflow shape (#1352 AC-2) > passes event values to run: scripts through env, not ${{ }} failed; restored.
Mutation-verified: AC-3 — replaced the claude-cse-id regex with a never-matching one; __tests__/gitleaks-config.integration.test.ts > gitleaks project rules (#1352) > flags a Claude cloud session id but allows a FAKE one failed; restored.

Fixes #1352


🤖 Generated by sequant run

…ession links

Entire-Checkpoint: 0ad537cafd3a
… tests in the gitleaks job

The gitleaks job flagged the PR's own fixtures (home paths, a session URL). They are now assembled at run time, so the committed tree passes the scanner and the AC-5 grep. The hook-corpus redaction tests feed a real-shaped home dir again; the earlier /Users/user/ input made them unable to fail. The rule tests skip where gitleaks is absent, so the gitleaks job now runs them with SEQUANT_REQUIRE_GITLEAKS=1.

Entire-Checkpoint: e122c8e45ebb
…n by fingerprint

The PR scan checks every commit, so d718c03's fake fixtures still failed it after 2119fce rebuilt them at run time. .gitleaksignore lists those four findings by fingerprint (commit:file:rule:line), which cannot hide a new leak; the scanner doc says when to add one.

Entire-Checkpoint: 9b9faf5e8a89
…d rule

QA round 2: the range step interpolated github.base_ref and the merge_group SHAs into run:. They now arrive through env, guarded by a shape test. The claude-cse-id rule gets a fixture test (a real-shaped id flagged, a FAKE one allowed).

Entire-Checkpoint: 6d79baf384c7
@admarble
admarble merged commit 39fee12 into main Oct 8, 2026
8 checks passed
@admarble
admarble deleted the feature/1352-improve-security-enable-secret-scanning-push-prote branch October 8, 2026 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

improve(security): enable secret scanning + push protection and add gitleaks with project rules — four manual-caught leaks in a public repo

1 participant