@@ -940,7 +940,8 @@ pub(crate) fn extract_repo_from_github_url(url: &str) -> Option<String> {
940940
941941/// Extract repository full name from a response item
942942/// Tries multiple fields in order: full_name, repository.full_name,
943- /// base.repo.full_name, head.repo.full_name, html_url parsing
943+ /// base.repo.full_name, head.repo.full_name, then URL parsing from
944+ /// repository_url, html_url, and url.
944945/// Returns empty string if no repo info found
945946pub fn extract_repo_from_item ( item : & Value ) -> String {
946947 // Direct full_name (repositories)
@@ -975,7 +976,7 @@ pub fn extract_repo_from_item(item: &Value) -> String {
975976 }
976977 // URL field fallback (repository_url for search results, html_url / url as generic fallbacks)
977978 for field in & [ "repository_url" , "html_url" , "url" ] {
978- if let Some ( url) = item. get ( * field) . and_then ( |v| v. as_str ( ) ) {
979+ if let Some ( url) = item. get ( field) . and_then ( |v| v. as_str ( ) ) {
979980 if let Some ( repo_id) = extract_repo_from_github_url ( url) {
980981 return repo_id;
981982 }
@@ -1771,6 +1772,20 @@ mod tests {
17711772 PolicyContext :: default ( )
17721773 }
17731774
1775+ #[ test]
1776+ fn test_is_any_trusted_actor_tiers_and_negative ( ) {
1777+ let ctx = PolicyContext {
1778+ trusted_bots : vec ! [ "custom-bot" . to_string( ) ] ,
1779+ trusted_users : vec ! [ "trusted-human" . to_string( ) ] ,
1780+ ..Default :: default ( )
1781+ } ;
1782+
1783+ assert ! ( is_any_trusted_actor( "github-actions[bot]" , & ctx) ) ;
1784+ assert ! ( is_any_trusted_actor( "custom-bot" , & ctx) ) ;
1785+ assert ! ( is_any_trusted_actor( "trusted-human" , & ctx) ) ;
1786+ assert ! ( !is_any_trusted_actor( "random-user" , & ctx) ) ;
1787+ }
1788+
17741789 #[ test]
17751790 fn test_collaborator_permission_floor_admin ( ) {
17761791 let ctx = test_ctx ( ) ;
0 commit comments