Repository navigation
fix(secret): detect Mailchimp API keys from every datacenter, not only us20 #11735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
1dfe4ae
3fbe25c
b1cba0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2403,6 +2403,35 @@ func TestSecretScanner(t *testing.T) { | |
| } | ||
| } | ||
|
|
||
| // 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) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other rules are tested as cases in
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| const hexPart = "3f9c2a7d1b8e4c6f0a5d9e2b7c1f4a8d" | ||
| content := strings.Join([]string{ | ||
| `MAILCHIMP_API_KEY: "` + hexPart + "-us" + "6" + `"`, | ||
|
nikpivkin marked this conversation as resolved.
Resolved
|
||
| `MAILCHIMP_API_KEY: "` + hexPart + "-us" + "20" + `"`, | ||
| // A bare 32-hex list ID and a datacenter name on their own are not keys. | ||
| `MAILCHIMP_LIST_ID: "` + hexPart + `"`, | ||
| `MAILCHIMP_SERVER: "us6"`, | ||
| }, "\n") | ||
|
|
||
| c, err := secret.ParseConfig(filepath.Join("testdata", "config.yaml")) | ||
| require.NoError(t, err) | ||
|
|
||
| s := secret.NewScanner(c) | ||
| got := s.Scan(secret.ScanArgs{ | ||
| FilePath: "mailchimp.env", | ||
| Content: strings.NewReader(content), | ||
| }) | ||
|
|
||
| var lines []int | ||
| for _, f := range got.Findings { | ||
| assert.Equal(t, "mailchimp-api-key", f.RuleID) | ||
| lines = append(lines, f.StartLine) | ||
| } | ||
| assert.Equal(t, []int{1, 2}, lines, "keys for us6 and us20 are found; the list ID and server name are not") | ||
| } | ||
|
|
||
| func TestSecretScannerWithStreaming(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.