Skip to content

Unify force-public-repos gating across gateway and proxy - #17149

Merged
lpcox merged 4 commits into
mainfrom
copilot/duplicate-code-force-public-repos
Nov 23, 2026
Merged

lpcox merged 4 commits into
mainfrom
copilot/duplicate-code-force-public-repos

Conversation

@lpcox

@lpcox lpcox commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

The gateway and CLI proxy duplicated the force-public-repos decision, with divergent failure reporting. The proxy also ignored the gateway’s config-file opt-out.

  • Shared gate: Centralize opt-out checks and public-visibility detection in config.ShouldForcePublicRepos. Config, environment, or CLI false disables forcing—even when another source explicitly enables it.
  • Proxy configuration: Add optional --config support using the validated gateway TOML loader; consume only gateway.force_public_repos.
    [gateway]
    force_public_repos = false
  • Preserved behavior: Keep gateway-lifetime visibility caching, existing policy-override helpers, write-sink exclusions, and unchanged policies on lookup failure.

@lpcox lpcox changed the title [WIP] Fix duplicate code pattern for force-public-repos gate Unify force-public-repos gating across gateway and proxy Nov 23, 2026
@lpcox
lpcox marked this pull request as ready for review November 23, 2026 05:03
Copilot AI adaptive review requested due to automatic review settings November 23, 2026 05:03
@github-actions

This comment has been minimized.

@lpcox

lpcox commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical logging regressions suppress skipped-check diagnostics when DEBUG is unset and omit lookup-failure causes, breaking existing integration log assertions.

1 open issue
What changed in this PR

Centralizes the public-repository policy gate used by the MCP gateway and standalone proxy, addressing #17142 and making their opt-out behavior consistent.

Changes:

  • Adds a shared gate where any config, environment, or CLI opt-out disables forcing.
  • Adds proxy --config / -c support through the validated gateway TOML loader.
  • Expands tests and documentation while preserving gateway-lifetime visibility caching and existing policy overrides.
File Description
internal/​server/​guard_visibility.go Uses the shared gate while retaining visibility caching.
internal/​server/​force_public_repos_test.go Verifies opt-outs skip visibility lookups.
internal/​config/​guard_policy_public.go Defines the shared force-public-repos decision.
internal/​config/​guard_policy_public_test.go Covers opt-out precedence, visibility results, and lookup failures.
internal/​cmd/​proxy.go Loads optional TOML config and uses the shared gate.
internal/​cmd/​proxy_force_public_repos_test.go Tests proxy opt-outs and config loading; updates existing cases.
docs/​PROXY_MODE.md Documents the config flag, opt-out precedence, and lookup lifetime.

Review effort: Max (adaptive)

Comment thread internal/config/guard_policy_public.go Resolved

Copilot AI commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

@copilot fix the failing lint check https://github.com/github/gh-aw-mcpg/actions/runs/45111493589/job/137496884135?pr=17149

Fixed the testifylint failure by comparing the policy JSON with assert.JSONEq. Lint and the full verification target pass; commit: 1b71846.

@github-actions

This comment has been minimized.

Updated logging statements to use logger.LogInfo and logger.LogWarn for better error handling.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🔒 mcpg Read-Only Stress — default

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default AWF (normal container isolation)

Part Surface Op Result Expected Status
A MCP reads data ALLOWED ✅
B MCP writes (reaction/star/issue/comment/branch/file/PR) all 6 write tools absent from catalog BLOCKED ⚠️
C CLI reads data ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) gh CLI unauthenticated BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh CLI unauthenticated BLOCKED ⚠️

Overall: INCONCLUSIVE

⚠️ Part B: none of add_issue_comment/star_repository/issue_write/create_branch/create_or_update_file/create_pull_request appeared in the exposed 23-tool catalog (all read-only). This confirms backend/toolset read-only config but could not independently exercise the gateway's own write-blocking layer.
⚠️ Parts D/E: gh auth status reported not logged in (You are not logged into any GitHub hosts), so the token-scope boundary for proxied CLI/GraphQL writes could not be validated this run.

No writes leaked. No artifacts created/modified.

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

@lpcox
lpcox merged commit 43a801b into main Nov 23, 2026
28 checks passed
@lpcox
lpcox deleted the copilot/duplicate-code-force-public-repos branch November 23, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[duplicate-code] Duplicate Code Pattern: Force-Public-Repos Gate Duplicated Between Server and CLI Proxy

3 participants