Skip to content

adding customizable successRanges and rotatedRanges to customDetector#4892

Merged
jordanTunstill merged 3 commits into
mainfrom
CustomDetectorVerificationOptions
May 11, 2026
Merged

adding customizable successRanges and rotatedRanges to customDetector#4892
jordanTunstill merged 3 commits into
mainfrom
CustomDetectorVerificationOptions

Conversation

@jordanTunstill

@jordanTunstill jordanTunstill commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Description:

This would allow users to add successRanges and rotatedRanges to their customDetectors, for verification purposes, allowing them control/configuration over what is considered live/rotated for these custom detections.
If both successRanges and rotatedRanges are implemented, any response that is not within said ranges is treated as inconclusive. Here is how the change handles edge cases:
Only successRanges set: non-matching responses mean rotated
Only rotatedRanges set: non-matching responses mean live
Neither set: old behavior, only 200 means verified; other statuses are just unverified without a verification error.

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

Note

Medium Risk
Changes verification behavior for custom detectors by interpreting verifier HTTP status codes via configurable ranges and introducing new "inconclusive" verification errors, which could affect existing workflows if misconfigured. Backward compatibility is preserved when no ranges are provided, but verification outcomes and error reporting now depend on additional config.

Overview
Adds configurable HTTP status handling for custom detector webhook verification by introducing rotatedRanges alongside existing successRanges, allowing verifiers to explicitly mark secrets as live, rotated, or inconclusive based on response codes.

Updates the verifier loop to evaluate these ranges (including single-range fallbacks and legacy no-range behavior), records truncated response bodies via a shared helper, and emits a verification error when ranges are configured but no verifier returns a definitive match.

Extends the protobuf schema (VerifierConfig) and YAML parsing/validation to support rotatedRanges, adds StatusCodeMatchesRanges, and introduces focused unit tests covering parsing, range matching, mixed legacy+ranged verifiers, and edge-case status handling.

Reviewed by Cursor Bugbot for commit d12d4d9. Bugbot is set up for automated code reviews on this repo. Configure here.

@jordanTunstill jordanTunstill requested review from a team April 16, 2026 19:05
@jordanTunstill jordanTunstill requested review from a team as code owners April 16, 2026 19:05

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit be9bfc5. Configure here.

Comment thread pkg/custom_detectors/custom_detectors.go
…o that an earlier ranged verifier's rangesInEffect = true can't trigger a spurious SetVerificationError after the legacy verifier already confirmed the secret as live.
}

if rangesInEffect && !definitive {
result.SetVerificationError(fmt.Errorf("verification response status code did not match any configured successRanges or rotatedRanges"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No format args in fmt.Errorf we can use errors.New.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thank you!

storeResponseBody(resp, result.ExtraData)
break
}
continue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to set a definitive as true here before continue for legacy non 200 path.

Scenario that can trigger without this:

Verifier 1: ranged, both configured, returns 500 or any code not in ranges
  - rangesInEffect = true                                                                                                                                                                   
  - bothConfigured = true, neither range matches
  - loop continues (no break, no definitive)                                                                                                                                                
                                                                                                                                                                                              
Verifier 2: legacy (no ranges), returns 401
  - hits continue at line 327                                                                                                                                                             
  - definitive never set
          
After loop:
  - rangesInEffect = true, definitive = false
  - SetVerificationError fires

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, just made this change

@jordanTunstill jordanTunstill merged commit 37b7700 into main May 11, 2026
16 checks passed
@jordanTunstill jordanTunstill deleted the CustomDetectorVerificationOptions branch May 11, 2026 15:27
MuneebUllahKhan222 pushed a commit that referenced this pull request May 29, 2026
…#4892)

* adding customizable successRanges and rotatedRanges to customDetector

*setting definitive = true in the legacy 200 path so that an earlier ranged verifier's rangesInEffect = true can't trigger a spurious SetVerificationError after the legacy verifier already confirmed the secret as live.

* adressed review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants