Repository navigation
Consolidate internal helpers and align public-repository policy overrides - #17010
Conversation
…pers Co-authored-by: copilot-swe-agent[bot] <[email protected]>
This comment has been minimized.
This comment has been minimized.
|
@copilot merge main and resolve conflicts |
There was a problem hiding this comment.
🟡 Changes recommended
Critical policy alias and casing flaws can leave private-repository access enabled or discard approved integrity and blocked-user restrictions in public workflows.
3 open issues
What changed in this PR
Addresses #16964 by consolidating internal helpers in the MCP gateway and sharing public-repository policy overrides between proxy and server paths.
Changes:
- Add config helpers for typed and raw policy overrides, leaving write-sink-only policies unchanged.
- Replace redundant wrappers, mount adapters, and locking logic with shared implementations.
- Update regression tests and documentation while retaining ASCII-only repository-scope folding.
| File | Description |
|---|---|
internal/sys/docker.go |
Remove the unused host-network helper. |
internal/sys/docker_test.go |
Test the retained helper, including case-insensitive matching. |
internal/syncutil/registry.go |
Delegate registry creation to MapGetOrCreate. |
internal/syncutil/registry_test.go |
Add zero-value caching coverage. |
internal/syncutil/registry_internal_test.go |
Adapt concurrent-miss tests to the public method. |
internal/server/system_tools.go |
Use the shared MCP text-response constructor. |
internal/server/guard_visibility.go |
Call config helpers for public-scope overrides. |
internal/server/circuit_breaker_test.go |
Migrate text-response fixtures to the shared constructor. |
internal/proxy/proxy.go |
Use the shared text-response constructor. |
internal/proxy/graphql.go |
Remove the test-only alias-detection wrapper. |
internal/proxy/graphql_aliased_pr_test.go |
Call the parsed alias-detection helper directly. |
internal/middleware/jqschema_test.go |
Update the MCP response fixture constructor. |
internal/mcpresult/mcpresult.go |
Correct the constructor name in a comment. |
internal/mcp/tool_result.go |
Remove the redundant text-response wrapper. |
internal/mcp/tool_result_test.go |
Migrate fixtures and remove wrapper-only tests. |
internal/logger/write_json_to_file_test.go |
Update test names and atomic-write comments. |
internal/logger/observed_url_domains_logger_test.go |
Update helper names in test comments. |
internal/logger/fileutil.go |
Call util.AtomicWriteFile directly. |
internal/logger/atomic_write_test.go |
Delete redundant wrapper tests. |
internal/launcher/mount_policy.go |
Use mountspec.Parse and its shared type directly. |
internal/launcher/mount_policy_test.go |
Exercise parser failures through ValidateMount. |
internal/difc/path_labels_test.go |
Rename the text-response subtest. |
internal/config/guard_policy_string_validation_test.go |
Add ASCII-only folding regression coverage. |
internal/config/guard_policy_public.go |
Add typed and raw-map public-scope helpers. |
internal/config/guard_policy_public_test.go |
Cover overrides, aliases, and write-sink preservation. |
internal/cmd/proxy.go |
Replace duplicated policy mutation with the config helper. |
internal/cmd/proxy_force_public_repos_test.go |
Add write-sink-only policy preservation coverage. |
docs/PROXY_MODE.md |
Clarify force-public behavior for policy types. |
Review effort: Max (adaptive)
| } | ||
| for _, key := range allowOnlyKeys { | ||
| if allowOnly, ok := raw[key].(map[string]interface{}); ok && allowOnly != nil { | ||
| allowOnly["repos"] = policy.AllowOnly.Repos |
| raw[key] = map[string]interface{}{ | ||
| "repos": policy.AllowOnly.Repos, | ||
| "min-integrity": IntegrityNone, | ||
| } |
| "min-integrity": config.IntegrityNone, | ||
| } | ||
| } else { | ||
| if !config.ForcePublicReposInMap(serverCfg.GuardPolicies) { |
…ntic-function-clustering # Conflicts: # internal/logger/observed_url_domains_logger_test.go # internal/logger/write_json_to_file_test.go # internal/mcp/tool_result_test.go # internal/proxy/graphql_aliased_pr_test.go # internal/server/circuit_breaker_test.go # internal/sys/docker_test.go Co-authored-by: copilot-swe-agent[bot] <[email protected]>
|
@copilot merge main and resolve conflicts then address all review feedback |
Merged |
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
|
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No reaction, star, issue, comment, branch, file, or PR was created in any part of this test; no writes leaked.
|

Force-public policy mutation was duplicated across proxy and server layers; the proxy could add allow-only to a write-sink-only policy, creating an invalid combination. Several internal helpers also duplicated shared implementations or existed only for tests.
Policy overrides
Helper consolidation
MapGetOrCreateand mount parsing tomountspec.Parse.Preserved semantics