Skip to content

fix(secret): detect Mailchimp API keys from every datacenter, not only us20 - #11735

Open
apex-engine-dev wants to merge 3 commits into
aquasecurity:mainfrom
apex-engine-dev:fix/secret-mailchimp-datacenter
Open

apex-engine-dev wants to merge 3 commits into
aquasecurity:mainfrom
apex-engine-dev:fix/secret-mailchimp-datacenter

Conversation

@apex-engine-dev

Copy link
Copy Markdown

Description

There's no issue for this; it's a one-line regex fix, so the justification is here as pr.md allows.

The built-in mailchimp-api-key rule only matches keys ending in -us20. Mailchimp API keys end in -us<N>, where N is the account's datacenter (us1, us6, us21, …), so trivy currently misses keys from every datacenter except us20.

This changes the suffix to -us[0-9]{1,2}. The keyword and the rest of the pattern are unchanged.

Tests

New TestSecretScannerMailchimpDatacenters: a us6 key and a us20 key must both be found, while a bare 32-hex list ID and a "us6" server value must stay clean. The keys are assembled at runtime rather than stored in a testdata file, because GitHub push protection rejects key-shaped fixtures.

  • Before: the test fails — findings on line [2] only (the us6 key is missed).
  • After: passes. go test ./pkg/fanal/secret/... passes; gofmt and go vet are clean.

Checklist

@CLAassistant

CLAassistant commented Nov 25, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment thread pkg/fanal/secret/scanner_test.go Outdated

// Mailchimp API keys end in "-us<N>", where N is the account's datacenter. The
// keys are assembled at runtime so no complete key-shaped string is committed.
func TestSecretScannerMailchimpDatacenters(t *testing.T) {

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.

Other rules are tested as cases in TestSecretScanner with a fixture in testdata/. This one could be a case there too, with testdata/mailchimp-api-key.txt. If push protection blocks the fixture, you can bypass it with the "It's used in tests" reason.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I tried moving it into TestSecretScanner with testdata/mailchimp-api-key.txt, but push protection kept rejecting the fixture even after allowing both keys with the "It's used in tests" reason. So I've kept it as a separate test that assembles the keys at runtime (the other two points are done in 4c97990). If you'd prefer the fixture form, feel free to move it over, or let me know and I'll try again.

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 bypass works for fixtures. Please try once more. Open the unblock URLs from the error, choose "It's used in tests", then run the same git push again without changing the commit.

Comment thread pkg/fanal/secret/scanner_test.go Resolved
Comment thread pkg/fanal/secret/scanner_test.go Resolved
@apex-engine-dev
apex-engine-dev force-pushed the fix/secret-mailchimp-datacenter branch from 4c97990 to 3fbe25c Compare November 26, 2026 14:10
@apex-engine-dev

Copy link
Copy Markdown
Author

Thanks, that worked. Moved it into TestSecretScanner as "find Mailchimp API keys from every datacenter" with testdata/mailchimp-api-key.txt (us6 and us20 keys are found; the bare list ID and server name are not), and removed the separate test in b1cba0a.

This branch has not been deployed

No deployments
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