#474: Anchor Fbe.mask_to_regex regex to prevent prefix collisions#495
#474: Anchor Fbe.mask_to_regex regex to prevent prefix collisions#495VasilevNStas wants to merge 2 commits into
Conversation
edmoffo
left a comment
There was a problem hiding this comment.
Fix is correct and the four added tests cover the anchored-match contract, including the prefix-collision case from #474. CI is green across the matrix.
One unrelated change to address: .github/workflows/typos.yml downgrades crate-ci/typos from v1.47.1 to v1.47.0. Drop that line so the diff stays focused on the regex fix.
edmoffo
left a comment
There was a problem hiding this comment.
Anchoring the regex with \A and \z resolves issue #474 directly: substrings like zerocracy/judges-actions and zerocracy/judges-action-old no longer match zerocracy/judges-action. The four new tests pin exact match, prefix-collision rejection, wildcard expansion, and case insensitivity.
Local validation on the checked-out head:
bundle exec ruby -Itest test/fbe/test_unmask_repos.rb— 9 tests, 20 assertions, 0 failures, 1 skip (live test).
All 10 exposed checks are green. No inline comments.
bibonix
left a comment
There was a problem hiding this comment.
Anchors close the prefix-collision hole on both the inclusion and exclusion paths in unmask_repos, and the four new tests pin the behavior including the wildcard and case-insensitive cases. No inline comments.
9e14a27 to
e500539
Compare
|
@edmoffo Thanks for the review! You've earned +10 points for this contribution: +18 as the base reward for authoring a code review, then -8 deducted due to absolutely no comments being posted during the review process. Your running score is +1536; don't forget to check your Zerocracy account too. |
|
@kreinba Thanks for the review! You've earned +10 points for this contribution: +18 as a basis for completing the review, -8 for absolutely no comments posted during the review process. Your running score is +1427; don't forget to check your Zerocracy account too. |
|
@bibonix Thanks for the review! You've earned +10 points for this contribution: +18 as a basis for completing the review, -8 for absolutely no comments posted during the review process. Your running score is +1015; don't forget to check your Zerocracy account too. |
|
@VasilevNStas merge conflicts here |
|
Please fix the merge conflicts so this pull request can be merged. |
The regex built by Fbe.mask_to_regex was unanchored, so re.match? would match substrings. For exclusion masks like '-zerocracy/judges-action', this caused repositories with prefix collisions (e.g. 'zerocracy/judges-actions' or 'zerocracy/judges-action-old') to be incorrectly excluded. Added \A and \z anchors to ensure full-string matching. Wildcard masks (zerocracy/*) are unaffected since .* already absorbs the entire tail. Added four direct unit tests for Fbe.mask_to_regex: - test_mask_to_regex_exact_match - test_mask_to_regex_prefix_collision - test_mask_to_regex_wildcard - test_mask_to_regex_case_insensitive
e500539 to
e84f749
Compare
|
@yegor256 plz re-review |
Description
Fbe.mask_to_regexbuilds a regex without\A/\zanchors, causingre.match?to match substrings. For exclusion masks like-zerocracy/judges-action, this means repositories with prefix collisions (e.g.zerocracy/judges-actionsorzerocracy/judges-action-old) are incorrectly excluded.Fix
Added
\Aand\zanchors to the regex compilation inlib/fbe/unmask_repos.rb:27:Wildcard masks (
zerocracy/*) are unaffected because.*already absorbs the entire tail.Tests
Added four direct unit tests for
Fbe.mask_to_regexintest/fbe/test_unmask_repos.rb:test_mask_to_regex_exact_match— confirms exact match workstest_mask_to_regex_prefix_collision— confirmszerocracy/judges-actiondoes NOT matchzerocracy/judges-actionsorzerocracy/judges-action-oldtest_mask_to_regex_wildcard— confirmszerocracy/*still matches any repotest_mask_to_regex_case_insensitive— confirms case-insensitive flag is preservedVerification
bundle exec rubocop— 0 offensesbundle exec rake test— 287 tests, 0 failuresCloses #474