fix(safeoutputs): support glob wildcards anywhere in allowed-tags patterns#442
fix(safeoutputs): support glob wildcards anywhere in allowed-tags patterns#442jamesadevine merged 2 commits intomainfrom
Conversation
🔍 Rust PR ReviewSummary: Good fix with correct implementation — but has two documentation gaps and one undocumented behavioral regression worth addressing before merge. Findings🐛 Bugs / Logic Issues
|
…terns tag_matches_pattern only handled a trailing '*' (prefix match). Patterns like 'copilot:repo=msazuresphere/4x4/*@main' silently fell through to exact-match comparison, rejecting valid tags such as 'copilot:repo=msazuresphere/4x4/VsCodeExtension@main'. Switch to glob_match::glob_match (already a dependency) so '*' works in any position. Also consolidate the inline matching in add_build_tag.rs to use the shared tag_matches_pattern helper, gaining case-insensitive matching it was previously missing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…_match Address PR review feedback: - Replace glob_match::glob_match with a purpose-built wildcard_match() that treats * as matching any character including /. Tags and artifact names are not file paths, so / should not act as a segment separator. - Add name_matches_pattern() (case-sensitive) alongside the existing tag_matches_pattern() (case-insensitive) for artifact name allow-lists. - Consolidate upload_build_attachment.rs and upload_pipeline_artifact.rs to use name_matches_pattern instead of inline strip_suffix + starts_with. - Leave queue_build.rs branch matching as-is — it has intentionally different semantics (case-sensitive, requires / separator). - Update docs/safe-outputs.md to describe * wildcard support instead of the old 'prefix wildcards' language. - Add comprehensive tests for wildcard_match, slash-crossing, and name_matches_pattern. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
5932d67 to
32a2f28
Compare
🔍 Rust PR ReviewSummary: The updated implementation is correct and well-tested — the previous review's concerns have been addressed. One minor behavioral change in Findings
|
Summary
tag_matches_patternonly handled a trailing*(prefix match). Patterns with a wildcard in the middle — likecopilot:repo=msazuresphere/4x4/*@main— silently fell through to exact-string comparison, rejecting valid tags such ascopilot:repo=msazuresphere/4x4/VsCodeExtension@main.This PR introduces a purpose-built
wildcard_match()function that treats*as matching any character including/— tags and artifact names are not file paths, so/should not act as a segment separator. This replaces both the previousglob_match::glob_matchcall (which treated/as a separator) and the scattered hand-rolledstrip_suffix('*') + starts_withpatterns across safe-output modules.Changes
src/safeoutputs/mod.rs: Newwildcard_match()function, plustag_matches_pattern()(case-insensitive) andname_matches_pattern()(case-sensitive) wrapperssrc/safeoutputs/add_build_tag.rs: Consolidated to usetag_matches_pattern(gains case-insensitive matching it was missing)src/safeoutputs/upload_build_attachment.rs: Consolidated to usename_matches_patternsrc/safeoutputs/upload_pipeline_artifact.rs: Consolidated to usename_matches_patternqueue_build.rs: Left as-is — branch matching has intentionally different semantics (case-sensitive, requires/separator)docs/safe-outputs.md: Updated to describe*wildcard support instead of "prefix wildcards"Test plan
cargo test— all 1186+ tests passcargo clippy --all-targets --all-features— no new warnings*, middle*,*crossing/, multiple*s, case sensitivity, andname_matches_patternbehavior