feat(guard): elevate trusted first-party bot integrity to approved#2144
Merged
feat(guard): elevate trusted first-party bot integrity to approved#2144
Conversation
Objects authored by trusted first-party GitHub bots now receive approved (writer) integrity regardless of their author_association value from the GitHub API. This ensures that bot-authored issues, PRs, and commits are not incorrectly blocked by guard policies with min-integrity settings above none. Trusted first-party bots: - dependabot[bot]: GitHub dependency updater - github-actions[bot]: GitHub Actions workflow actor (GITHUB_TOKEN) - github-merge-queue[bot]: GitHub merge queue automation - copilot: GitHub Copilot AI assistant These bots are platform services whose presence requires explicit admin configuration, providing the trust signal for elevation. Changes: - Add is_trusted_first_party_bot() in helpers.rs (narrow 4-bot list) - Modify author_association_floor() to check user.login/author.login for trusted bots before falling back to author_association - Add author_login to PullRequestFacts and new IssueAuthorInfo struct in backend.rs for request-time bot detection - Update tool_rules.rs issue and PR paths to check author_login - Add comprehensive tests for all 4 bots across issues, PRs, commits on both public and private repos Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the GitHub guard’s integrity labeling so that objects authored by specific trusted first-party GitHub bots are treated as approved/writer integrity even when the GitHub API reports author_association: NONE, preventing them from being incorrectly filtered by min-integrity guard policies.
Changes:
- Added trusted first-party bot detection and elevated integrity floor logic in label helpers.
- Extended backend fact fetching to include
author_loginfor PRs and issues, and used it in tool-time labeling rules. - Added unit tests validating trusted-bot detection and integrity elevation for issues/PRs/commits.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
guards/github-guard/rust-guard/src/labels/helpers.rs |
Adds is_trusted_first_party_bot and uses author login to elevate integrity floors for trusted bots. |
guards/github-guard/rust-guard/src/labels/backend.rs |
Extends PR facts with author_login and introduces IssueAuthorInfo + fetch helper for issue author login/association. |
guards/github-guard/rust-guard/src/labels/tool_rules.rs |
Uses fetched author login in request-time labeling to elevate trusted bot issues/PRs to writer integrity. |
guards/github-guard/rust-guard/src/labels/mod.rs |
Adds tests for trusted bot detection and integrity elevation behavior. |
Comments suppressed due to low confidence (2)
guards/github-guard/rust-guard/src/labels/tool_rules.rs:116
- The trusted-bot elevation logic is now implemented in multiple places (author_association_floor() plus the request-time issue/PR paths here). To reduce the risk of future divergence, consider factoring the “association + optional login => floor integrity” calculation into a single helper that both response labeling and tool_rules can reuse.
let mut floor = author_association_floor_from_str(
repo_id,
info.author_association.as_deref(),
ctx,
);
// Elevate trusted first-party bots to approved
if let Some(ref login) = info.author_login {
if is_trusted_first_party_bot(login) {
floor = max_integrity(
repo_id,
floor,
writer_integrity(repo_id, ctx),
ctx,
);
}
}
integrity = max_integrity(repo_id, integrity, floor, ctx);
guards/github-guard/rust-guard/src/labels/tool_rules.rs:117
- The trusted-bot elevation logic on the request-time issue path isn’t covered by unit tests today (existing apply_tool_labels tests don’t assert integrity for get_issue/issue_read because the backend call can’t be mocked). Consider refactoring apply_tool_labels to accept an injectable backend callback (similar to *_with_callback helpers) so you can add a deterministic test that a trusted bot issue yields writer integrity when author_association is NONE.
if let Some(info) =
super::backend::get_issue_author_info(&owner, &repo, &issue_num)
{
let mut floor = author_association_floor_from_str(
repo_id,
info.author_association.as_deref(),
ctx,
);
// Elevate trusted first-party bots to approved
if let Some(ref login) = info.author_login {
if is_trusted_first_party_bot(login) {
floor = max_integrity(
repo_id,
floor,
writer_integrity(repo_id, ctx),
ctx,
);
}
}
integrity = max_integrity(repo_id, integrity, floor, ctx);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+152
to
+162
| // Elevate trusted first-party bots to approved | ||
| if let Some(ref login) = facts.author_login { | ||
| if is_trusted_first_party_bot(login) { | ||
| integrity = max_integrity( | ||
| repo_id, | ||
| integrity, | ||
| writer_integrity(repo_id, ctx), | ||
| ctx, | ||
| ); | ||
| } | ||
| } |
Comment on lines
+879
to
+885
| pub fn is_trusted_first_party_bot(username: &str) -> bool { | ||
| let lower = username.to_lowercase(); | ||
| lower == "dependabot[bot]" | ||
| || lower == "github-actions[bot]" | ||
| || lower == "github-merge-queue[bot]" | ||
| || lower == "copilot" | ||
| } |
This was referenced Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Objects authored by trusted first-party GitHub bots now receive approved (writer) integrity regardless of their
author_associationvalue from the GitHub API.Problem
Bot-authored issues, PRs, and commits were receiving baseline
noneintegrity because theirauthor_associationfrom the GitHub API is typicallyNONE. This caused them to be incorrectly blocked by guard policies withmin-integritysettings abovenone.For example, with
min-integrity: merged, all dependabot PRs and github-actions issues were filtered out — even though these bots are trusted platform services explicitly configured by repo admins.Solution
Introduced
is_trusted_first_party_bot()to identify 4 GitHub platform bots:dependabot[bot]github-actions[bot]github-merge-queue[bot]copilotThese bots receive
approved(writer) integrity because:Changes
helpers.rsis_trusted_first_party_bot()— narrow 4-bot detection (exact match)extract_author_login()— checksuser.login(issues/PRs) andauthor.login(commits)author_association_floor()— checks for trusted bots before falling back toauthor_associationis_bot()for broad bot detection (unchanged)backend.rsauthor_login: Option<String>toPullRequestFactsIssueAuthorInfostruct withauthor_association+author_loginget_issue_author_info()/get_issue_author_info_with_callback()for request-time bot detectiontool_rules.rsget_issue/issue_read) to useget_issue_author_infoand check trusted bot statusget_pull_request/pull_request_read) to checkfacts.author_loginfor trusted botsTests (155 new lines)
test_trusted_first_party_bot_detection— all 4 bots detected, case-insensitive, third-party bots excludedtest_trusted_bot_issue_integrity_public_repo— all 4 bots get approved on public repostest_trusted_bot_pr_integrity_public_repo— bot PRs get approved, merged bot PRs get mergedtest_trusted_bot_commit_integrity— bot commits get approved/merged based on branchDesign Decisions
dependabot[bot](not justdependabot) to avoid false positivesauthor_association_floor) and request-time labeling (tool_rules.rs)author_associationlogic unchanged