Skip to content

Add a TruffleHog dectector for Kong Konnect Platform - #5305

Merged
kashifkhan0771 merged 15 commits into
trufflesecurity:mainfrom
mrwanny:feat/add-kong-detector
Oct 6, 2026
Merged

kashifkhan0771 merged 15 commits into
trufflesecurity:mainfrom
mrwanny:feat/add-kong-detector

Conversation

@mrwanny

@mrwanny mrwanny commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Description:

Add a TruffleHog dectector for Kong Konnect Platform (api.konghq.com)

token format (?:kpat_|spat_)[a-zA-Z0-9]{49}

issue: #5306

Checklist:

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

Note

Low Risk
Additive, feature-flagged detector using the same registration and HTTP verification pattern as other API-key scanners; no changes to core scan or auth logic.

Overview
Adds Kong Konnect (DetectorType_KongKonnect, id 1072) to the default scanner set behind KongKonnectDetectorEnabled (on by default in OSS main.go).

The new detector matches Konnect personal/system access tokens with prefix kpat_ or spat_ plus 49 alphanumeric characters. When verification is enabled, it checks tokens with a Bearer request to https://global.api.konghq.com/v3/organizations/me (200 = verified, 401 = invalid) and attaches a Kong rotation-guide link in ExtraData.

Registration follows the usual path: proto enum, buildDetectorList(), feature-flag filter in defaults.go, and unit/integration/pattern tests under pkg/detectors/kong/.

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

@mrwanny
mrwanny requested a review from a team September 10, 2026 22:29
@mrwanny
mrwanny requested a review from a team as a code owner September 10, 2026 22:29
@CLAassistant

CLAassistant commented Sep 10, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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

Stale Bugbot comment from a previous run.

Comment thread pkg/engine/defaults/defaults.go Outdated

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

Stale Bugbot comment from a previous run.

Comment thread pkg/detectors/kong/kong.go

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

Stale Bugbot comment from a previous run.

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

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

Stale Bugbot comment from a previous run.

Comment thread pkg/detectors/kong/kong.go Outdated
@mrwanny
mrwanny force-pushed the feat/add-kong-detector branch from b1a4215 to ea8e739 Compare September 30, 2026 00:50
@mrwanny
mrwanny requested a review from a team as a code owner September 30, 2026 00:50
@mrwanny
mrwanny force-pushed the feat/add-kong-detector branch from ea8e739 to 5722375 Compare September 30, 2026 01:02
Comment thread pkg/engine/defaults/defaults_test.go Outdated
Comment thread proto/detector_type.proto Outdated
Comment thread pkg/detectors/kong/kong.go Outdated
case http.StatusOK:
// If the endpoint returns useful information, we can return it as a map.
return true, extraData, nil
case http.StatusForbidden:

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.

The API documentation only lists 200 and 401 as possible responses. Does the API actually return 403 for valid keys, or was that added to address the Bugbot feedback?

@mrwanny mrwanny Oct 1, 2026 •

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.

@shahzadhaider1 I was just trying to make Bugbot happy.
While at the moment the endpoint has only 200 or 401 as possible responses. It is possible that in the future it can start returning 403 too, so this would cover that incase without further changes needed.
I am happy to remove it if you prefer.

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.

Thanks for confirming. Since /organizations/me only returns 200/401 today, I'd prefer to drop the 403 case. If Konnect starts returning 403 here later, we don't know yet whether it would mean "valid but restricted" or something like a suspended org or disabled account, and treating it as verified would produce false positives. Falling through to default reports it as an unknown status with the code in the error, which is the safer outcome until we can see a real 403 response.

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.

@shahzadhaider1 , sounds good 403 case has been drop.
thanks for the feedback.

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

Stale Bugbot comment from a previous run.

Comment thread proto/detector_type.proto

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

Stale Bugbot comment from a previous run.

Comment thread pkg/engine/defaults/defaults_test.go

@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 using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 5219129. Configure here.

Comment thread pkg/detectors/kong/kong_integration_test.go Outdated

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

Great work. Thank you for the contribution!

@kashifkhan0771
kashifkhan0771 merged commit c95844e into trufflesecurity:main Oct 6, 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.

5 participants