diff --git a/pkg/fanal/secret/scanner.go b/pkg/fanal/secret/scanner.go index 7699ec748d42..02f99403b585 100644 --- a/pkg/fanal/secret/scanner.go +++ b/pkg/fanal/secret/scanner.go @@ -476,7 +476,10 @@ func toFinding(rule Rule, loc Location, content []byte) types.SecretFinding { } } -const secretHighlightRadius = 2 // number of lines above + below each secret to include in code output +const ( + secretHighlightRadius = 2 // number of lines above + below each secret to include in code output + maxLineLength = 2000 // +) func findLocation(start, end int, content []byte) (int, int, types.Code, string) { startLineNum := bytes.Count(content[:start], lineSep) @@ -515,8 +518,8 @@ func findLocation(start, end int, content []byte) (int, int, types.Code, string) inCause := realLine >= startLineNum && realLine <= endLineNum var strRawLine string - if len(rawLine) > 2000 { - strRawLine = lo.Ternary(inCause, matchLine, string(rawLine[:1000])) + if len(rawLine) > maxLineLength { + strRawLine = lo.Ternary(inCause, matchLine, string(rawLine[:maxLineLength])) } else { strRawLine = string(rawLine) }