Files
Kashif KhanandNicholas Comer e1f9e5d1d5 Update Cloudflare detectors for 2026+ prefixed credential formats (include upstream PR changes) (#5111)
* Update Cloudflare detectors for 2026+ prefixed credential formats

 ## Context/Background

Cloudflare is rolling out new prefixed credential formats in 2026.
The new formats (`cfk_`, `cfut_`, `cfat_`) are self-identifying via
prefix and do not need keyword proximity matching. Per project
convention, new token formats are added via the `Versioner` interface
with a `v1`/`v2` directory split.

Additionally, CA keys (Service Keys) are now deprecated.

 ## Changes in this commit

- cloudflareglobalapikey: split into `v1`/`v2` with `Versioner`
  interface. v1 fixes legacy regex to `[a-f0-9]{37,45}` (lowercase
  hex). v2 adds `cfk_` prefixed format detection.
- cloudflareapitoken: split into `v1`/`v2` with `Versioner`
  interface. v2 adds `cfut_`/`cfat_` prefixed format detection.
  `cfat_` (account tokens) route verification through the
  account-scoped `/accounts/:id/tokens/verify` endpoint, extracting
  account IDs from surrounding data.
- cloudflarecakey: add deprecation notice with changelog link.
- defaults.go: updated imports and registrations for versioned
  scanners.

* Address PR feedback on Cloudflare detectors

 ## Context/Background

Addressing reviewer feedback from @MuneebUllahKhan222 and Cursor
Bugbot on PR #4830.

 ## Changes in this commit

- Verification functions now return `(bool, error)` with proper
  indeterminate/determinate handling. Callsites use
  `SetVerificationError`. Status checks use exact `http.StatusOK`
  instead of range. Response bodies properly drained via
  `io.Copy(io.Discard, ...)`.
- Extracted shared verification functions into `common.go` at each
  detector package root (following the AWS detector pattern). v1 and
  v2 both import from the parent package instead of v2 importing v1.
- Added integration tests for both v2 detectors with coverage for
  `cfk_`, `cfut_`, and `cfat_` (including account-scoped
  verification).
- `cfat_` tokens now pair with account IDs in `RawV2` regardless of
  the `verify` flag, consistent with how `cfk_` pairs with emails.

* Resolved Comments

---------

Co-authored-by: Nicholas Comer <[email protected]>
2026-07-15 11:14:06 +05:00
..