[PR #7243] http_client: don't panic on invalid block regex; use RwLock #31566

Open
opened 2026-06-17 11:33:21 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/dani-garcia/vaultwarden/pull/7243
Author: @nghiphaam
Created: 5/20/2026
Status: 🔄 Open

Base: mainHead: fix/http-block-regex-no-panic


📝 Commits (1)

  • a9893d6 http_client: don't panic on invalid block regex; use RwLock

📊 Changes

1 file changed (+19 additions, -11 deletions)

View changed files

📝 src/http_client.rs (+19 -11)

📄 Description

should_block_address_regex called Regex::new(&block_regex).unwrap() on every miss. Config validation (config.rs) already rejects invalid patterns, but a slip-through (e.g. test path or a race) would crash the server mid-request. Swap the unwrap() for a logged warning + skip-block fallback.

Also switched the cache from Mutex to RwLock so concurrent outbound HTTP checks don't serialise on the same lock when the regex is unchanged.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/dani-garcia/vaultwarden/pull/7243 **Author:** [@nghiphaam](https://github.com/nghiphaam) **Created:** 5/20/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/http-block-regex-no-panic` --- ### 📝 Commits (1) - [`a9893d6`](https://github.com/dani-garcia/vaultwarden/commit/a9893d60a3f8fe3b519ff74d6d045c4097485b71) http_client: don't panic on invalid block regex; use RwLock ### 📊 Changes **1 file changed** (+19 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `src/http_client.rs` (+19 -11) </details> ### 📄 Description `should_block_address_regex` called `Regex::new(&block_regex).unwrap()` on every miss. Config validation (`config.rs`) already rejects invalid patterns, but a slip-through (e.g. test path or a race) would crash the server mid-request. Swap the `unwrap()` for a logged warning + skip-block fallback. Also switched the cache from `Mutex` to `RwLock` so concurrent outbound HTTP checks don't serialise on the same lock when the regex is unchanged. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-06-17 11:33:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vaultwarden#31566