Skip to content

[INS-332] Add New Relic Insights Insert key detector - #4778

Merged
mustansir14 merged 13 commits into
trufflesecurity:mainfrom
mustansir14:INS-332-Detector-Visible-New-Relic-Insights-Insert-Key
Jul 7, 2026
Merged

[INS-332] Add New Relic Insights Insert key detector#4778
mustansir14 merged 13 commits into
trufflesecurity:mainfrom
mustansir14:INS-332-Detector-Visible-New-Relic-Insights-Insert-Key

Conversation

@mustansir14

@mustansir14 mustansir14 commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

Description:

This PR adds the New Relic Insights Insert Key Detector.

Regex: \b(NRII-[a-zA-Z0-9-_]{25})
Note: We haven't added a trailing \b because having that causes secrets ending with - to not be matched.

Verification:
For verification, we use the Events API: https://insights-collector.newrelic.com/v1/accounts/{account_id}/events.
We use a dummy placeholder (nowaythiscanexist) in place of account ID.
We send a POST request with an empty body to this endpoint. A response code of 200 means the key is valid. 403 means it is an invalid/rotated key.
Note: For EU region keys, the host should be insights-collector.eu01.nr-data.net

Corpora Test:
The detector does not appear in the list.
image
image

Checklist:

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

Note

Medium Risk
Enables live outbound verification against New Relic with discovered keys and expands default scan surface via a new gated detector; behavior matches existing detector rollout patterns.

Overview
Adds New Relic Insights Insert Key (NRII-…) detection and optional verification against the Insights Event API in US and EU, recording region in extra data when a key validates.

The new newrelicinsightsinsertkey scanner matches \b(NRII-[a-zA-Z0-9-_]{25}) (no trailing word boundary so keys ending in - still match), pre-filters on nrii-, and verifies with an empty-body POST and X-Insert-Key to collector URLs using a placeholder account id (nowaythiscanexist); 200 vs 403 drives verified vs invalid.

Wiring follows other gated detectors: proto type 1058, registration in buildDetectorList(), NewRelicInsightsInsertKeyDetectorEnabled (on by default in main.go), and listing under feature-flag exclusions in defaults_test.go. Unit and integration tests cover pattern matching and live verification (US/EU/inactive).

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

@mustansir14
mustansir14 requested review from a team February 27, 2026 17:06
@mustansir14
mustansir14 requested a review from a team as a code owner February 27, 2026 17:06
@mustansir14 mustansir14 changed the title add new relic insights insert key detector [INS-332] Add New Relic Insights Insert key detector Feb 27, 2026
func (s Scanner) verify(ctx context.Context, key string) (bool, map[string]string, error) {
regionUrls := map[string]string{
"us": "https://insights-collector.newrelic.com/v1/accounts/`nowaythiscanexist/events",
"eu": "https://insights-collector.eu01.nr-data.net/v1/accounts/`nowaythiscanexist/events",

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.

Stray backtick character in verification API URLs

High Severity

Both verification URLs contain a stray backtick character before nowaythiscanexist in the account ID path segment. The URLs read .../accounts/ `nowaythiscanexist/events` instead of .../accounts/nowaythiscanexist/events. This backtick (likely copied from the PR description's markdown formatting) becomes a literal character in the Go double-quoted string, making the verification requests go to an incorrect path. This will likely cause verification to always fail or return unexpected status codes.

Fix in Cursor Fix in Web

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.

It is intentional. It is done to ensure the account ID never exists. I've tested this and the API returns with a 200 for a valid key and 403 for an invalid/rotated key.

@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.

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

Comment thread pkg/detectors/newrelicinsightsinsertkey/newrelicinsightsinsertkey.go Outdated

@MuneebUllahKhan222 MuneebUllahKhan222 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.

LGTM!

@mustansir14
mustansir14 requested a review from a team July 7, 2026 05:49
@mustansir14
mustansir14 merged commit 67339b2 into trufflesecurity:main Jul 7, 2026
16 checks passed
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.

4 participants