Scan git history for removed secrets - #935
Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit intoJul 23, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in “git history only” secrets scan mode that surfaces secrets removed from the working tree but still present in reachable Git history, and emits these findings under a distinct SARIF tool name/run.
Changes:
- Extend
SecretResultwith history metadata (is_git_history_only, introducing SHA, removal SHA) and helper cloning for per-path fan-out. - Add SARIF support for distinct tool driver names and splitting into multiple runs (static vs. secrets-history) when in history mode.
- Implement two-pass history scanning in the binary crate (scan all unique blobs, then attribute secret-bearing blobs to paths/commits) and add
--scan-git-history-onlyCLI flag plus tests.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/secrets/src/scanner.rs | Initialize new history-related fields on normal secret findings. |
| crates/secrets/src/model/secret_result.rs | Add history metadata fields and a path-cloning helper for blob→path fan-out. |
| crates/cli/src/sarif/sarif_utils.rs | Add per-finding history info, make tool name configurable, and split SARIF into separate runs in history mode (with tests). |
| crates/cli/src/constants.rs | Introduce tool-name constants and SARIF property keys for history metadata. |
| crates/bins/src/lib.rs | Implement two-pass Git history secrets scan (blob scan + attribution) and add targeted tests. |
| crates/bins/src/bin/datadog-static-analyzer.rs | Add --scan-git-history-only flag and wire it into secrets execution + SARIF metadata. |
| crates/bins/src/bin/datadog-static-analyzer-git-hook.rs | Populate new SARIF metadata tool_name field. |
| crates/bins/Cargo.toml | Add tempfile dev-dependency for Git history tests. |
| Cargo.lock | Lockfile update for tempfile. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🎯 Code Coverage (details) 🔗 Commit SHA: 593bb45 | Docs | Datadog PR Page | Give us feedback! |
MikaYuoadas
force-pushed
the
akim.sadaoui/git-history-scanning
branch
from
July 8, 2026 11:44
142014a to
04ed463
Compare
MikaYuoadas
force-pushed
the
akim.sadaoui/git-history-scanning
branch
from
July 21, 2026 20:13
04ed463 to
0578d22
Compare
MikaYuoadas
force-pushed
the
akim.sadaoui/git-history-scanning
branch
from
July 22, 2026 12:36
0578d22 to
4cd7945
Compare
MikaYuoadas
force-pushed
the
akim.sadaoui/git-history-scanning
branch
from
July 23, 2026 09:09
4cd7945 to
a211a6b
Compare
Add a --scan-git-history-only flag that make secrets scan only return secrets found in files that existed in past commits but are no longer present at the branch HEAD. The scan runs in two passes: - Pass 1: scans every unique blob in the object database once. - Pass 2: attributes only the blobs that contained a secret back to their (path, introducing commit, removal commit) by streaming a single `git log --raw` over all branches. A blob with no reachable add on any branch is dropped. Publish in a separate SARIF runs with `datadog-static-analyzer-secrets-history` tool driver.
MikaYuoadas
force-pushed
the
akim.sadaoui/git-history-scanning
branch
from
July 23, 2026 12:18
a211a6b to
593bb45
Compare
gh-worker-dd-mergequeue-cf854d
Bot
deleted the
akim.sadaoui/git-history-scanning
branch
July 23, 2026 13:02
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
--scan-git-history-onlyflag to the secrets scanner. When enabled, the scan reports secrets that existed in past commits but are no longer present at the branch HEAD.The scan runs in two passes:
git log --rawover all branches. A blob with no reachable addition on any branch is dropped.Historic findings are published in a separate SARIF run under the
datadog-static-analyzer-secrets-historytool driver, so they stay distinct from the regular HEAD scan results.Why
Secrets that were committed and later deleted still live in the repository history and can be recovered by anyone with a clone. A HEAD-only scan never surfaces them. This flag lets a scan cover that gap without slowing down or altering the normal HEAD scan, which continues to run as before.
Notes