Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
[tempfix] - add bounds check check to avoid panics (#3867)
ahrav0fede8267b34
diff --git a/pkg/engine/ahocorasick/ahocorasickcore.go b/pkg/engine/ahocorasick/ahocorasickcore.goindex 9ec2da626..c6f97da14 100644--- a/pkg/engine/ahocorasick/ahocorasickcore.go+++ b/pkg/engine/ahocorasick/ahocorasickcore.go@@ -99,6 +99,14 @@ func (m *adjustableSpanCalculator) calculateSpan(params spanCalculationParams) mstartIdx := max(startOffset, 0)endIdx := min(maxSize, int64(len(params.chunkData)))+ // Ensure the start index is not greater than the end index to prevent invalid spans.+ // In rare cases where the calculated start index exceeds the end index (possibly due to+ // detector-provided offsets), we reset the start index to 0 to maintain a valid span range+ // and avoid runtime panics. This is a temporary fix until the root cause is identified.+ if startIdx >= endIdx {+ startIdx = 0+ }+return matchSpan{startOffset: startIdx, endOffset: endIdx}}