Skip to content

Centralize allow-only repos normalization - #17148

Merged
lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-allow-only-repos
Nov 23, 2026
Merged

lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-allow-only-repos

Conversation

@lpcox

@lpcox lpcox commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Allow-only repos validation duplicated type switches across policy loading and WASM payload construction, allowing acceptance rules and errors to drift. WASM payloads also validated each value twice.

  • Normalization: Route NormalizeGuardPolicy through NormalizeAllowOnlyReposValue; convert []string once into the shared array-validation path.
  • Callers: Remove the WASM pre-check. Retain IsValidAllowOnlyReposValue as a delegating wrapper, now consistent for []string.
  • Regression coverage: Check equivalent outputs and errors across input types, including typed nil slices, normalized duplicates, and non-ASCII scopes.

@lpcox lpcox changed the title [WIP] Refactor duplicate repos type switch in guard policy validation Centralize allow-only repos normalization Nov 23, 2026
@lpcox
lpcox marked this pull request as ready for review November 23, 2026 05:02
Copilot AI adaptive review requested due to automatic review settings November 23, 2026 05:02

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.

🟢 Approval recommended

No active review issues are reported for the change centralizing allow-only repos normalization.

No open issues 🎉

What changed in this PR

Centralizes allow-only repos normalization so policy loading and WASM payload construction share validation rules and error messages, addressing #17141.

Changes:

  • Routes policy normalization and the validity wrapper through one helper, with a shared array-validation path.
  • Removes redundant validation during WASM payload construction.
  • Expands regression coverage for input types, typed nil slices, normalized duplicates, and non-ASCII scopes.
File Description
internal/​guard/​wasm_payload.go Removes the redundant repos validation pre-check.
internal/​guard/​wasm_payload_test.go Adds normalization and validation-error cases.
internal/​guard/​guard_test.go Updates the expected empty-array error.
internal/​config/​guard_policy_validation.go Centralizes repos normalization and array handling.
internal/​config/​guard_policy_test.go Aligns the expected unsupported-type error.
internal/​config/​guard_policy_string_validation_test.go Updates validity expectations for string slices.
internal/​config/​guard_policy_normalize_repos_test.go Checks consistent outputs and errors across normalization entry points.

Review effort: Balanced (adaptive)

@github-actions

Copy link
Copy Markdown
Contributor

🔒 mcpg Read-Only Stress — default AWF

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 (list_issues, list_pull_requests, get_file_contents, list_commits) data returned ALLOWED ✅
B MCP writes (star_repository, issue_write, add_issue_comment, create_branch, create_or_update_file, create_pull_request) all 7 targets absent from tool catalog ("unknown tool") BLOCKED ⚠️
C CLI reads (github list_issues) data returned ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) gh CLI not authenticated, not attempted BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh CLI not authenticated, not attempted BLOCKED ⚠️

Overall: INCONCLUSIVE

No write leaked through any surface. Part B is INCONCLUSIVE because all targeted write tools (star_repository, issue_write, add_issue_comment, create_branch, create_or_update_file, create_pull_request) are entirely absent from the GitHub MCP tool catalog exposed to this workflow — this reflects gh-aw's own tools.github: wrapper forcing GITHUB_READ_ONLY=1 at the backend, not an independent mcpg gateway-level refusal, so it cannot confirm mcpg's own DIFC/guard write-blocking layer. Parts D/E are INCONCLUSIVE because the gh CLI is not authenticated in this environment ("You are not logged into any GitHub hosts"), so the REST/GraphQL token-scope boundary could not be exercised this run.

Full Report

Part A detail: All 4 MCP reads (list_issues, list_pull_requests, get_file_contents README.md, list_commits) against github/gh-aw-mcpg returned valid JSON data via the gateway-backed github CLI bridge.

Part B detail: Catalog discovery (github --help) listed only 23 read-oriented tools (get_commit, get_file_contents, get_label, get_latest_release, get_release_by_tag, get_tag, issue_read, list_branches, list_commits, list_issue_fields, list_issue_types, list_issues, list_pull_requests, list_releases, list_repository_collaborators, list_starred_repositories, list_tags, pull_request_read, search_code, search_commits, search_issues, search_pull_requests, search_repositories). None of the 7 targeted write tools appeared; each call returned Error [-32602]: unknown tool "<name>". Per the test's own validation criteria, this is recorded as INCONCLUSIVE rather than PASS since it only proves backend/toolset configuration, not the gateway's independent write-blocking layer.

Part C detail: github list_issues --owner github --repo gh-aw-mcpg --perPage 2 returned valid JSON over the proxied CLI.

Part D/E detail: gh auth status reported "You are not logged into any GitHub hosts." No REST or GraphQL write attempts were made since the authentication gap alone makes any result non-diagnostic (an unauthenticated 401 is not evidence of gateway/token-scope enforcement).

No artifacts were created, no reactions/stars applied, no comments posted, no branches/files/PRs created. Results saved to /tmp/gh-aw/agent/readonly-stress-45111492511.txt and /tmp/gh-aw/agent/readonly-stress-result-45111492511.txt.

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

@lpcox
lpcox merged commit d6facfa into main Nov 23, 2026
37 checks passed
@lpcox
lpcox deleted the copilot/duplicate-code-allow-only-repos branch November 23, 2026 16:10
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: Allow-Only repos Type Switch Repeated in Guard Policy Validation

3 participants