Skip to content

Dynamic regex audit - #3131

Merged
david-a-wheeler merged 2 commits into
mainfrom
dynamic-regex-audit
Nov 13, 2026
Merged

david-a-wheeler merged 2 commits into
mainfrom
dynamic-regex-audit

Conversation

@david-a-wheeler

Copy link
Copy Markdown
Collaborator

No description provided.

Ruby 3.4.12 fixed Onigmo memory-safety bugs that are reachable only by
compiling a regex from attacker-controlled text; matching untrusted
text against our own patterns is fine. We audited our code and found
no regex compiled from untrusted input. This test keeps it that way.

It parses our production and CI/CD Ruby (app/, lib/ including rake
tasks, config/, Rakefile, and Ruby scripts in script/ and bin/) with
Prism and finds every Regexp.new/compile/union, interpolated regex
literal, and String#match/match? whose pattern isn't obviously
trusted. Literals, constants, and values computed only from them
(including ENV, ARGV, and STDIN, which we control) are trusted. Any
other site must be listed in ALLOWLIST, keyed by its untrusted inputs
(e.g., "match: name_pattern") rather than line numbers, so unrelated
edits don't break it but changing an input forces a re-review. Stale
entries also fail.

The 21 current entries are all reviewed as safe: their inputs come
from regex literals, repository content, or translation terms passed
through Regexp.escape.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
The check "[ $# = '' ]" compared the argument count to an empty
string, so it was never true: an empty branch name passed validation
("Branch name validated") and exited 0. Test the name itself with
"[ -z "$BRANCH_NAME" ]" instead.

No test covered this script, so add one that runs it on valid and
invalid names (empty, leading "-", leading "/").

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (dc93fbf) to head (f18a384).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #3131   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           90        90           
  Lines         4818      4818           
=========================================
  Hits          4818      4818           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@david-a-wheeler
david-a-wheeler merged commit f55cdca into main Nov 13, 2026
14 checks passed
@david-a-wheeler
david-a-wheeler deleted the dynamic-regex-audit branch November 13, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant