rust-guard: replace magic integrity strings with constants; add security-tool label tests#6470
Merged
Merged
Conversation
…curity-tool label tests
Copilot
AI
changed the title
[WIP] Replace magic integrity strings with constants in Rust Guard
rust-guard: replace magic integrity strings with constants; add security-tool label tests
May 25, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens the Rust GitHub guard’s labeling consistency and strengthens regression protection for security-sensitive tools by removing hard-coded integrity tokens and adding unit tests that enforce always-private secrecy for security tooling outputs.
Changes:
- Replace fallback magic strings in
labels/helpers.rswith canonicalpolicy_integrity::{NONE,APPROVED}constants. - Add unit tests in
labels/tool_rules.rsensuring secret scanning, code scanning, Dependabot alerts, and job logs always receive private secrecy and approved integrity labels.
Show a summary per file
| File | Description |
|---|---|
| guards/github-guard/rust-guard/src/labels/helpers.rs | Replaces "none" / "approved" fallbacks with canonical integrity constants to avoid drift/typos. |
| guards/github-guard/rust-guard/src/labels/tool_rules.rs | Adds tests enforcing always-private secrecy + approved integrity for security-tool endpoints. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 0
This was referenced May 25, 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.
Two helper functions in
helpers.rsused raw string literals"none"and"approved"as fallback defaults while every other reference in the codebase usespolicy_integrity::NONE/policy_integrity::APPROVED. Additionally, the security-sensitive arms ofapply_tool_labels(secret scanning, code scanning, Dependabot, job logs) lacked unit tests to enforce their always-private invariant.Changes
labels/helpers.rs— eliminate magic stringseffective_disapproval_integrity:"none"→super::constants::policy_integrity::NONEeffective_endorser_min_integrity:"approved"→super::constants::policy_integrity::APPROVEDlabels/tool_rules.rs— security-tool label testsThree new tests added to the
#[cfg(test)]block, guarding against regressions where a refactor could silently apply visibility-inherited secrecy to these tools (leaking data on public repos):apply_tool_labels_secret_scanning_is_always_privatelist_secret_scanning_alerts,get_secret_scanning_alertapply_tool_labels_code_scanning_and_dependabot_are_always_privatelist_code_scanning_alerts,get_code_scanning_alert,list_dependabot_alerts,get_dependabot_alertapply_tool_labels_get_job_logs_is_always_privateget_job_logsEach test asserts that secrecy contains a
private:label and integrity contains anapproved:label, regardless of repo visibility.