Skip to content

Packs / github-ops-public

clean-leaked-secrets-history

A secret got committed: stop pushing, remove it from the tree and from history (orphan commit for not-yet-shared repos, git filter-repo --replace-text otherwise), verify with gitleaks, force-push only with OK; rotation is Waleed's call.

Install

logicpacks pack use github-ops-public/clean-leaked-secrets-history
get_pack github-ops-public/clean-leaked-secrets-history

The second line is the MCP tool call for the LogicPacks connector (Claude Code, Codex, Claude.ai and others). The first run of a pack someone else wrote asks for your yes.

Keys it needs (names only)

None.

Playbooks included

  • Spec: spec/SPEC.md (goal, steps, edge cases, don’ts)
  • Routes: gh-cli
  • Checks: 2 in outcome/checks.yaml
  • Code: orphan_reset.shselftest.sh
  • Tools: git, gitleaks, git-filter-repo (pip)

Usage, last 8 weeks

New: no recorded use yet.

Purpose (from spec/SPEC.md)

Goal

The secret value exists nowhere in the repo's reachable history, and the owner knows exactly what leaked and where.

Steps

  1. Stop: don't push; list findings masked (gitleaks detect --source . --log-opts=--all --redact).
  2. Tell Waleed which key (name + masked hint + where); he decides rotation. Never rotate or revoke keys yourself.
  3. Remove from the tree: replace the value with an env NAME / vault reference and commit.
  4. Repo never shared: replace history with one orphan commit of the clean tree: bash code/orphan_reset.sh.
  5. Repo already shared: git filter-repo --replace-text replacements.txt (lines literal:VALUE==>[REDACTED], file kept outside the repo and deleted after), then gitleaks again.

Edge cases

  • Orphaned objects keep counting on GitHub (e.g. contribution graph) until server GC; there is no API to force GC.
  • Forks and clones keep the old history: rotation is the only real fix once shared.

Don'ts

  • Don't paste the secret into the replacements file inside the repo or into chat.
  • Don't rotate, revoke or change real keys yourself.