Skip to content

Commit

Permalink
Return early if the context is canceled
Browse files Browse the repository at this point in the history
  • Loading branch information
mcastorina committed Dec 5, 2022
1 parent 06957fc commit f7e59d7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/custom_detectors/custom_detectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func (c *customRegexWebhook) FromData(ctx context.Context, verify bool, data []b

// Create result object and test for verification.
for _, match := range matches {
if common.IsDone(ctx) {
// TODO: Log we're possibly leaving out results.
return results, nil
}
var raw string
for _, values := range match {
// values[0] contains the entire regex match.
Expand All @@ -105,6 +109,10 @@ func (c *customRegexWebhook) FromData(ctx context.Context, verify bool, data []b
}
// Try each config until we successfully verify.
for _, verifyConfig := range c.GetVerify() {
if common.IsDone(ctx) {
// TODO: Log we're possibly leaving out results.
return results, nil
}
req, err := http.NewRequestWithContext(ctx, "POST", verifyConfig.GetEndpoint(), bytes.NewReader(jsonBody))
if err != nil {
continue
Expand Down

0 comments on commit f7e59d7

Please sign in to comment.