Skip to content

Commit

Permalink
safer out of bounds (#1135)
Browse files Browse the repository at this point in the history
  • Loading branch information
zricethezav committed Mar 29, 2023
1 parent 9c6650d commit 56079dc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions detect/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,14 @@ func printFinding(f report.Finding) {
Italic(true).
Foreground(lipgloss.Color("#f05c07"))
matchEnd := lipgloss.NewStyle().SetString(f.Match[secretInMatchIdx+len(f.Secret):]).Foreground(lipgloss.Color("#f5d445"))

lineEndIdx := matchInLineIDX + len(f.Match)
if len(f.Line)-1 <= lineEndIdx {
lineEndIdx = len(f.Line) - 1
}

lineEnd := f.Line[matchInLineIDX+len(f.Match):]

if len(f.Secret) > 100 {
secret = lipgloss.NewStyle().SetString(f.Secret[0:100] + "...").
Bold(true).
Expand Down

0 comments on commit 56079dc

Please sign in to comment.