Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get by uri does not match IP addresses and fails on entries without trailing slash #211

Open
fabian-thomas opened this issue Oct 27, 2024 · 0 comments

Comments

@fabian-thomas
Copy link

I've identified two issues with the current get by uri implementation:

  1. Ip addresses can't be matched in domain mode. For example try rbw get https://192.168.178.1 with an entry that has the uri https://192.168.178.1 configured. This is because the domain_port invocation here does not return anything because the entry has no domain. I'm not sure how this can be fixed. One option would be to use domain or ip address there.
  2. If exact mode is used, entries without the trailing slash configured in bitwarden are not matched. This is because url.to_string here returns the url with trailing slash even when rbw get https://example.com (no trailing slash) is used for querying. Again, I'm not sure how to fix this. In exact mode you could argue that it should actually exactly match, but then you would need to add both entries https://example.com/ and https://example.com to your bitwarden entry so that all clients handle it correctly. Therefore I think it would be best to make this a special case that even matches in exact mode. For reference: firefox with the bitwarden android app only match when https://example.com is configured, but not when https://example.com/ is configured.

I personally fix 2. with this patch:

diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs
index 486b5d1..6becb49 100644
--- a/src/bin/rbw/commands.rs
+++ b/src/bin/rbw/commands.rs
@@ -816,7 +816,7 @@ impl DecryptedUri {
             rbw::api::UriMatchType::StartsWith => {
                 url.to_string().starts_with(&self.uri)
             }
-            rbw::api::UriMatchType::Exact => url.to_string() == self.uri,
+            rbw::api::UriMatchType::Exact => url.to_string().trim_end_matches('/') == self.uri.trim_end_matches('/'),
             rbw::api::UriMatchType::RegularExpression => {
                 let Ok(rx) = regex::Regex::new(&self.uri) else {
                     return false;
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

No branches or pull requests

1 participant