Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions guards/github-guard/rust-guard/src/labels/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ mod tests {
assert_eq!(tool_names::UI_GET, "ui_get");
assert_eq!(tool_names::GET_COMMIT, "get_commit");
assert_eq!(tool_names::SEARCH_REPOSITORIES, "search_repositories");
assert_eq!(tool_names::SEARCH_CODE, "search_code");
assert_eq!(
UI_GET_REPO_SCOPED_METHODS,
&["labels", "milestones", "branches"]
Expand Down Expand Up @@ -209,6 +210,7 @@ pub mod tool_names {
pub const LIST_COMMITS: &str = "list_commits";
pub const LIST_RELEASES: &str = "list_releases";
pub const SEARCH_REPOSITORIES: &str = "search_repositories";
pub const SEARCH_CODE: &str = "search_code";
pub const ACTIONS_GET: &str = "actions_get";
pub const UI_GET: &str = "ui_get";
}
Expand Down
2 changes: 1 addition & 1 deletion guards/github-guard/rust-guard/src/labels/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ mod tests {
});

let (secrecy, integrity, _desc) = apply_tool_labels(
"search_code",
tool_names::SEARCH_CODE,
&tool_args,
"github/copilot",
vec![],
Expand Down
4 changes: 2 additions & 2 deletions guards/github-guard/rust-guard/src/labels/tool_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ pub fn apply_tool_labels(
}

// === Code / Commit Search ===
"search_code" | "search_code_ff_fields_param" | "search_commits" => {
tool_names::SEARCH_CODE | "search_code_ff_fields_param" | "search_commits" => {
// Repo-scoped search reads. Resolve scope from query repo qualifier first,
// then fall back to tool_args owner/repo.
let (s_owner, s_repo, s_repo_id) = resolve_search_scope(tool_args, &owner, &repo);
Expand Down Expand Up @@ -1673,7 +1673,7 @@ mod tests {

let search_code_args = serde_json::json!({ "query": "repo:github/copilot auth" });
assert_same_labels(
"search_code",
tool_names::SEARCH_CODE,
"search_code_ff_fields_param",
&search_code_args,
);
Expand Down
9 changes: 5 additions & 4 deletions guards/github-guard/rust-guard/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mod tools;

use labels::constants::policy_integrity;
use labels::constants::scope_names;
use labels::constants::tool_names;
use labels::{
blocked_integrity, extract_repo_info, extract_repo_info_from_search_query, MinIntegrity,
PolicyContext, PolicyScopeEntry, ScopeKind,
Expand Down Expand Up @@ -512,7 +513,7 @@ fn infer_scope_for_baseline<'a>(
.map(|value| Cow::Owned(value.to_string()))
.unwrap_or_else(|| Cow::Borrowed(repo_id))
}
"search_code"
tool_names::SEARCH_CODE
| "search_code_ff_fields_param"
| "search_issues"
| "search_issues_ff_fields_param"
Expand Down Expand Up @@ -1319,7 +1320,7 @@ mod tests {
fn infer_scope_for_baseline_uses_search_code_query_repo() {
let tool_args = json!({"query": "repo:lpcox/github-guard README"});

let inferred = infer_scope_for_baseline("search_code", &tool_args, "");
let inferred = infer_scope_for_baseline(tool_names::SEARCH_CODE, &tool_args, "");
assert!(matches!(&inferred, Cow::Owned(_)));
assert_eq!(inferred, "lpcox/github-guard");
}
Expand Down Expand Up @@ -1363,7 +1364,7 @@ mod tests {

let tool_args = json!({"query": "repo:lpcox/github-guard README"});
let (_, integrity, _) = labels::apply_tool_labels(
"search_code",
tool_names::SEARCH_CODE,
&tool_args,
"",
vec![],
Expand All @@ -1372,7 +1373,7 @@ mod tests {
&ctx,
);

let inferred_scope = infer_scope_for_baseline("search_code", &tool_args, "");
let inferred_scope = infer_scope_for_baseline(tool_names::SEARCH_CODE, &tool_args, "");
let baseline = labels::ensure_integrity_baseline(&inferred_scope, integrity, &ctx);

assert_eq!(
Expand Down
Loading