fix: reject mangled publisher metadata (#1310)
## Summary - add a publisher preflight that rejects non-UTF-8 `server.json` bytes before parsing - reject unpaired UTF-16 surrogate escapes inside JSON string fields before publish/validate requests are sent - keep valid non-ASCII descriptions, including em dashes, round-tripping through the publish path - make the publisher test token helper set `USERPROFILE` as well as `HOME` so Windows tests use the temp home directory Closes #1306. ## To verify - `go test ./cmd/publisher/commands -run "TestPublishCommand_(Success|PreservesNonASCIIDescription|RejectsInvalidUTF8ServerJSON|RejectsUnpairedSurrogateEscape)$" -count=1` - `go test ./cmd/publisher/commands -run TestPublishCommand -count=1` - `go test ./cmd/publisher/commands -run TestValidateCommand -count=1` - `git diff --check` Co-authored-by: Radoslav Dimitrov <radoslav@stacklok.com>
This commit is contained in:
parent
2d3262c8aa
commit
c36b521bf1
1 changed files with 190 additions and 1 deletions
|
|
@ -68,9 +68,10 @@ func SetupMockRegistryServer(t *testing.T, publishHandler func(w http.ResponseWr
|
|||
func SetupTestToken(t *testing.T, registryURL, token string) string {
|
||||
t.Helper()
|
||||
|
||||
// Override $HOME so tokenFilePath() resolves to a temp directory
|
||||
// Override the home directory so tokenFilePath() resolves to a temp directory.
|
||||
tempHome := t.TempDir()
|
||||
t.Setenv("HOME", tempHome)
|
||||
t.Setenv("USERPROFILE", tempHome)
|
||||
|
||||
dir := filepath.Join(tempHome, ".config", "mcp-publisher")
|
||||
require.NoError(t, os.MkdirAll(dir, 0700))
|
||||
|
|
|
|||
Loading…
Reference in a new issue