Repository navigation
[test] Add tests for proxyHandler.validateReadOnlyRequest - #16471
Conversation
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The test does not observe whether the request body is read before enclave-mode rejection, so a regression in the ordering could still pass.
1 open issue
What changed in this PR
Adds focused unit coverage for (*proxyHandler).validateReadOnlyRequest, covering unsafe paths, restricted modes, request-body handling, supported REST reads, and GraphQL operation selection. Production behavior is unchanged.
Changes:
- Adds table-driven tests for unsafe paths, alternate-mode restrictions, missing or unreadable bodies, and REST body rejection.
- Verifies supported REST reads are accepted without a body.
- Verifies GraphQL requests retain only the selected operation.
| File | Description |
|---|---|
| internal/proxy/validate_read_only_request_test.go | Adds table-driven tests covering read-only request validation, request-body handling, REST read acceptance, and GraphQL operation filtering. |
Review effort: Lite (dynamic)
| name: "rejects graphql in enclave mode before reading body", | ||
| mode: "enclave", | ||
| request: func() *http.Request { | ||
| return httptest.NewRequest(http.MethodPost, "http://example.test/graphql", strings.NewReader("not read")) |
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
|
|
@copilot address review feedback |
Co-authored-by: lpcox <[email protected]>

Function Analyzed
internal/proxy(*proxyHandler).validateReadOnlyRequestWhy This Function?
This is the read-only proxy's request-shape security boundary. It fail-closed rejects unsafe raw paths, alternate-mode GraphQL requests, missing or unreadable GraphQL bodies, and REST bodies before forwarding, while allowing supported read requests and selecting only the authorized GraphQL operation.
Tests Added
Coverage Report
The full
go test -coverprofile=coverage.out ./...run passed; the proxy package measured 96.7% coverage and the reported total was 97.5%.Test Execution
Passed:
go test ./internal/proxy -run '^TestProxyHandlerValidateReadOnlyRequest$' -count=1 -vgo test -coverprofile=coverage.out ./...go vet ./...make agent-finishedGo formatting, build, unit, and integration stagesThe final
make agent-finishedRust guard stage could not downloadserdebecause the sandbox crates.io TLS/SNI certificate does not matchindex.crates.io; golangci-lint was also unavailable and skipped by the repository Makefile. No production code or behavior was changed, and there are no breaking changes.Warning
Firewall blocked 4 domains
The following domains were blocked by the firewall during workflow execution:
example.comnonexistent.localslow.example.comthishostdoesnotexist12345.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.