Skip to content

Centralize workflow repository visibility and sink overrides - #16059

Merged
lpcox merged 4 commits into
mainfrom
copilot/refactor-sink-visibility-logic
Nov 6, 2026
Merged

lpcox merged 4 commits into
mainfrom
copilot/refactor-sink-visibility-logic

Conversation

Copilot AI commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Sink-visibility enforcement duplicated a security-critical override rule, while server and proxy paths repeated workflow repository and token lookups.

  • Shared lookup: Add githubhttp.FetchWorkflowRepoVisibility for repository/token resolution; retain caller-owned API endpoints, timeouts, caching, and fallback policy.
  • Shared enforcement: Add EffectiveSinkVisibility for normalization and public-only overrides. Never relax an explicitly public sink.
  • Preserved behavior: Keep server-side omitted-visibility skips, opt-outs, explicit proxy token precedence, and fail-open handling. Cache the repository identity alongside its visibility for consistent logging.

Copilot AI changed the title [WIP] Refactor duplicated sink-visibility override logic Centralize workflow repository visibility and sink overrides Nov 6, 2026
Copilot AI requested a review from lpcox November 6, 2026 03:33
@lpcox
lpcox marked this pull request as ready for review November 6, 2026 14:57
Copilot AI adaptive review requested due to automatic review settings November 6, 2026 14:57

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

The logging changes remove a required missing-repository message, breaking an integration test, and bypass delegation redaction, exposing repository names in stderr and file logs.

2 open issues
What changed in this PR

Centralizes workflow repository visibility lookup and sink-visibility enforcement in MCP Gateway, reducing duplicated logic across server and proxy paths.

Changes:

  • Adds shared helpers for repository/token lookup and public-only sink overrides.
  • Caches repository identity alongside visibility while retaining caller-owned lookup policies.
  • Adds coverage for omitted visibility, token precedence, override rules, and shared caching.
File Description
internal/​server/​unified.go Stores repository identity, visibility, and lookup errors together.
internal/​server/​sink_visibility_test.go Verifies omitted sink visibility skips the lookup.
internal/​server/​guard_visibility.go Uses shared lookup and override helpers with server-side caching.
internal/​server/​force_public_repos_test.go Covers shared caching for successful and failed lookups.
internal/​githubhttp/​visibility.go Defines shared workflow lookup and sink-visibility decisions.
internal/​githubhttp/​visibility_test.go Tests normalization, overrides, lookup skips, and token fallback.
internal/​cmd/​proxy.go Uses the shared workflow repository lookup.
internal/​cmd/​proxy_force_public_repos_test.go Verifies explicit token and API endpoint precedence.

Review effort: Max (auto)

Comment thread internal/cmd/proxy.go Resolved
Comment thread internal/server/guard_visibility.go Resolved
lpcox and others added 2 commits November 6, 2026 07:20
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

🔒 mcpg Read-Only Stress — default

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

Part Surface Op Result Expected Status
A MCP reads data returned (issues, PRs, README.md, commits) ALLOWED ✅
B MCP writes (reaction/star/issue/comment/branch/file/PR) all 6 write tools absent from 23-tool catalog (read-only toolset only) BLOCKED ⚠️
C CLI reads data returned via github CLI proxy ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment/file) gh CLI unauthenticated (no GH_TOKEN) — could not reach GitHub API to test token-scope boundary BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) not attempted — same auth gap as Part D BLOCKED ⚠️

Overall: INCONCLUSIVE

No write leaked on any surface. Part A/C reads confirm the gateway allows reads correctly. Part B could not confirm gateway-level write enforcement because the write tools were never exposed in the catalog (backend/toolset config via gh-aw's tools.github: always launching with GITHUB_READ_ONLY=1, independent of mcpg). Parts D/E could not run because gh was unauthenticated in this environment (no GH_TOKEN), so the REST/GraphQL token-scope boundary was never exercised. These gaps are methodology limitations, not evidence of a security hole — but they mean this run does not independently confirm mcpg's own DIFC/guard write-blocking layer. Recommend a follow-up probe with an authenticated token and/or a write-capable backend toolset to directly exercise gateway enforcement.

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

@lpcox
lpcox merged commit 4180fd8 into main Nov 6, 2026
31 checks passed
@lpcox
lpcox deleted the copilot/refactor-sink-visibility-logic branch November 6, 2026 15:34
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.

[refactor] Semantic clustering: duplicated sink-visibility override logic and scattered GITHUB_REPOSITORY visibility lookups

3 participants