Skip to content

Commit

Permalink
chore: add a const instead of hard-coded figures
Browse files Browse the repository at this point in the history
  • Loading branch information
afdesk committed Jul 22, 2024
1 parent 6cb43b6 commit f9baa72
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/fanal/secret/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit f9baa72

Please sign in to comment.