Repository navigation
Deduplicate Rust guard repository secrecy logic - #10782
Conversation
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
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
| 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()] | ||
| } | ||
| } |
| #[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()] | ||
| ); | ||
| } |
| 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()] | ||
| } | ||
| } |
|
@copilot address review feedback |
Co-authored-by: lpcox <[email protected]>
🔒 mcpg Read-Only Stress — docker-sbxSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: PASS
Run: §31132683305
|
Summary
Fixes #10767