Skip to content

Deduplicate Rust guard repository secrecy logic - #10782

Merged
lpcox merged 3 commits into
mainfrom
copilot/rust-guard-deduplicate-secrecy-logic
Aug 7, 2026
Merged

lpcox merged 3 commits into
mainfrom
copilot/rust-guard-deduplicate-secrecy-logic

Conversation

Copilot AI commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • centralize private-repository secrecy labeling, including malformed-name fallback
  • reuse the existing validated repository-name parser in PR and issue enrichment paths
  • cover policy-scoped and malformed repository names with unit tests

Fixes #10767

@lpcox lpcox changed the title [WIP] Refactor Rust Guard response labeling to deduplicate secrecy logic Deduplicate Rust guard repository secrecy logic Aug 6, 2026
@lpcox
lpcox marked this pull request as ready for review August 6, 2026 21:33
Copilot AI balanced review requested due to automatic review settings August 6, 2026 21:33

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Centralizes private-repo secrecy labeling and reuses a shared repository-name parser across response labeling and enrichment paths, with added unit tests for policy-scoped and malformed repository names.

Changes:

  • Replaced duplicated private-repo secrecy labeling logic with private_repo_secrecy_label.
  • Switched PR/issue enrichment owner/repo extraction to split_repo_id.
  • Added unit tests for policy-scope behavior and malformed-name fallback.
Show a summary per file
File Description
guards/github-guard/rust-guard/src/labels/response_paths.rs Uses centralized private-repo secrecy labeling when emitting path-based labels.
guards/github-guard/rust-guard/src/labels/response_items.rs Uses centralized private-repo secrecy labeling when emitting item-based labels.
guards/github-guard/rust-guard/src/labels/helpers.rs Introduces private_repo_secrecy_label, reuses split_repo_id in enrichment, and adds tests.

Review details

Tip

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

  • Files reviewed: 3/3 changed files
  • Comments generated: 3
  • Review effort level: Lite

Comment on lines +1016 to +1022
pub(crate) fn private_repo_secrecy_label(full_name: &str, ctx: &PolicyContext) -> Vec<String> {
if let Some((owner, repo)) = split_repo_id(full_name) {
policy_private_scope_label(owner, repo, full_name, ctx)
} else {
vec![label_constants::PRIVATE_BASE.to_string()]
}
}
Comment on lines +2296 to +2310
#[test]
fn test_private_repo_secrecy_label_falls_back_for_malformed_name() {
assert_eq!(
private_repo_secrecy_label("malformed", &test_ctx()),
vec![label_constants::PRIVATE_BASE.to_string()]
);
assert_eq!(
private_repo_secrecy_label("/repo", &test_ctx()),
vec![label_constants::PRIVATE_BASE.to_string()]
);
assert_eq!(
private_repo_secrecy_label("owner/", &test_ctx()),
vec![label_constants::PRIVATE_BASE.to_string()]
);
}
Comment on lines +1016 to +1022
pub(crate) fn private_repo_secrecy_label(full_name: &str, ctx: &PolicyContext) -> Vec<String> {
if let Some((owner, repo)) = split_repo_id(full_name) {
policy_private_scope_label(owner, repo, full_name, ctx)
} else {
vec![label_constants::PRIVATE_BASE.to_string()]
}
}
@lpcox

lpcox commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address review feedback

Addressed in 6b5cefd. The repository parser now rejects extra path segments, private_repo_secrecy_label delegates parsing/fallback to policy_private_scope_label, and malformed-name coverage includes owner/repo/extra.

@lpcox
lpcox merged commit a6631c4 into main Aug 7, 2026
33 of 36 checks passed
@lpcox
lpcox deleted the copilot/rust-guard-deduplicate-secrecy-logic branch August 7, 2026 02:29
@github-actions

github-actions Bot commented Aug 7, 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) unknown tool [-32602] BLOCKED ✅
C CLI reads (issues/file) data returned ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment/file) HTTP 401 Bad credentials BLOCKED ✅
E CLI GraphQL mutations (addReaction/addStar/createIssue) HTTP 401 Bad credentials BLOCKED ✅

Overall: PASS

Part B: All write tools returned Error [-32602]: unknown tool — gateway enforces read-only by exposing only the read-only tool subset (write tools absent from allowlist).
Parts D & E: gh CLI unauthenticated (HTTP 401), providing a second enforcement layer.

Run: §31132683305

🔒 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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[rust-guard] Rust Guard: Deduplicate repo secrecy/owner-parsing logic across response labeling modules

3 participants