Skip to content

visibility: fix multi-wildcard globs and *.pem matching (SEC-01, SEC-02) - #35

Merged
kridaydave merged 1 commit into
mainfrom
fix/pr-15-visibility-matcher-globs
Nov 8, 2026
Merged

kridaydave merged 1 commit into
mainfrom
fix/pr-15-visibility-matcher-globs

Conversation

@kridaydave

Copy link
Copy Markdown
Contributor

Bugs

  • SEC-01: dot-extension/suffix private-path patterns (repo policy intended *.pem key coverage) did not catch real key files like key.pem/deploy/id.pem in practice because the documented suffix form was not used in config; visibility must follow the documented .pem (literal) vs *.pem (suffix) intent.
  • SEC-02: matches_pattern used a single split_once('*') with literal ends_with, so patterns with more than one * (e.g. *key*, *audit*, a*b*c) never matched real paths/branches.

What was wrong

src/visibility.rs:80-89 (matches_pattern): split_once('*') left any later * inside the suffix, making multi-wildcard patterns require a literal * in the candidate. This under-matched both path globs and private-branch globs. visibility.toml also listed .pem (literal) while the documented suffix form for private keys is *.pem, leaving key files like key.pem/deploy/id.pem outside the repo policy.

Fix

  • Reworked matches_pattern to split on every * and match prefix, ordered middle segments, and suffix (handling any number of wildcards, preserving fail-closed behavior).
  • Updated visibility.toml private_paths to use *.pem (the documented suffix form) so private key files are caught as intended, without changing .pem's documented literal semantics.
  • Added regression coverage in src/visibility.rs unit tests for multi-* path/branch globs and *.pem suffix matching.

Verification

CI green (fmt, clippy, tests, release build, adjudication) + the regression test added (test_path_globs_support_multiple_wildcards_and_pem_suffix)

@kridaydave kridaydave added the purging Batch purge: bug-fix swarm PRs label Nov 8, 2026
@kridaydave
kridaydave force-pushed the fix/pr-15-visibility-matcher-globs branch from aa1ea8a to 4d7aa25 Compare November 8, 2026 18:01
… SEC-02)

SEC-02: matches_pattern used split_once('*') so patterns with more than one
wildcard (e.g. *key*, *audit*, a*b*c) never matched real paths/branches.
Replace with segment-wise matching that handles any number of '*' wildcards.

SEC-01: private key files like key.pem/deploy/id.pem were not caught by the
repo visibility policy. visibility.toml documented '*.pem' as the suffix form
while the config used literal '.pem'; switch the policy to '*.pem' (matching
documented intent) and add a regression test covering multi-* globs and the
*.pem suffix case.
@kridaydave
kridaydave force-pushed the fix/pr-15-visibility-matcher-globs branch from 5d60c80 to 93456c9 Compare November 8, 2026 18:50
@kridaydave
kridaydave merged commit 19addc5 into main Nov 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

purging Batch purge: bug-fix swarm PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant