Skip to content

Commit

Permalink
Merge pull request #57 from bricks-cloud/redact-bug
Browse files Browse the repository at this point in the history
fix bug where regex redaction is run even when there isn't a match
  • Loading branch information
spikelu2016 authored May 9, 2024
2 parents 9de7e3e + 281ef2d commit 8534708
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 8534708

Please sign in to comment.