-
Notifications
You must be signed in to change notification settings - Fork 19
fix: compliance gaps — HTTP 400 for malformed auth headers, reject unknown TOML fields, random API key generation #3097
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
Changes from all commits
801d820
0ad774a
b15a883
f144878
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 |
|---|---|---|
|
|
@@ -172,7 +172,7 @@ GITHUB_TOKEN = "mytoken" | |
| } | ||
|
|
||
| // TestLoadFromFile_UnknownKeysDoNotCauseError verifies that unknown configuration | ||
| // keys produce a warning log but do not prevent the config from loading. | ||
| // keys are rejected with an error per spec §4.3.1. | ||
| func TestLoadFromFile_UnknownKeysDoNotCauseError(t *testing.T) { | ||
| path := writeTempTOML(t, ` | ||
| [gateway] | ||
|
|
@@ -182,12 +182,11 @@ prot = 3000 | |
| command = "docker" | ||
| args = ["run", "--rm", "-i", "ghcr.io/github/github-mcp-server:latest"] | ||
| `) | ||
| // Unknown key "prot" (typo for "port") should warn but not error | ||
| // Unknown key "prot" (typo for "port") must now return an error per spec §4.3.1 | ||
| cfg, err := LoadFromFile(path) | ||
| require.NoError(t, err) | ||
| require.NotNil(t, cfg) | ||
| // Port should use default since "prot" was not recognized | ||
| assert.Equal(t, DefaultPort, cfg.Gateway.Port) | ||
| require.Error(t, err) | ||
| assert.Nil(t, cfg) | ||
| assert.Contains(t, err.Error(), "unrecognized field") | ||
|
Comment on lines
174
to
+189
|
||
| } | ||
|
|
||
| // TestLoadFromFile_TrustedBotsEmptyArray verifies that an explicitly set but | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generateRandomAPIKey() already wraps rand.Read errors with "failed to generate random API key". The caller in run() wraps the returned error with the same prefix again, which will produce duplicated text like "failed to generate random API key: failed to generate random API key: …". Consider returning the raw rand.Read error from generateRandomAPIKey (or removing the extra wrap in run()) so the error chain is not repetitive.