Skip to content

Add DIFC labeling rule for create_pull_request_with_copilot#3651

Merged
lpcox merged 3 commits intomainfrom
copilot/guard-coverage-fix-for-github-mcp-server
Apr 12, 2026
Merged

Add DIFC labeling rule for create_pull_request_with_copilot#3651
lpcox merged 3 commits intomainfrom
copilot/guard-coverage-fix-for-github-mcp-server

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 12, 2026

create_pull_request_with_copilot (remote-only tool) was covered by the create_* prefix pattern in tools.rs for write classification, but had no explicit match arm in apply_tool_labels, causing it to fall through to the default catch-all with no repo-scoped secrecy or writer integrity labels applied.

Changes

  • guards/github-guard/rust-guard/src/labels/tool_rules.rs: Add create_pull_request_with_copilot to the existing Issue/PR write operations match arm alongside create_pull_request, applying S(repo) secrecy and writer-level integrity — identical labeling to the standard PR creation tool.
// === Issue/PR write operations (repo-scoped) ===
"create_issue" | "issue_write" | "sub_issue_write" | "add_issue_comment"
| "create_pull_request" | "create_pull_request_with_copilot"   // ← added
| "update_pull_request" | "merge_pull_request"
| "pull_request_review_write" | "add_comment_to_pending_review"
| "add_reply_to_pull_request_comment" => {
    secrecy = apply_repo_visibility_secrecy(&owner, &repo, repo_id, secrecy, ctx);
    integrity = writer_integrity(repo_id, ctx);
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • example.com
    • Triggering command: /tmp/go-build2069436726/b514/launcher.test /tmp/go-build2069436726/b514/launcher.test -test.testlogfile=/tmp/go-build2069436726/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s -W .cfg 8221058/b288/ x_amd64/vet . --gdwarf2 (dns block)
  • invalid-host-that-does-not-exist-12345.com
    • Triggering command: /tmp/go-build2069436726/b496/config.test /tmp/go-build2069436726/b496/config.test -test.testlogfile=/tmp/go-build2069436726/b496/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build2069436726/b379/vet.cfg @v1.1.3/cpu/cpu.go1.25.8 om/tetratelabs/w-c=4 x_amd64/vet -I nal/encoding/def-atomic -I x_amd64/vet -I hB8eipdrZ -I x_amd64/vet --gdwarf-5 telabs/wazero/in-atomic -o x_amd64/vet (dns block)
  • nonexistent.local
    • Triggering command: /tmp/go-build2069436726/b514/launcher.test /tmp/go-build2069436726/b514/launcher.test -test.testlogfile=/tmp/go-build2069436726/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s -W .cfg 8221058/b288/ x_amd64/vet . --gdwarf2 (dns block)
  • slow.example.com
    • Triggering command: /tmp/go-build2069436726/b514/launcher.test /tmp/go-build2069436726/b514/launcher.test -test.testlogfile=/tmp/go-build2069436726/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s -W .cfg 8221058/b288/ x_amd64/vet . --gdwarf2 (dns block)
  • this-host-does-not-exist-12345.com
    • Triggering command: /tmp/go-build2069436726/b523/mcp.test /tmp/go-build2069436726/b523/mcp.test -test.testlogfile=/tmp/go-build2069436726/b523/testlog.txt -test.paniconexit0 -test.timeout=10m0s 8221�� .cfg ache/go/1.25.8/x64/src/database/sql/driver/driver.go x_amd64/vet --gdwarf-5 g/grpc/credentia/usr/bin/runc -o x_amd64/vet .cfg�� k3QZ/k0KRG1xFvJtggzT2k3QZ -trimpath x_amd64/vet -p 8221058/b468/ -lang=go1.16 x_amd64/vet (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Fix guard coverage gap for github-mcp-server operation Add DIFC labeling rule for create_pull_request_with_copilot Apr 12, 2026
Copilot AI requested a review from lpcox April 12, 2026 16:10
@lpcox lpcox marked this pull request as ready for review April 12, 2026 16:13
Copilot AI review requested due to automatic review settings April 12, 2026 16:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the GitHub DIFC guard’s tool labeling rules so create_pull_request_with_copilot is treated like other Issue/PR write operations, receiving repo-scoped secrecy and writer-level integrity labels.

Changes:

  • Add create_pull_request_with_copilot to the Issue/PR write-operation match arm in apply_tool_labels.
  • Ensure the tool gets S(repo) secrecy (via repo visibility) and writer integrity, matching create_pull_request.
Show a summary per file
File Description
guards/github-guard/rust-guard/src/labels/tool_rules.rs Adds explicit labeling for create_pull_request_with_copilot under repo-scoped Issue/PR write operations.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (1)

guards/github-guard/rust-guard/src/labels/tool_rules.rs:575

  • There are unit tests covering writer-integrity for create_pull_request, but none for the newly added create_pull_request_with_copilot. Add a corresponding apply_tool_labels test to ensure this tool consistently gets writer integrity (and repo-visibility secrecy behavior) the same way as create_pull_request.
        "create_issue" | "issue_write" | "sub_issue_write" | "add_issue_comment"
        | "create_pull_request" | "create_pull_request_with_copilot"
        | "update_pull_request" | "merge_pull_request"
        | "pull_request_review_write" | "add_comment_to_pending_review"
        | "add_reply_to_pull_request_comment" => {
  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment on lines 571 to +573
"create_issue" | "issue_write" | "sub_issue_write" | "add_issue_comment"
| "create_pull_request" | "update_pull_request" | "merge_pull_request"
| "create_pull_request" | "create_pull_request_with_copilot"
| "update_pull_request" | "merge_pull_request"
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

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

create_pull_request_with_copilot is now labeled as a repo-scoped write here, but it still won’t be classified as a write operation by tools::is_write_operation (see guards/github-guard/rust-guard/src/tools.rs: it’s not in WRITE_OPERATIONS, and there’s no create_* prefix handling). That means label_resource will emit operation="read" for this tool, which can weaken DIFC enforcement (read checks don’t apply write-integrity constraints). Add this tool to WRITE_OPERATIONS (or otherwise ensure it’s treated as a write op) so operation is correct end-to-end.

This issue also appears on line 571 of the same file.

Copilot uses AI. Check for mistakes.
Address review feedback:
- Add create_pull_request_with_copilot to WRITE_OPERATIONS in tools.rs
  so label_resource emits operation="write", matching DIFC enforcement
  for other PR creation tools.
- Add unit test for create_pull_request_with_copilot writer integrity
  in tool_rules, mirroring the existing create_pull_request test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

[guard-coverage] Guard coverage gap: 1 operation from github-mcp-server not fully covered

3 participants