Skip to content

Commit d7db26f

Browse files
committed
A credential found on a branch head says which file it is in
A repository whose history is too big to walk gets its branch heads read instead, with trufflehog filesystem. That reports where a value is under SourceMetadata.Data.Filesystem, and only .Data.Git was read, so every one of those findings had no file and no line, and its link opened the repository home page instead of the file. The same pass also read .git/objects, which is the history decompressed again. Once the path was read it could name a loose object, so .git is now left out of it. The fingerprint is the value alone and ingest rewrites the location every time a finding is seen, so the findings already stored get their file, line and link on the next scan. Nothing needs repairing.
1 parent c35b2a9 commit d7db26f

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎lib/secrets.sh‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,12 @@ run_trufflehog_worktree() {
10931093
local dir="$1" full_name="$2" out="$3"
10941094
have_cmd trufflehog || { : > "$out"; return 0; }
10951095
local args=(filesystem "$dir" --json --no-update)
1096+
# The files as they are, not the history again. Left alone this also reads
1097+
# .git/objects, which is every commit decompressed, and reports a key at
1098+
# .git/objects/8e/4d0004..., a link nobody can open.
1099+
local skip="$GHSCAN_TMPROOT/trufflehog.exclude"
1100+
printf '%s\n' '(^|/)\.git/' > "$skip"
1101+
args+=(--exclude-paths "$skip")
10961102
if cfg_bool '.scan.secrets.trufflehog.verify' true; then
10971103
args+=(--results "$(cfg '.scan.secrets.trufflehog.results' 'verified,unverified,unknown')")
10981104
else
@@ -1186,7 +1192,10 @@ normalize_trufflehog() {
11861192
local in="$1" full_name="$2"
11871193
jq -c --arg repo "$full_name" --argjson alias "$(detector_alias_map)" "$JQ_CANON_DETECTOR"'
11881194
select(.DetectorName != null) |
1189-
(.SourceMetadata.Data.Git // {}) as $g |
1195+
# A history walk says where under Git, a branch-head scan under
1196+
# Filesystem. Reading only the first left every branch-head hit with no
1197+
# file and no line, so its link went to the repository home page.
1198+
(.SourceMetadata.Data.Git // .SourceMetadata.Data.Filesystem // {}) as $g |
11901199
{
11911200
engine: "trufflehog",
11921201
repository: $repo,

0 commit comments

Comments
 (0)