Skip to content

Commit 02fea7e

Browse files
Copilotlpcox
andauthored
Remove dead is_bot function and eliminate format! allocation in check_file_secrecy
Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/beff37b6-0877-4d2c-960a-a2b7b5cd165b Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
1 parent 0cb0c59 commit 02fea7e

4 files changed

Lines changed: 3 additions & 17 deletions

File tree

guards/github-guard/rust-guard/src/labels/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Common utility functions including:
2929
- Label generation helpers (secret_label, writer_integrity, etc.)
3030
- JSON extraction functions (get_string_field, extract_repo_info, etc.)
3131
- Integrity determination (pr_integrity, issue_integrity)
32-
- User classification (is_bot)
32+
- User classification (is_blocked_user, is_trusted_user)
3333

3434
### backend.rs (92 lines)
3535
Backend API calls for verifying user status:

guards/github-guard/rust-guard/src/labels/helpers.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,20 +1323,6 @@ pub fn is_trusted_user(username: &str, ctx: &PolicyContext) -> bool {
13231323
username_in_list(username, &ctx.trusted_users)
13241324
}
13251325

1326-
/// Check if a user appears to be a bot (broad detection).
1327-
///
1328-
/// This is a broader check that includes third-party bots.
1329-
/// For integrity elevation, use is_trusted_first_party_bot() instead.
1330-
#[allow(dead_code)]
1331-
pub fn is_bot(username: &str) -> bool {
1332-
let lower = username.to_lowercase();
1333-
lower.ends_with("[bot]")
1334-
|| lower.ends_with("-bot")
1335-
|| lower == "dependabot"
1336-
|| lower == "renovate"
1337-
|| lower == "github-actions"
1338-
|| lower == "copilot"
1339-
}
13401326

13411327
#[cfg(test)]
13421328
mod tests {

guards/github-guard/rust-guard/src/labels/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub use helpers::{
4747
extract_graphql_single_object, extract_items_array,
4848
extract_number_as_string, extract_repo_from_item, extract_repo_info,
4949
extract_repo_info_from_search_query, get_bool_or, get_nested_str, get_str_or,
50-
has_author_association, is_blocked_user, is_bot, is_graphql_wrapper, is_mcp_text_wrapper,
50+
has_author_association, is_blocked_user, is_graphql_wrapper, is_mcp_text_wrapper,
5151
is_search_result_wrapper, issue_integrity, limit_items_with_log, make_item_path,
5252
merged_integrity, none_integrity, pr_integrity, private_scope_label, private_user_label,
5353
project_github_label, reader_integrity, search_result_total_count,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ fn check_file_secrecy(
682682

683683
// Check for sensitive file extensions/names
684684
for pattern in SENSITIVE_FILE_PATTERNS {
685-
if path_lower.ends_with(pattern) || path_lower.contains(&format!("/{}", pattern)) {
685+
if path_lower.ends_with(pattern) || path_lower.split('/').any(|seg| seg == *pattern) {
686686
return policy_private_scope_label(owner, repo, repo_id, ctx);
687687
}
688688
}

0 commit comments

Comments
 (0)