8000 fix(secret): use only line with secret for long secret lines by DmitriyLewen · Pull Request #7412 · aquasecurity/trivy · GitHub
[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(secret): use only line with secret for long secret lines #7412

Merged
merged 2 commits into from
Aug 29, 2024
Merged
Changes from 1 commit
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
Next Next commit
fix(secret): use lineStart and lineEnd
  • Loading branch information
DmitriyLewen committed Aug 28, 2024
commit 9471e84dc524b4986acbfe67e646c1a70839fb25
4 changes: 2 additions & 2 deletions pkg/fanal/secret/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,8 @@ func findLocation(start, end int, content []byte) (int, int, types.Code, string)
}

if lineEnd-lineStart > 100 {
lineStart = lo.Ternary(start-30 < 0, 0, start-30)
lineEnd = lo.Ternary(end+20 > len(content), len(content), end+20)
lineStart = lo.Ternary(start-lineStart-30 < 0, lineStart, start-30)
lineEnd = lo.Ternary(end+20 > lineEnd, lineEnd, end+20)
}
matchLine := string(content[lineStart:lineEnd])
endLineNum := startLineNum + bytes.Count(content[start:end], lineSep)
Expand Down
0