Skip to content

Add regression tests locking in DIFC coverage for 8 previously-flagged GitHub MCP tools - #10875

Merged
lpcox merged 3 commits into
mainfrom
copilot/guard-coverage-fix
Aug 8, 2026
Merged

lpcox merged 3 commits into
mainfrom
copilot/guard-coverage-fix

Conversation

Copilot AI commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

The guard coverage checker flagged 8 operations (add_pull_request_review_comment_reaction, add_reply_to_pull_request_comment, projects_write, reprioritize_sub_issue, set_issue_fields, unresolve_review_thread, update_pull_request_branch, update_pull_request_title) as potentially falling through to default DIFC labeling in apply_tool_labels, risking missed repo/org-scoped secrecy and integrity labels.

Investigation found all 8 tools already have explicit classification in tools.rs and explicit match arms in apply_tool_labels (tool_rules.rs) — the labeling logic itself was already correct. The gap was in test coverage: 5 of the 8 tools had no dedicated regression test asserting their labeling behavior, leaving them vulnerable to silent breakage during future refactors.

  • Test coverage
    • Added apply_tool_labels_issue_and_pr_granular_write_ops_are_repo_scoped_writes covering reprioritize_sub_issue, set_issue_fields, update_pull_request_branch, and update_pull_request_title — asserts repo-scoped writer integrity and empty secrecy for public repos.
    • Added apply_tool_labels_projects_write_is_owner_scoped_writer_integrity covering projects_write — asserts owner-scoped writer integrity, consistent with its existing Projects v2 alias siblings.
    • add_pull_request_review_comment_reaction, add_reply_to_pull_request_comment, and unresolve_review_thread already had direct test coverage and required no changes.

No changes to production labeling logic were needed since the match arms were already present and correct.

Copilot AI changed the title [WIP] Fix guard coverage gap for 8 operations Add regression tests locking in DIFC coverage for 8 previously-flagged GitHub MCP tools Aug 8, 2026
Copilot AI requested a review from lpcox August 8, 2026 15:57
@lpcox
lpcox marked this pull request as ready for review August 8, 2026 15:58
Copilot AI balanced review requested due to automatic review settings August 8, 2026 15:58

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.

Pull request overview

Adds regression tests for existing DIFC labeling rules covering five GitHub MCP write operations.

Changes:

  • Tests four repo-scoped issue/PR write operations.
  • Tests owner-scoped integrity for projects_write.
Show a summary per file
File Description
guards/github-guard/rust-guard/src/labels/tool_rules.rs Adds DIFC labeling regression tests.

Review details

Tip

Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

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

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🔒 mcpg Read-Only Stress — gVisor

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: gVisor (runsc) kernel-level isolation

Part Surface Op Result Expected Status
A MCP reads (issues/PRs/file/commits) data returned ALLOWED ✅
B MCP writes (reaction/star/issue/comment/branch/file/PR) Error [-32602]: unknown tool BLOCKED ✅
C CLI reads (list_issues, get_file_contents) data returned ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment/file) gh: GH_TOKEN not set (unauthenticated) BLOCKED ✅
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh: GH_TOKEN not set (unauthenticated) BLOCKED ✅

Overall: PASS

Notes:

  • Part B: Gateway enforces read-only by exposing only 22 read-only MCP tools; all write tool calls return MCP error [-32602]: unknown tool — gateway-level enforcement confirmed.
  • Parts D/E: gh CLI is unauthenticated (GH_TOKEN not set), so all REST/GraphQL write attempts are rejected at the auth layer before reaching GitHub API. No writes leaked.

References: §31266577964

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

@github-actions

github-actions Bot commented Aug 8, 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 AWF container)

Part Surface Op Result Expected Status
A MCP reads (issues/PRs/file/commits) data returned ALLOWED ✅
B MCP writes (reaction/star/issue/comment/branch/file/PR) Error [-32602]: unknown tool — gateway allowlist, 6ms local reject BLOCKED ✅
C CLI reads (list_issues, get_file_contents) data returned ALLOWED ✅
D CLI REST writes × 5 rejected (gh unauthenticated — GH_TOKEN not set) BLOCKED ✅
E CLI GraphQL mutations × 3 rejected (gh unauthenticated — GH_TOKEN not set) BLOCKED ✅

Gateway enforcement evidence (Part B): Write tool calls return in ~6 ms (local reject by tool allowlist) vs 283–605 ms for reads forwarded to the backend. The gateway exposes exactly 22 read-only tools; all write tools are absent from the allowlist and rejected with MCP error [-32602] before any backend contact.

Overall: PASS

References: §31266577972

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

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🔒 mcpg Read-Only Stress — docker-sbx

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: docker-sbx (KVM-isolated microVM)

Part Surface Op Result Expected Status
A MCP reads (issues/PRs/file/commits) data returned ALLOWED ✅
B MCP writes (reaction/star/issue/comment/branch/file/PR) all refused: unknown tool [-32602] BLOCKED ✅
C CLI reads (list_issues via MCP-backed github CLI) data returned ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment/file) all refused: 401 Bad credentials BLOCKED ✅
E CLI GraphQL mutations (addReaction/addStar/createIssue) refused: 401 Bad credentials BLOCKED ✅

Note on Part B: All 7 write tools returned Error [-32602]: unknown tool — gateway enforces read-only by not exposing write tools in the MCP tool list.

Note on Parts D/E: gh is unauthenticated in this runtime; all REST/GraphQL writes received 401 Bad credentials (blocked).

Note on Part C: github CLI (MCP-backed) reads succeeded; gh api reads returned 401 (unauthenticated).

Overall: PASS

Run: §31266578009

🔒 mcpg read-only stress (docker-sbx runtime) by Read-Only Stress: docker-sbx runtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[guard-coverage] Guard coverage gap: 8 operations from github-mcp-server / GitHub CLI not fully covered

3 participants