Files
agentic-dev/docs/work/2026-05-14-ci-security-and-supply-chain/07-gitleaks-precommit/_story.md
Danijel Martinek 90fc2853f2 feat(work): add ISO timestamps + auto-bump on staged work-doc changes
- New scripts/work/bump-updated-timestamps.mjs stamps the `updated:`
  frontmatter field to the current ISO 8601 UTC timestamp on every
  staged docs/work/**/*.md file. Idempotent; adds the field after
  `created:` if missing.
- .husky/pre-commit invokes the bump script as step 2 (before
  rebuild-state) so _state.json sees the fresh timestamp.
- Backfill all existing work docs (4 PRDs + 3 epics + 21 stories):
    * created: promoted from \`YYYY-MM-DD\` -> ISO timestamp using
      git log --diff-filter=A on each file (first-commit date for
      stories that had no \`created:\` line, midnight UTC for PRDs
      and epics that had date-only created).
    * updated: added from \`git log -1 --format=%aI\` on each file
      (last-commit timestamp); will be re-stamped to "now" by the
      pre-commit hook on this commit.

Stories that had no \`created:\` line now get one.
2026-05-14 21:10:34 +02:00

2.7 KiB

id, epic, title, type, status, feature, depends-on, blocks, created, updated
id epic title type status feature depends-on blocks created updated
07-gitleaks-precommit 2026-05-14-ci-security-and-supply-chain Gitleaks pre-commit hook technical-story done tooling
09-ci-security-guide-and-docs
2026-05-14T18:59:12+02:00 2026-05-14T19:10:35.370Z

Goal

Add gitleaks protect --staged --redact as a step in .husky/pre-commit and ship a .gitleaks.toml allowlist that covers test-fixture patterns in __seeds__/**, so a commit containing a known secret pattern is blocked locally before it reaches the remote.

Why

Developer accidents (pasting tokens into config, seeding test fixtures with real-looking keys) are the most common secret-leak vector. A pre-commit hook stops the leak at the earliest possible point — before the secret is ever pushed. GitHub native push protection is the second line of defense (documented in Story 09's guide); the hook is the first. The __seeds__/** allowlist prevents false positives from test fixtures that deliberately use token-shaped strings as dummy data.

Done when

  • .husky/pre-commit has a gitleaks protect --staged --redact step that runs before the existing state-sync guard (or after — order between guards doesn't matter, both must run).
  • .gitleaks.toml exists at repo root with at minimum one allowlist rule scoping __seeds__/** test fixtures (using paths or allowlist.paths depending on the gitleaks version).
  • A smoke test (bash script or vitest) pipes a staged commit containing a Stripe-style test key (sk_test_...) through the hook and asserts non-zero exit code. The smoke test is documented in the story's Done-when but may live as a manual verification step given gitleaks requires a binary; include instructions in docs/guides/ci-security.md (Story 09) for consumers to verify locally.
  • pnpm typecheck && pnpm lint && pnpm test && pnpm conformance && pnpm fallow:audit && pnpm coverage:diff all pass.

In scope

  • .husky/pre-commit — new gitleaks step.
  • .gitleaks.toml — allowlist config.

Out of scope

  • Installing gitleaks as a project devDependency — consumers install it via their OS package manager or brew; the hook exits gracefully with a warning if gitleaks is not found in $PATH (to avoid blocking developers who haven't installed it yet, while still enforcing for those who have).
  • GitHub native push protection configuration — consumer-facing instruction deferred to Story 09's guide.

Tasks

  • Add gitleaks protect --staged --redact step to .husky/pre-commit (exit-gracefully if gitleaks not in $PATH); create .gitleaks.toml at repo root with __seeds__/** allowlist for test-fixture patterns; one commit, all gates pass.