Skip to content

Commit

Permalink
fix bug where regex redaction is run even when there isn't a match
Browse files Browse the repository at this point in the history
  • Loading branch information
donfour committed May 9, 2024
1 parent 9de7e3e commit 281ef2d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,11 +744,13 @@ func (p *Policy) scan(input []string, scanner Scanner, cd CustomPolicyDetector,
continue
}

if sr.Action != Block && sr.Action != AllowButWarn {
sr.Action = AllowButRedact
}
if regex.MatchString(text) {
replaced = regex.ReplaceAllString(text, "***")

replaced = regex.ReplaceAllString(text, "***")
if sr.Action != Block && sr.Action != AllowButWarn {
sr.Action = AllowButRedact
}
}
}
}

Expand Down

0 comments on commit 281ef2d

Please sign in to comment.