DocsStart here
How it works
Secret Sleuth does not just report secrets. A full scan changes your working tree and how git treats it, so it pays to know the model before you run it.
What a full scan does to a flagged file
As committed--dry-run marks it
"ConnectionStrings": {
"DefaultConnection": "Server=sql-02;…;Password=Wint3r!"
},
"SendGrid": { "ApiKey": "SG.f3Kq9vXbT2…" }
After --full-scansealed and guarded
"ConnectionStrings": {
"DefaultConnection": "DO_NOT_COMMIT_CONNSTR"
},
"SendGrid": { "ApiKey": "DO_NOT_COMMIT_APIKEY" }
Synthetic values. The syntax and quotes stay exactly as they were, so the file still parses.
| After a full scan, a flagged file is… | What that means for you |
|---|---|
| Rewritten on disk | Each secret value is replaced with a DO_NOT_COMMIT_* placeholder. The real values are still in git HEAD, which is how they can be restored. Untracked files have no HEAD copy, so they are backed up to ~/.ironforge-secretsleuth/backups/ first. |
Marked skip-worktree when tracked | Git treats a tracked file as unchanged. Your edits to it do not appear in git status or VS Code, and git add refuses it with a confusing “outside of your sparse-checkout definition” message. Use stage to commit edits. Untracked files cannot be marked skip-worktree; the pre-commit hook still blocks staged placeholders in them. |
| Guarded by a pre-commit hook | Nothing whose staged content holds a placeholder can be committed. |
Not runnable locally until you run the generated setup-dev-secrets script | The app reads the real values from user secrets or a local store instead. See Local dev secrets. |
The first full scan of a repository explains this and asks you to confirm (--yes skips the question). A --dry-run does not change scanned files, Git protection, or the manifest. It still writes a report and, when findings exist and dev-secrets generation is enabled, a setup script under the profile by default. An explicit --report path inside the repository writes the report and setup script there.
The three guards
skip-worktreeon every obfuscated, tracked file. Untracked files cannot use this protection. Agit pullorgit checkoutthat would overwrite a tracked protected file fails loudly instead of silently restoring the real secret.post-mergehook. After every merge it checks that the files listed in.git/ironforge-protectedstill hold their placeholders, and warns (prompting a re-scan) when a merge restored a secret or changed a config file.pre-commithook. Blocks any commit whose staged content containsDO_NOT_COMMIT_, including placeholders in untracked files. It checks what is staged, not the file on disk, so committing your own edit or remediated safe value in a protected file viastageworks.
Existing hooks are never overwritten: they are renamed to <hook>.ifss-backup and still run after the Secret Sleuth check. restore --remove-hooks puts them back.
I want to…
All commands default --repo to the current folder. Run <command> --help for every option.
| I want to… | Run |
|---|---|
| See what would be found, changing nothing | SecretSleuth --dry-run |
| Obfuscate and protect a repo | SecretSleuth --full-scan |
| Check whether everything is in order | SecretSleuth status |
| Pull the current branch | SecretSleuth pull |
| Switch branch (and pull) | SecretSleuth branch-switch --to main --pull |
| Commit my edits to a protected file | SecretSleuth stage --file appsettings.json |
| Put the real values back in some files | SecretSleuth restore --file <path> |
| Undo everything Secret Sleuth did | SecretSleuth restore --all --remove-hooks |
| Track remediation | SecretSleuth remediate --list |
Never use plain git pull or git checkout <branch> on a protected repo
Use pull and branch-switch. They put the real values back first, refuse to throw away your own edits, and re-protect afterwards.
Safety first
- Run
--dry-runfirst on a clean branch. - Treat detected secrets as compromised and rotate them.
- Cleaning the current files is not cleaning history.
- Learn the two commands that get you out of trouble before you need them:
statusandrestore --all --remove-hooks.