aboutsummaryrefslogtreecommitdiff
path: root/src/api/icons.rs
AgeCommit message (Collapse)Author
2024-12-05Update Rust and crates (#5248)Mathijs van Veluw
* Update Rust and crates - Updated Rust to v1.83.0 - Updated MSRV to v1.82.0 (Needed for html5gum crate) - Updated icon fetching code to match new html5gum version - Updated workflows - Enabled edition 2024 clippy lints Nightly reports some clippy hints, but that would be too much to change in this PR i think. Signed-off-by: BlackDex <[email protected]> * Some additional updates - Patch fern to allow syslog-7 feature - Fixed diesel logger which was broken because of the sqlite backup feature Refactored the sqlite backup because of this - Added a build workflow test to include the query_logger feature Signed-off-by: BlackDex <[email protected]> * Also patch yubico-rs and latest updates Signed-off-by: BlackDex <[email protected]> --------- Signed-off-by: BlackDex <[email protected]>
2024-11-25chore: fix some comments (#5224)chuangjinglu
Signed-off-by: chuangjinglu <[email protected]>
2024-09-23Add extra linting (#4977)1.32.1Mathijs van Veluw
* Add extra linting Added extra linting for some code styles. Also added the Rust Edition 2024 lints. Closes #4974 Signed-off-by: BlackDex <[email protected]> * Adjusted according to comments Signed-off-by: BlackDex <[email protected]> --------- Signed-off-by: BlackDex <[email protected]>
2024-07-12Improved HTTP client (#4740)Daniel García
* Improved HTTP client * Change config compat to use auto, rename blacklist * Fix wrong doc references
2024-04-27Implement custom DNS resolver (#3988)Daniel García
2024-03-23Update Rust and crates (#4445)Mathijs van Veluw
- Updated Rust to v1.77.0 - Updated several crates The `reqwest` update included `trust-dns` > `hickory-dns` changes. Also, `reqwest` v0.12 is not working correctly for us, that is something to investigate. - Fixed a new clippy warning
2023-10-05Fix typostuhana
2023-08-31Update Rust and CratesBlackDex
- Updated Rust to v1.72.0 - Updated all the crates Including a CVE https://github.com/dani-garcia/vaultwarden/security/dependabot/21 - Updated GitHub Workflows - Run `cargo fmt` which has some new fmt's - Moved from `rust-toolchain` to `rust-toolchain.toml`
2023-08-13Optimized Favicon downloadingBlackDex
Some optimizations in regards to downloading Favicon's. I also encounterd some issues with accessing some sites where the connection got dropped or closed early. This seems a reqwest/hyper thingy, https://github.com/hyperium/hyper/issues/2136. This is now also fixed. General: - Decreased struct size - Decreased memory allocations - Optimized tokenizer a bit more to only emit tags when all attributes are there and are valid. reqwest/hyper connection issue: The following changes helped solve the connection issues to some sites. The endresult is that some icons are now able to be downloaded always instead of sometimes. - Enabled some extra reqwest features, `deflate` and `native-tls-alpn` (Which do not bring in any extra crates since other crates already enabled them, but they were not active for Vaultwarden it self) - Configured reqwest to have a max amount of idle pool connections per host - Configured reqwest to timeout the idle connections in 10 seconds
2023-07-03Fix dataurl parse panic when icon is malformedDaniel García
2023-06-21Update crates and workflowBlackDex
- Updated all the crates - Updated workflow actions - Set cargo registry to sparse
2023-04-30Change `String` to `&str` for all Rocket functionsBlackDex
During setting the latest commit hash for Rocket and updating all the other crates, there were some messages regarding the usage of `String` for the Rocket endpoint function calls. I acted upon this message and changed all `String` types to `&str` and modified the code where needed. This ended up in less alloc calls, and probably also a bit less memory usage. - Updated all the crates and commit hashes - Modified all `String` to `&str` where applicable
2023-02-07Ensure that all results from check_domain_blacklist_reason are cached.Kevin P. Fleming
2023-02-07Generate distinct log messages for regex vs. IP blacklisting.Kevin P. Fleming
When an icon will not be downloaded due to matching a configured blacklist, ensure that the log message indicates the type of blacklist that was matched.
2023-01-09Resolve uninlined_format_args clippy warningsBlackDex
The upcomming release of Rust 1.67.0 will warn on `uninlined_format_args`. This PR resolves that by inlining all these items. It also looks nicer.
2022-12-02Cleanups and Fixes for Emergency AccessBlackDex
- Several cleanups and code optimizations for Emergency Access - Fixed a race-condition regarding jobs for Emergency Access - Some other small changes like `allow(clippy::)` removals Fixes #2925
2022-11-14Prevent DNS leak when icon regex is configuredBlackDex
When a icon blacklist regex was configured to not check for a domain, it still did a DNS lookup first. This could cause a DNS leakage for these regex blocked domains. This PR resolves this issue by first checking the regex, and afterwards the other checks. Fixes #2909
2022-11-08Update Rust version, deps and workflowBlackDex
- Update Rust to v1.65.0 - Update dependencies - Updated workflow files - Added some extra clippy checks - Fixed some clippy checks
2022-07-17Fix issue with CSP and icon redirectsBlackDex
When using anything else but the `internal` icon service it would trigger an CSP block because the redirects were not allowed. This PR fixes #2623 by dynamically adding the needed CSP strings. This should also work with custom services. For Google i needed to add an extra check because that does a redirect it self to there gstatic.com domain.
2022-07-10Add more clippy checks for better code/readabilityBlackDex
A bit inspired by @paolobarbolini from this commit at lettre https://github.com/lettre/lettre/pull/784 . I added a few more clippy lints here, and fixed the resulted issues. Overall i think this could help in preventing future issues, and maybe even peformance problems. It also makes some code a bit more clear. We could always add more if we want to, i left a few out which i think arn't that huge of an issue. Some like the `unused_async` are nice, which resulted in a few `async` removals. Some others are maybe a bit more estatic, like `string_to_string`, but i think it looks better to use `clone` in those cases instead of `to_string` while they already are a string.
2022-06-25Update dep's and small improvements on faviconsBlackDex
- Updated dependencies (html5gum for favicon downloading) * Also openssl, time, jsonwebtoken and r2d2 - Small optimizations on downloading favicons. It now only emits tokens/tags which needs to be parsed, all others are being skipped. This prevents unneeded items within the for-loop being parsed.
2022-06-04use dashmap in icons blacklist regexDaniel García
2022-02-26Favicon, SMTP and misc updatesBlackDex
Favicon: - Replaced HTML tokenizer, much faster now. - Caching the domain blacklist function. - Almost all functions are async now. - Fixed bug on minimizing data to parse - Changed maximum icon download size to 5MB to match Bitwarden - Added `apple-touch-icon.png` as a second fallback besides `favicon.ico` SMTP: - Deprecated SMTP_SSL and SMTP_EXPLICIT_TLS, replaced with SMTP_SECURITY Misc: - Fixed issue when `resolv.conf` contains errors and trust-dns panics (Fixes #2283) - Updated Javscript and CSS files for admin interface - Fixed an issue with the /admin interface which did not cleared the login cookie correctly - Prevent websocket notifications during org import, this caused a lot of traffic, and slowed down the import. This is also the same as Bitwarden which does not trigger this refresh via websockets. Rust: - Updated to use v1.59 - Use the new `strip` option and enabled to strip `debuginfo` - Enabled `lto` with `thin` - Removed the strip RUN from the alpine armv7, this is now done automatically
2022-01-30Async/Awaited all db methodsBlackDex
This is a rather large PR which updates the async branch to have all the database methods as an async fn. Some iter/map logic needed to be changed to a stream::iter().then(), but besides that most changes were just adding async/await where needed.
2022-01-30Update to rocket 0.5 and made code async, missing updating all db calls, ↵Daniel García
that are currently blocking
2022-01-08Add support for legacy HTTP 301/302 redirects for external iconsJeremy Lin
At least on Android, it seems the Bitwarden mobile client responds to HTTP 307, but not to HTTP 308 for some reason.
2021-12-30Add config option to set the HTTP redirect code for external iconsJeremy Lin
The default code is 307 (temporary) to make it easier to test different icon services, but once a service has been decided on, users should ideally switch to using permanent redirects for cacheability.
2021-12-28Additionally set expires header when caching responsesJake Howard
Browsers are rather smart, but also dumb. This uses the `Expires` header alongside `cache-control` to better prompt the browser to actually cache. Unfortunately, firefox still tries to "race" its own cache, in an attempt to respond to requests faster, so still ends up making a bunch of requests which could have been cached. Doesn't appear there's any way around this.
2021-12-24Small changes to icon log messages.BlackDex
As requested in #2136, some small changes on the type of log messages and wording used. Resolves #2136
2021-12-20Add support for external icon servicesJeremy Lin
If an external icon service is configured, icon requests return an HTTP redirect to the corresponding icon at the external service. An external service may be useful for various reasons, such as if: * The Vaultwarden instance has no external network connectivity. * The Vaultwarden instance has trouble handling large bursts of icon requests. * There are concerns that an attacker may probe the instance to try to detect whether icons for certain sites have been cached, which would suggest that the instance contains entries for those sites. * The external icon service does a better job of providing icons than the built-in fetcher.
2021-09-24Updated icon downloadingBlackDex
- Unicode websites could break (www.post.japanpost.jp for example). regex would fail because it was missing the unicode-perl feature. - Be less verbose in logging with icon downloads - Removed duplicate info/error messages - Added err_silent! macro to help with the less verbose error/info messages.
2021-06-19Fix clippy lintsDaniel García
2021-05-16Updated icon fetching and crates.BlackDex
- Updated some crates - Updated icon fetching code: + Use a cookie jar and set Max-Age to 2 minutes for all cookies + Locate the base href tag to fix some locations + Changed User-Agent (Helps on some sites to get HTML instead of JS) + Reduced HTML code limit from 512KB to 384KB + Allow some large icons higer-up in the sort + Allow GIF images + Ignore cookie_store and hyper::client debug messages
2021-05-08Updated branding, email and cratesBlackDex
- Updated branding for admin and emails - Updated crates and some deprications - Removed newline-converter because this is built-in into lettre - Updated email templates to use a shared header and footer template - Also trigger SMTP SSL When TLS is selected without SSL Resolves #1641
2021-05-02Extract some FromDb trait impls outside the macros so they aren't repeated, ↵Daniel García
and fix some clippy lints
2021-04-15Format the changes from merge to masterDaniel García
2021-04-15Merge branch 'master' into fmtDaniel García
2021-04-06Merge remote-tracking branch 'origin/master' into fmtJake Howard
2021-04-06Modify rustfmt fileJake Howard
2021-04-06Extract client creation to a single placeJake Howard
2021-04-03Updated icon fetching.BlackDex
- Added image type checking, and prevent downloading non images. We didn't checked this before, which could in turn could allow someone to download an arbitrary file. - This also prevents SVG images from being used, while they work on the web-vault and desktop client, they didn't on the mobile versions. - Because of this image type checking we can return a valid file type instead of only 'x-icon' (which is still used as a fallback). - Prevent rel values with `icon-mask`, these are not valid favicons.
2021-03-31Run `cargo fmt` on codebaseJake Howard
2021-03-29Icon and SMTP Debug fixes.BlackDex
- We need to add some feature to enable smtp debugging again. See: https://github.com/lettre/lettre/pull/584 - Upstream added the fallback icon again, probably because of caching ;). See: https://github.com/bitwarden/server/pull/1149 - Enabled gzip and brotli compression support with reqwest. Some sites seem to force this, or assume that because of the User-Agent string it is supported. This caused some failed icons. Fixes #1540
2021-03-28Merge pull request #1546 from RealOrangeOne/clippy-run1.20.0Daniel García
Run Clippy
2021-03-28Icons should always be cached using full TTLJake Howard
2021-03-27Use `if let` moreJake Howard
2021-03-27Cache icons on the clientJake Howard
This should make the vault pages load much faster, and massively reduce the number of requests.
2021-02-07Remove soup and use a newer html5ever directlyDaniel García
2020-12-10Small update on favicon downloadingBlackDex
- Changed the user-agent, which caused at least one site to stall the connection (Same happens on icons.bitwarden.com) - Added default_header creation to the lazy static CLIENT - Added referer passing, which is checked by some sites - Some small other changes
2020-12-08Updated icon downloadingBlackDex
- Added more checks to prevent panics (Removed unwrap) - Try do download from base domain or add www when the provided domain fails - Added some more domain validation checks to prevent errors - Added the ICON_BLACKLIST_REGEX to a Lazy Static HashMap which speeds-up the checks! - Validate the Regex before starting/config change. - Some cleanups - Disabled some noisy debugging from 2 crates.