Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions pkg/fanal/secret/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,12 +820,15 @@ func (s *Scanner) scanChunk(filePath string, content []byte, binary bool) types.
}

// deduplicateFindings removes duplicate secret findings that may occur at chunk boundaries
// or from multiple regex matches of the same rule on the same line.
func (s *Scanner) deduplicateFindings(findings []types.SecretFinding) []types.SecretFinding {
// Deduplicate based on rule ID and byte offset
// This accurately identifies the same secret across chunk boundaries
// Different secrets at the same offset are impossible, so this is safe
// Deduplicate based on rule ID and line range.
// Offset is intentionally excluded — same rule matching at different byte
// positions on the same line(s) produces identical code blocks and should
// be reported once. Cross-chunk overlap duplicates share the same adjusted
// StartLine/EndLine, so this also handles streaming dedup correctly.
return lo.UniqBy(findings, func(f types.SecretFinding) string {
return fmt.Sprintf("%s:%d-%d-%d", f.RuleID, f.StartLine, f.EndLine, f.Offset)
return fmt.Sprintf("%s:%d-%d", f.RuleID, f.StartLine, f.EndLine)
})
}

Expand Down