Repository navigation
[SM-2126] Updating regex - #8809
cd-bitwarden wants to merge 6 commits into
Conversation
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE This PR replaces the regex loop in Code Review Details
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8809 +/- ##
==========================================
- Coverage 74.83% 68.49% -6.35%
==========================================
Files 2750 2751 +1
Lines 117618 117664 +46
Branches 10781 10791 +10
==========================================
- Hits 88022 80596 -7426
- Misses 26940 34528 +7588
+ Partials 2656 2540 -116 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| /// catastrophic backtracking on untrusted input (CWE-1333). Call this as the very first | ||
| /// statement of <c>Main</c>, before anything else has a chance to construct a <c>Regex</c>. | ||
| /// </summary> | ||
| public static void ConfigureDefaultMatchTimeout() |
There was a problem hiding this comment.
❓ QUESTION: Were the Sso and Scim hosts left out on purpose? Both reference Core, but neither Main calls ConfigureDefaultMatchTimeout().
Details and fix
The PR description says the timeout is set "in each service host's Main". That is true for the eight hosts under src/, but bitwarden_license/src/Sso/Program.cs and bitwarden_license/src/Scim/Program.cs are unchanged. Both reference Core.csproj, and both already have using Bit.Core.Utilities;. So those two processes still run every Regex with no timeout, and SSO handles external IdP input.
If the omission is not intentional, add this as the first statement of each Main:
RegexDefaults.ConfigureDefaultMatchTimeout();code-review
🎟️ Tracking
https://bitwarden.atlassian.net/browse/SM-2126
📔 Objective
This PR replaces the regex-based CoreHelpers.SanitizeForEmail with a single-pass linear scan, which removes the quadratic re-scan loop on repeated :// input. It also caps RequestSMAccessRequestModel.EmailContent at 1000 characters and sets a process-wide 5-second Regex default match timeout in each service host's Main.