diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b6352bbb..78e7e79d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,7 +38,7 @@ repos: description: Test the package for errors. entry: cargo test language: system - args: [ "--features", "sqlite,mysql,postgresql", "--" ] + args: [ "--features", "sqlite,mysql,postgresql,enable_mimalloc,s3,unsafe_test_mode", "--" ] types_or: [ rust, toml ] # Cargo.lock matches toml type which is intended pass_filenames: false - id: cargo-clippy @@ -46,7 +46,7 @@ repos: description: Lint Rust sources entry: cargo clippy language: system - args: [ "--features", "sqlite,mysql,postgresql", "--", "-D", "warnings" ] + args: [ "--features", "sqlite,mysql,postgresql,enable_mimalloc,s3,unsafe_test_mode", "--", "-D", "warnings" ] types_or: [ rust, toml ] # Cargo.lock matches toml type which is intended pass_filenames: false - id: check-docker-templates diff --git a/Cargo.lock b/Cargo.lock index 91299665..b027d6fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,7 +15,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ "cfg-if", - "getrandom 0.3.4", "once_cell", "version_check", "zerocopy", @@ -66,11 +65,20 @@ version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" +[[package]] +name = "ar_archive_writer" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523e5e187fff36fcb8d1d19ccf0ca4ca43ec3d158316057f66dc6f72716bc5ec" +dependencies = [ + "object", +] + [[package]] name = "arc-swap" -version = "1.9.3" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380962b3d93b99642e50b9febf72c071e97e8b32d86eae9cf4ef582bb960ae6e" +checksum = "84a22b5d51209f6de83d37a0b33d320acb8da88823e42a94c075140708f032a5" dependencies = [ "rustversion", ] @@ -151,9 +159,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.51" +version = "0.4.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5755640120b24961f8231e05892e4a4f7e0d04e8aeca161508c9c397946970" +checksum = "6ad47a740fb906fffdd891e8b6d5fde2511600f7bfaebd68939fa08a14999459" dependencies = [ "compression-codecs", "compression-core", @@ -163,9 +171,9 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.14.0" +version = "1.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c96bf972d85afc50bf5ab8fe2d54d1586b4e0b46c97c50a0c9e71e2f7bcd812a" +checksum = "f426a31126c735126297bc5ea7a521263c9faff4f63ca415267ee625651c4f37" dependencies = [ "async-task", "concurrent-queue", @@ -210,9 +218,9 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.4.2" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f7f2596bd5b78a9fec8088ccd89180d7f9f55b94b0576823bbbdc72ee8311" +checksum = "0876700b0d007ad25d5508865a4259c3af9af6d296bf663a0d586d0bc3369f6f" dependencies = [ "event-listener 5.4.2", "event-listener-strategy", @@ -318,7 +326,7 @@ checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667" dependencies = [ "proc-macro2", "quote", - "syn 3.0.9", + "syn 3.0.10", ] [[package]] @@ -350,9 +358,9 @@ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] name = "aws-config" -version = "1.13.0" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "939e256cfe0ed68e96d32f194339d88210d5c10685cff0787400158f852c6819" +checksum = "16ec023cac0d0c0432e606a2d14f04eb70d09c71a739a406141e7be6b923ab95" dependencies = [ "aws-credential-types", "aws-runtime", @@ -393,9 +401,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.10.2" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a0cc2144962cc5e358467b16e3d82981b1d424a7c3d34602be0036103814a1a" +checksum = "de8930c11353c72ae54aa24dc94d692df74d59814839cbaf8069d63dbcb4c519" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -418,9 +426,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.119.0" +version = "1.121.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c414f25ec4aa9dc18f5cc8f55e18848bb509fcda4ce7c77bee6072e95806bc9" +checksum = "d8d414ba8f00c2b4b506893ded67827e63be88b5e6cce71b7c0ac8f96ce09bc5" dependencies = [ "arc-swap", "aws-credential-types", @@ -443,9 +451,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.121.0" +version = "1.123.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc638bb4355e6514334dcc3228cd4622f5ee54d704bd6a9010a5a91d7856d9d9" +checksum = "db26187b124bcc637641f7963d5200c5ec2409ea5b7730dd7e014ef4e0ab6f19" dependencies = [ "arc-swap", "aws-credential-types", @@ -459,18 +467,16 @@ dependencies = [ "aws-smithy-schema", "aws-smithy-types", "aws-types", - "bytes", "fastrand", - "http 1.5.0", "regex-lite", "tracing", ] [[package]] name = "aws-sdk-sts" -version = "1.124.0" +version = "1.126.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f8a0dd8fbde04ba58ad722113c7addb11bf94cf549b1ea0eb9ea427fb87198a" +checksum = "c667da7839295125cfe23280f798c07ba694a9fed191af804edb4bda09ac7f10" dependencies = [ "arc-swap", "aws-credential-types", @@ -494,9 +500,9 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "1.6.4" +version = "1.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f385da9b7757ed4c8214797ad663ff534fb622006143530aa80e21f8e06ff85c" +checksum = "57a4393e6addc3380632887b0998d06ad5f099ab5c478be0a3eeedecf8604161" dependencies = [ "aws-credential-types", "aws-smithy-http", @@ -557,11 +563,13 @@ dependencies = [ [[package]] name = "aws-smithy-observability" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e86338c869539a581bf161247762a6e87f92c5c075060057b5ed6d06632ed0c" +checksum = "a416257d7b1b0f32a517a470a8c1dd354d8c4aa697ccab81a11a1e6cfb7418e3" dependencies = [ "aws-smithy-runtime-api", + "aws-smithy-types", + "tracing", ] [[package]] @@ -579,9 +587,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.16.2" +version = "1.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cb80fb19c084da5fca9d797845735e184445e5b958599440d67529bf6ef1b64" +checksum = "5bc688673e282f42d3152dcd9cacc1a9a75734d7cd39d02e58989276fc750f3c" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -601,9 +609,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime-api" -version = "1.19.2" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c4e85cffe9944b10d576b075432bd8f98dbc081e8681cb37d5b2d87dc27bc84" +checksum = "0467a2414e84b1b01e37452896fb3562b93926e81c619eba6ecf27ce9e682a0e" dependencies = [ "aws-smithy-async", "aws-smithy-runtime-api-macros", @@ -629,9 +637,9 @@ dependencies = [ [[package]] name = "aws-smithy-schema" -version = "1.1.2" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9543fc722ed4865ab29fb66bd7ed0bef7b029d265ba8c587144511e30006d431" +checksum = "f7ef30d39e131651359b60a1c560de9a9502a4c3754172ab2d6e8734fe21bcba" dependencies = [ "aws-smithy-runtime-api", "aws-smithy-types", @@ -640,9 +648,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.9.1" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf183d70774ea2cfcc101ca74a8884e4c76be8b9df65cd303f6a1175c88e8f80" +checksum = "aff4bf014c512840b2bba80a20417b723cbd6a0a65c02e2d81f50b4268aedfc7" dependencies = [ "base64-simd", "bytes", @@ -651,7 +659,6 @@ dependencies = [ "http-body", "http-body-util", "itoa", - "num-integer", "pin-project-lite", "ryu", "serde", @@ -685,12 +692,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - [[package]] name = "base16ct" version = "1.0.0" @@ -761,12 +762,6 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "383d29d513d8764dcdc42ea295d979eb99c3c9f00607b3692cf68a431f7dca72" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.13.2" @@ -798,6 +793,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa" dependencies = [ "hybrid-array", + "zeroize", ] [[package]] @@ -815,9 +811,9 @@ dependencies = [ [[package]] name = "brotli" -version = "9.1.1" +version = "9.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "627b7cfb0578f0eafce087a90fcd40add1231900b69e4d4de2d456260a4f5d81" +checksum = "9071f285ed78f04f37d675abaaef5de7689e2f30a216c8dc6795465d81910a13" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -826,9 +822,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "6.2.0" +version = "6.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34c6783f42c21c952ad7112b354f0ba2f10760e9decea5b1b60523d6e270faaf" +checksum = "cc031cd87c6529082b0b65c604e86af0ed7744841b17ccfe60b1e31fa606179e" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -845,9 +841,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.20.3" +version = "3.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" +checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db" [[package]] name = "bytemuck" @@ -877,46 +873,11 @@ dependencies = [ "either", ] -[[package]] -name = "cached" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f886e989b5b6e7991606f2550e45a99e130024465ba8d67f9f9b256eb7044bf" -dependencies = [ - "ahash", - "async-lock", - "cached_proc_macro", - "cached_proc_macro_types", - "hashbrown 0.17.1", - "parking_lot 0.12.5", - "thiserror 2.0.21", - "web-time", -] - -[[package]] -name = "cached_proc_macro" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ece0579b43cf6e927b3370c7d44359c7122e7e52b3ea635bc8484da571442edb" -dependencies = [ - "darling 0.20.11", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "cached_proc_macro_types" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5813789573ae815c8b4be58c4428e0e7ae05f0227678ba9de332ded585b9159" - [[package]] name = "cc" -version = "1.10.0" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86e055fa6e3e40ad6187ba25b6855eeb635d5271f8e0f0e1e9a5826b8d75bea0" +checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45" dependencies = [ "find-msvc-tools", "jobserver", @@ -958,7 +919,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-link", + "windows-link 0.2.1", ] [[package]] @@ -995,9 +956,9 @@ dependencies = [ [[package]] name = "compression-codecs" -version = "0.4.46" +version = "0.4.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cae36683101b2899f48bd31f8db9839437356188e3b1ff23096e73dab09ba8fe" +checksum = "84f840cff84d10085260e460023934d0af699e71212b09b2a41452e8bd9cda43" dependencies = [ "brotli", "compression-core", @@ -1030,9 +991,9 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "const-oid" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c" +checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a" [[package]] name = "const-random" @@ -1160,9 +1121,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.5.3" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ba106e844045ddc02c20768ac4b0b7cb45f2cc2ecbd833ac9f5dacb183c2055" +checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64" dependencies = [ "cfg-if", ] @@ -1217,21 +1178,9 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" [[package]] name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-bigint" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c035cb64cba03dad2fb921f3e218785e8cf9a41790da5eb3a1400f62fa2be11" +checksum = "914c195c4d7fbc5ed7f88d14cbf85914d5c664967658d43404b263913a477e82" dependencies = [ "cpubits", "ctutils", @@ -1239,15 +1188,16 @@ dependencies = [ "hybrid-array", "num-traits", "rand_core 0.10.1", + "serdect", "subtle", "zeroize", ] [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", "typenum", @@ -1265,29 +1215,23 @@ dependencies = [ ] [[package]] -name = "ctutils" -version = "0.4.7" +name = "crypto-primes" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2376ffd6f96d8a9db59875b4b6b0237d6900b5baf64279714e05493ce64828a" +checksum = "3633a51a39c69ebbaa4feaa694bd83d241e4093901c84a0963b19d9bb3f0cf8f" dependencies = [ - "cmov", - "subtle", + "crypto-bigint", + "rand_core 0.10.1", ] [[package]] -name = "curve25519-dalek" -version = "4.1.3" +name = "ctutils" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +checksum = "261af4dc7a06ea8a527a8717d8cbba3417530d6ea14e1edb3de6b67806be474f" dependencies = [ - "cfg-if", - "cpufeatures 0.2.17", - "curve25519-dalek-derive", - "digest 0.10.7", - "fiat-crypto 0.2.9", - "rustc_version", + "cmov", "subtle", - "zeroize", ] [[package]] @@ -1300,7 +1244,7 @@ dependencies = [ "cpufeatures 0.3.1", "curve25519-dalek-derive", "digest 0.11.3", - "fiat-crypto 0.3.0", + "fiat-crypto", "rustc_version", "subtle", "zeroize", @@ -1385,7 +1329,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 3.0.9", + "syn 3.0.10", ] [[package]] @@ -1418,7 +1362,7 @@ checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785" dependencies = [ "darling_core 0.24.1", "quote", - "syn 3.0.9", + "syn 3.0.10", ] [[package]] @@ -1447,37 +1391,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376" -[[package]] -name = "defmt" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a0795ac740cb54d7b3775c9c17345f6aaecf884c01733b39d6017738e0e3e1" -dependencies = [ - "bitflags 1.3.2", - "defmt-macros", -] - -[[package]] -name = "defmt-macros" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "840bb056bd99c495c9188198a258ab787c79f306d864db3e6e8451442d6d8366" -dependencies = [ - "defmt-parser", - "proc-macro2", - "quote", - "syn 3.0.9", -] - -[[package]] -name = "defmt-parser" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71958f69fb2de856c5dd51ac9377e986ca1aa5919f931bf5395a807277f889a0" -dependencies = [ - "thiserror 2.0.21", -] - [[package]] name = "der" version = "0.7.10" @@ -1495,7 +1408,7 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a996a108feb8b427a6e12fcf6af4aa83409b79d72c15337d7741368131ee004" dependencies = [ - "const-oid 0.10.2", + "const-oid 0.10.3", "pem-rfc7468 1.0.0", "zeroize", ] @@ -1603,11 +1516,11 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "970e4b2fcd605ffa79715510663a9fe76b87f5483d59857399129cf047f73d27" dependencies = [ - "bitflags 2.13.2", + "bitflags", "proc-macro2", "proc-macro2-diagnostics 0.11.0", "quote", - "syn 3.0.9", + "syn 3.0.10", ] [[package]] @@ -1617,7 +1530,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebe9f7eaef33febd60290c5a9f3b0571d03c4c04a24739cd64808ce30e65a5d3" dependencies = [ "bigdecimal", - "bitflags 2.13.2", + "bitflags", "byteorder", "chrono", "diesel_derives", @@ -1688,7 +1601,7 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", "const-oid 0.9.6", - "crypto-common 0.1.6", + "crypto-common 0.1.7", "subtle", ] @@ -1699,9 +1612,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" dependencies = [ "block-buffer 0.12.1", - "const-oid 0.10.2", + "const-oid 0.10.3", "crypto-common 0.2.2", "ctutils", + "zeroize", ] [[package]] @@ -1712,7 +1626,7 @@ checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" dependencies = [ "proc-macro2", "quote", - "syn 3.0.9", + "syn 3.0.10", ] [[package]] @@ -1765,20 +1679,6 @@ version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der 0.7.10", - "digest 0.10.7", - "elliptic-curve 0.13.8", - "rfc6979 0.4.0", - "signature 2.2.0", - "spki 0.7.3", -] - [[package]] name = "ecdsa" version = "0.17.0" @@ -1787,23 +1687,13 @@ checksum = "c0681a4fc24c767085329728d8dfba959af91228aa4610cca4f8ce317ba46ae0" dependencies = [ "der 0.8.3", "digest 0.11.3", - "elliptic-curve 0.14.3", - "rfc6979 0.6.0", + "elliptic-curve", + "rfc6979", "signature 3.0.0", "spki 0.8.1", "zeroize", ] -[[package]] -name = "ed25519" -version = "2.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" -dependencies = [ - "pkcs8 0.10.2", - "signature 2.2.0", -] - [[package]] name = "ed25519" version = "3.0.0" @@ -1814,28 +1704,14 @@ dependencies = [ "signature 3.0.0", ] -[[package]] -name = "ed25519-dalek" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" -dependencies = [ - "curve25519-dalek 4.1.3", - "ed25519 2.2.3", - "serde", - "sha2 0.10.9", - "subtle", - "zeroize", -] - [[package]] name = "ed25519-dalek" version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ebaa1a2bf1290ab3bfe5a7b771d050ebffab2711c19a81691c683a5144a25de" dependencies = [ - "curve25519-dalek 5.0.0", - "ed25519 3.0.0", + "curve25519-dalek", + "ed25519", "serde", "sha2 0.11.1", "signature 3.0.0", @@ -1849,53 +1725,32 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct 0.2.0", - "crypto-bigint 0.5.5", - "digest 0.10.7", - "ff 0.13.1", - "generic-array", - "group 0.13.0", - "hkdf", - "pem-rfc7468 0.7.0", - "pkcs8 0.10.2", - "rand_core 0.6.4", - "sec1 0.7.3", - "subtle", - "zeroize", -] - [[package]] name = "elliptic-curve" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "900f37e7e18d74a2347389af6cd69e3a30d5cc9e697f40004865679aa75e9c7c" dependencies = [ - "base16ct 1.0.0", - "crypto-bigint 0.7.10", + "base16ct", + "crypto-bigint", "crypto-common 0.2.2", "digest 0.11.3", - "ff 0.14.0", - "group 0.14.0", + "ff", + "group", "hybrid-array", "pem-rfc7468 1.0.0", "pkcs8 0.11.0", "rand_core 0.10.1", - "sec1 0.8.1", + "sec1", "subtle", "zeroize", ] [[package]] name = "email-encoding" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420b9da095f052ea597503e39073b5b3c522f7db933fbac202d91d24492693fd" +checksum = "9f690ae2169f2ceb3f45b28b6fcd8fa16839f2f5c8818546774b9425f5f71004" dependencies = [ "base64 0.23.1", "memchr", @@ -1932,9 +1787,9 @@ checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" [[package]] name = "errno" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776" dependencies = [ "libc", "windows-sys 0.61.2", @@ -1984,16 +1839,6 @@ dependencies = [ "syslog", ] -[[package]] -name = "ff" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" -dependencies = [ - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "ff" version = "0.14.0" @@ -2004,12 +1849,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "fiat-crypto" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" - [[package]] name = "fiat-crypto" version = "0.3.0" @@ -2038,9 +1877,9 @@ checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" [[package]] name = "flate2" -version = "1.1.10" +version = "1.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e634e2e0ebac1ee034020da1ca582e17ffe4e0f5e985823721e168928136dcb" +checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" dependencies = [ "crc32fast", "miniz_oxide", @@ -2152,7 +1991,7 @@ checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" dependencies = [ "proc-macro2", "quote", - "syn 3.0.9", + "syn 3.0.10", ] [[package]] @@ -2203,15 +2042,28 @@ dependencies = [ "windows", ] +[[package]] +name = "generator" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6c6a73cd1aa4f4f00c02b109fa55d3a9d6ecc2fc4f53177b74ed6ee23b0c53" +dependencies = [ + "cc", + "libc", + "log", + "rustversion", + "windows-core 0.100.0", + "windows-sys 0.61.2", +] + [[package]] name = "generic-array" -version = "0.14.9" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -2309,24 +2161,13 @@ dependencies = [ "phf 0.11.3", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff 0.13.1", - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "group" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fd1a1c7a5206c5b7a3f5a0d7ccd3ff85d0c8f5133d62a02680255b0004af5f4" dependencies = [ - "ff 0.14.0", + "ff", "rand_core 0.10.1", "subtle", ] @@ -2410,11 +2251,6 @@ name = "hashbrown" version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" -dependencies = [ - "allocator-api2", - "equivalent", - "foldhash", -] [[package]] name = "heck" @@ -2450,7 +2286,7 @@ dependencies = [ "idna", "ipnet", "jni", - "rand 0.10.3", + "rand 0.10.4", "thiserror 2.0.21", "tinyvec", "tokio", @@ -2470,7 +2306,7 @@ dependencies = [ "jni", "once_cell", "prefix-trie", - "rand 0.10.3", + "rand 0.10.4", "ring", "thiserror 2.0.21", "tinyvec", @@ -2495,7 +2331,7 @@ dependencies = [ "ndk-context", "once_cell", "parking_lot 0.12.5", - "rand 0.10.3", + "rand 0.10.4", "resolv-conf", "smallvec", "system-configuration", @@ -2504,15 +2340,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "hkdf" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" -dependencies = [ - "hmac 0.12.1", -] - [[package]] name = "hmac" version = "0.12.1" @@ -2539,14 +2366,14 @@ checksum = "617aaa3557aef3810a6369d0a99fac8a080891b68bd9f9812a1eeda0c0730cbd" dependencies = [ "cfg-if", "libc", - "windows-link", + "windows-link 0.2.1", ] [[package]] name = "html5gum" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae3133814a10216af5242a254420a74cb0d2f7715646924f5a8e7720cd188b" +checksum = "469fd7ad11d167b79385adccbba0fae87a50a9adb0c081e8ce7b130faa51f3bb" [[package]] name = "http" @@ -2690,7 +2517,7 @@ dependencies = [ "js-sys", "log", "wasm-bindgen", - "windows-core", + "windows-core 0.62.2", ] [[package]] @@ -2850,7 +2677,7 @@ dependencies = [ "socket2", "widestring", "windows-registry", - "windows-result", + "windows-result 0.4.1", "windows-sys 0.61.2", ] @@ -2885,17 +2712,16 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" [[package]] name = "jiff" -version = "0.2.38" +version = "0.2.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b005715dcbeb0089a3c0dab99f2ff1cc3b2525323552703d648585d342a383" +checksum = "175dc66334db3b9ab9985bf8b61cfed50dc16d20964bb47f9e479adcae984a7f" dependencies = [ - "defmt", "jiff-core", "jiff-static", "jiff-tzdb-platform", @@ -2905,24 +2731,23 @@ dependencies = [ "portable-atomic-util", "serde_core", "wasm-bindgen", - "windows-link", + "windows-link 0.2.1", ] [[package]] name = "jiff-core" -version = "0.1.1" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e52fe76043ccecc9005d2305ebaadf7d7fc0cc89ca6baa10a94d6bc68c7128c" +checksum = "e599b80292e597019b8b3e392de3f4bea2959ddfb8c7dff60e035e9e311a2c1b" dependencies = [ - "defmt", "log", ] [[package]] name = "jiff-static" -version = "0.2.38" +version = "0.2.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc9817253cf7c7ee4684451bd327e88d6f3658014e54a29198625590650695c" +checksum = "c7b1af7547d47354bc438d797e3854601bde8f8d185780c5ba4ab27afa54f1ba" dependencies = [ "jiff-core", "proc-macro2", @@ -2932,9 +2757,9 @@ dependencies = [ [[package]] name = "jiff-tzdb" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8377070c6bae868759445e5a77f66d84f0b72f3a054bfb00e6d038b8282da7" +checksum = "0980fca2cc272465bd60e82397607ba9f33add9e48defd77923301bbd03808f2" [[package]] name = "jiff-tzdb-platform" @@ -2959,7 +2784,7 @@ dependencies = [ "simd_cesu8", "thiserror 2.0.21", "walkdir", - "windows-link", + "windows-link 0.2.1", ] [[package]] @@ -3028,24 +2853,23 @@ dependencies = [ [[package]] name = "jsonwebtoken" -version = "11.1.0" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e75fe14a82d81e5f5af639997db37d8b96045938a7ac6ab18cdbe1c7467e05e1" +checksum = "f347a975eb5fa8f5c4eadce6c1152c11c326cf32cf839fb64ff12d5cb8f4ce8b" dependencies = [ - "base64 0.22.1", - "ed25519-dalek 2.2.0", - "getrandom 0.2.17", - "hmac 0.12.1", + "base64 0.23.1", + "ed25519-dalek", + "getrandom 0.4.3", + "hmac 0.13.0", "js-sys", - "p256 0.13.2", - "p384 0.13.1", + "p256", + "p384", "pem", - "rand 0.8.8", - "rsa", + "rsa 0.10.0", "serde", "serde_json", - "sha2 0.10.9", - "signature 2.2.0", + "sha2 0.11.1", + "signature 3.0.0", "simple_asn1", "zeroize", ] @@ -3192,7 +3016,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff50ecb28bb86013e935fb6683ab1f6d3a20016f123c76fd4c27470076ac30f5" dependencies = [ "cfg-if", - "generator", + "generator 0.7.5", "scoped-tls", "serde", "serde_json", @@ -3200,12 +3024,25 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "loom" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1611ddbf89dc6ae42cfbd51fc207836140130257646eab8d6d2fb16577db2d2" +dependencies = [ + "cfg-if", + "generator 0.8.12", + "scoped-tls", + "tracing", + "tracing-subscriber", +] + [[package]] name = "macros" version = "0.1.0" dependencies = [ "quote", - "syn 3.0.9", + "syn 3.0.10", ] [[package]] @@ -3252,7 +3089,7 @@ dependencies = [ "migrations_internals", "proc-macro2", "quote", - "syn 3.0.9", + "syn 3.0.10", ] [[package]] @@ -3266,9 +3103,9 @@ dependencies = [ [[package]] name = "mime" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +checksum = "d5848f5a9e8117cf94f2f90faac24a87ff81600ff8628c1e3deaab572e76bfa1" [[package]] name = "minimal-lexical" @@ -3288,9 +3125,9 @@ dependencies = [ [[package]] name = "mio" -version = "1.2.4" +version = "1.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee" +checksum = "20521a903f02b0a573cd6840e9d0a5a0cc043d361fe924092cd70f8556cc9c4a" dependencies = [ "libc", "wasi", @@ -3344,9 +3181,9 @@ checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" [[package]] name = "mysqlclient-sys" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b72511f8f6991fe4ac86421ea0625630fd94e360b906cc59720506499f9e8f3b" +checksum = "48127dad9288a08350c34c6d9e17616420569cd24db43148bf223baac82fbb93" dependencies = [ "pkg-config", "semver", @@ -3361,11 +3198,11 @@ checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" [[package]] name = "nix" -version = "0.31.3" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d" +checksum = "77730ed34f01f4990cb2ea67fec715ecebc6fab9a6396cf83c5529b13f581bdc" dependencies = [ - "bitflags 2.13.2", + "bitflags", "cfg-if", "cfg_aliases", "libc", @@ -3445,7 +3282,7 @@ checksum = "e4e98dc3b890f6c23a0f9d3d491a2823d0dea0fa656302a13dd225fa924112a8" dependencies = [ "proc-macro2", "quote", - "syn 3.0.9", + "syn 3.0.10", ] [[package]] @@ -3530,6 +3367,15 @@ dependencies = [ "url", ] +[[package]] +name = "object" +version = "0.39.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e5a6c098c7a3b6547378093f5cc30bc54fd361ce711e05293a5cc589562739b" +dependencies = [ + "memchr", +] + [[package]] name = "oid-registry" version = "0.7.1" @@ -3644,17 +3490,17 @@ dependencies = [ "base64 0.22.1", "chrono", "dyn-clone", - "ed25519-dalek 3.0.0", + "ed25519-dalek", "getrandom 0.4.3", "hmac 0.12.1", "http 1.5.0", "itertools", "log", "oauth2", - "p256 0.14.0", - "p384 0.14.0", + "p256", + "p384", "rand 0.8.8", - "rsa", + "rsa 0.9.10", "serde", "serde-value", "serde_json", @@ -3669,11 +3515,11 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.81" +version = "0.10.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77823a27f0babb03091cb9ed9ef80af3b39dbc82f97e8fa530374b7dafd87a45" +checksum = "4de8111e94a56adca7ebfe6c365b6d42f99deb69b74b6becacd4204e2f193aa2" dependencies = [ - "bitflags 2.13.2", + "bitflags", "cfg-if", "foreign-types", "libc", @@ -3709,9 +3555,9 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.9.117" +version = "0.9.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b47e7e6bb2c38cd930d25a23b40fa52e068c10e85f3e03a7f5ba5aaca5713695" +checksum = "19c413d6ec9ebaf5e1c829d355cb3e9f783778d700f135be0921d52fce3c60ae" dependencies = [ "cc", "libc", @@ -3745,54 +3591,30 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a80800c0488c3a21695ea981a54918fbb37abf04f4d0720c453632255e2ff0e" -[[package]] -name = "p256" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" -dependencies = [ - "ecdsa 0.16.9", - "elliptic-curve 0.13.8", - "primeorder 0.13.6", - "sha2 0.10.9", -] - [[package]] name = "p256" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2c9239b2dbc807adbbe147e8cf72ea7450c3a0aabe62cb8e75ff4ec22e1f72a" dependencies = [ - "ecdsa 0.17.0", - "elliptic-curve 0.14.3", + "ecdsa", + "elliptic-curve", "primefield", - "primeorder 0.14.0", + "primeorder", "sha2 0.11.1", ] -[[package]] -name = "p384" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe42f1670a52a47d448f14b6a5c61dd78fce51856e68edaa38f7ae3a46b8d6b6" -dependencies = [ - "ecdsa 0.16.9", - "elliptic-curve 0.13.8", - "primeorder 0.13.6", - "sha2 0.10.9", -] - [[package]] name = "p384" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d17b851e6b3e378ab4ecb07fa2ed23f4d15f075735f8fec9fa1e7bdce5f8301f" dependencies = [ - "ecdsa 0.17.0", - "elliptic-curve 0.14.3", - "fiat-crypto 0.3.0", + "ecdsa", + "elliptic-curve", + "fiat-crypto", "primefield", - "primeorder 0.14.0", + "primeorder", "sha2 0.11.1", ] @@ -3832,7 +3654,7 @@ dependencies = [ "libc", "redox_syscall 0.5.18", "smallvec", - "windows-link", + "windows-link 0.2.1", ] [[package]] @@ -3844,7 +3666,7 @@ dependencies = [ "libc", "redox_syscall 0.9.5", "smallvec", - "windows-link", + "windows-link 0.2.1", ] [[package]] @@ -3912,16 +3734,16 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics 0.11.0", "quote", - "syn 3.0.9", + "syn 3.0.10", ] [[package]] name = "pem" -version = "3.0.6" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be" +checksum = "d354a98a3d1251555de99e8fdd8afda05573c31b82f59063a7b0a29b5527f120" dependencies = [ - "base64 0.22.1", + "base64 0.23.1", "serde_core", ] @@ -3951,9 +3773,9 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pest" -version = "2.9.5" +version = "2.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8db75153506001cb36ed924f08cadc862eb3f8c4d0d534139f29074769d7660" +checksum = "5ec53fd1d256900a9a771bf2720d42cef6f8bc91b4e25065fbd291e3e7222576" dependencies = [ "memchr", "pest_stack_guard", @@ -3962,9 +3784,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.9.5" +version = "2.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20aa17e11fb35664b67d5214a0afac57a360d231b6ec53d6eba0700b27d933b4" +checksum = "adcf794fd301ddc20818a6b4de85ed507f4b45300245cec948982e69e12e3bd7" dependencies = [ "pest", "pest_generator", @@ -3972,31 +3794,31 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.9.5" +version = "2.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "626ec5afccf44ccbfeb2b232316510bb55b4bf34d891afcb0fb07d2b17d7fe9d" +checksum = "c3073afae5db334c25dea9fc3e230a4f191e920c1df080cb9c0b37c9ce1dbb41" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 3.0.9", + "syn 3.0.10", ] [[package]] name = "pest_meta" -version = "2.9.5" +version = "2.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3f45b6caa65c1b08186832745159c2529994146340a7bf44168095469720f5d" +checksum = "7bc7f614b3742541642af1685faaa910bf6333e3cd3729c2cccd118146a57327" dependencies = [ "pest", ] [[package]] name = "pest_stack_guard" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97e6cd2217057fa86b6eaa512917e58089d875b957a31e35e7ab729977e0a5f2" +checksum = "9ac6154fd4418b8f0b82532c59c26f303f9ca59a64c883e8ce3971fd82733439" dependencies = [ "psm", "stacker", @@ -4113,6 +3935,16 @@ dependencies = [ "spki 0.7.3", ] +[[package]] +name = "pkcs1" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6250dd7321adbe93d12b750aee0ced159fd13e77f625edcdf1cb6f83cd99f650" +dependencies = [ + "der 0.8.3", + "spki 0.8.1", +] + [[package]] name = "pkcs8" version = "0.10.2" @@ -4220,45 +4052,27 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c555a6e4eb7d4e158fcb028c835c3b8642206ddc279b5c6b202ef9a8bdb592f4" dependencies = [ - "crypto-bigint 0.7.10", + "crypto-bigint", "crypto-common 0.2.2", - "ff 0.14.0", + "ff", "rand_core 0.10.1", "subtle", "zeroize", ] -[[package]] -name = "primeorder" -version = "0.13.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" -dependencies = [ - "elliptic-curve 0.13.8", -] - [[package]] name = "primeorder" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c9f42978c78a00e3d68f69fc03e57a234debae69da4020a4fb588fcdcd07b06" dependencies = [ - "elliptic-curve 0.14.3", + "elliptic-curve", "once_cell", "primefield", "serdect", "wnaf", ] -[[package]] -name = "proc-macro-crate" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" -dependencies = [ - "toml_edit 0.25.17+spec-1.1.0", -] - [[package]] name = "proc-macro2" version = "1.0.107" @@ -4289,7 +4103,7 @@ checksum = "df921e1ef974ebc8dd9effdb0c037a96928ae8cbf871438e02d6fd67204b595e" dependencies = [ "proc-macro2", "quote", - "syn 3.0.9", + "syn 3.0.10", "version_check", ] @@ -4301,10 +4115,11 @@ checksum = "33cb294fe86a74cbcf50d4445b37da762029549ebeea341421c7c70370f86cac" [[package]] name = "psm" -version = "0.1.24" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "200b9ff220857e53e184257720a14553b2f4aa02577d2ed9842d45d4b9654810" +checksum = "4dcd034599e63b970727f70d79e02d62390a4a84f7c6b827c27c46d5ac3fa622" dependencies = [ + "ar_archive_writer", "cc", ] @@ -4410,9 +4225,9 @@ dependencies = [ [[package]] name = "rand" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af" +checksum = "8f6fa277c67e6ea590466f04c3fe82cb509f0864fe470643e5570de9514a9b11" dependencies = [ "chacha20", "getrandom 0.4.3", @@ -4469,7 +4284,7 @@ version = "11.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "498cd0dc59d73224351ee52a95fee0f1a617a2eae0e7d9d720cc622c73a54186" dependencies = [ - "bitflags 2.13.2", + "bitflags", ] [[package]] @@ -4478,7 +4293,7 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.13.2", + "bitflags", ] [[package]] @@ -4487,7 +4302,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "580c875845b41ecb1564ad1ae4703044cef774145e3d7a94dc2b3fa7c97868fd" dependencies = [ - "bitflags 2.13.2", + "bitflags", ] [[package]] @@ -4507,14 +4322,17 @@ checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a" dependencies = [ "proc-macro2", "quote", - "syn 3.0.9", + "syn 3.0.10", ] [[package]] name = "ref-swap" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09c30c54dffee5b40af088d5d50aa3455c91a0127164b51f0215efc4cb28fb3c" +checksum = "2bae17046b1c8a87f555f61804da1775a44b4449c7de6bca0e7485e68e5a145b" +dependencies = [ + "loom 0.7.3", +] [[package]] name = "regex" @@ -4681,23 +4499,13 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e061d1b48cb8d38042de4ae0a7a6401009d6143dc80d2e2d6f31f0bdd6470c7" -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac 0.12.1", - "subtle", -] - [[package]] name = "rfc6979" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4a459cddafb3fe76b31fd8f1108007566c40301feb64dc7b54656eb7388172b" dependencies = [ - "crypto-bigint 0.7.10", + "crypto-bigint", "hmac 0.13.0", ] @@ -4785,7 +4593,7 @@ dependencies = [ "proc-macro2-diagnostics 0.11.0", "quote", "rocket_http", - "syn 3.0.9", + "syn 3.0.10", "unicode-xid", "version_check", ] @@ -4833,9 +4641,9 @@ dependencies = [ [[package]] name = "rpassword" -version = "7.5.4" +version = "7.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da316a15f47e3d053de9cb2c439650bd8fa4aaeb9365f2e5f27f492ff73c196" +checksum = "1fa2c5d9304b618df61ff17f3d3485c6e1854a3d94902a49abbb8d43dfbe0464" dependencies = [ "libc", "rtoolbox", @@ -4853,7 +4661,7 @@ dependencies = [ "num-bigint-dig", "num-integer", "num-traits", - "pkcs1", + "pkcs1 0.7.5", "pkcs8 0.10.2", "rand_core 0.6.4", "signature 2.2.0", @@ -4862,6 +4670,27 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rsa" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23e77fd77e0dea28b3011fd62d15445b7de7959333b0276d930e03be0f755699" +dependencies = [ + "const-oid 0.10.3", + "crypto-bigint", + "crypto-common 0.2.2", + "crypto-primes", + "digest 0.11.3", + "hmac 0.13.0", + "pkcs1 0.8.0", + "pkcs8 0.11.0", + "rand_core 0.10.1", + "sha2 0.11.1", + "signature 3.0.0", + "spki 0.8.1", + "zeroize", +] + [[package]] name = "rsqlite-vfs" version = "0.2.0" @@ -4915,7 +4744,7 @@ version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" dependencies = [ - "bitflags 2.13.2", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -4951,9 +4780,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.15.1" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" +checksum = "102f35f7de7b06d8c61f1cff6592f5253e0dea431c74867aad5dfd70f44663fb" dependencies = [ "zeroize", ] @@ -4987,9 +4816,9 @@ checksum = "eec689c0bc40ff2458a5977b6619cb718087084a18e02a131c599b62d05e1a5f" [[package]] name = "rustls-webpki" -version = "0.103.16" +version = "0.103.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281" +checksum = "e3a0760a887c14823fca5a1c970b01d47c328c696c0c64829d1df50e8f853fd5" dependencies = [ "ring", "rustls-pki-types", @@ -5071,27 +4900,13 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct 0.2.0", - "der 0.7.10", - "generic-array", - "pkcs8 0.10.2", - "subtle", - "zeroize", -] - [[package]] name = "sec1" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d56d437c2f19203ce5f7122e507831de96f3d2d4d3be5af44a0b0a09d8a80e4d" dependencies = [ - "base16ct 1.0.0", + "base16ct", "ctutils", "der 0.8.3", "hybrid-array", @@ -5105,7 +4920,7 @@ version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ - "bitflags 2.13.2", + "bitflags", "core-foundation 0.10.1", "core-foundation-sys", "libc", @@ -5175,7 +4990,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn 3.0.9", + "syn 3.0.10", ] [[package]] @@ -5222,9 +5037,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7523beb55eece201a2356bee0bbca0d1ab466c14c07703b2e0ee6d42cb0c2c" +checksum = "9c187e0a369471c550af028cba56d4f4fa2a489ad28151ae95a4d340a2a8b782" dependencies = [ "serde_core", ] @@ -5271,7 +5086,7 @@ dependencies = [ "darling 0.24.1", "proc-macro2", "quote", - "syn 3.0.9", + "syn 3.0.10", ] [[package]] @@ -5280,7 +5095,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66cf8fedced2fcf12406bcb34223dffb92eaf34908ede12fed414c82b7f00b3e" dependencies = [ - "base16ct 1.0.0", + "base16ct", "serde", ] @@ -5431,9 +5246,9 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "smallvec" -version = "1.16.4" +version = "1.16.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8" +checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46" [[package]] name = "socket2" @@ -5488,9 +5303,9 @@ dependencies = [ [[package]] name = "sqlite-wasm-rs" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36bd8e29bf08189a005b2df1df99823aa0861cabe9044e5f31ed54ca292ee618" +checksum = "a6cd504cecbfe7eef649988840f9a6cb768d11085efec138f8e99f160632d867" dependencies = [ "cc", "rsqlite-vfs", @@ -5530,7 +5345,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b8c4a4445d81357df8b1a650d0d0d6fbbbfe99d064aa5e02f3e4022061476d8" dependencies = [ - "loom", + "loom 0.5.6", ] [[package]] @@ -5571,9 +5386,9 @@ dependencies = [ [[package]] name = "syn" -version = "3.0.9" +version = "3.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" dependencies = [ "proc-macro2", "quote", @@ -5608,7 +5423,7 @@ checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" dependencies = [ "proc-macro2", "quote", - "syn 3.0.9", + "syn 3.0.10", ] [[package]] @@ -5629,7 +5444,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b" dependencies = [ - "bitflags 2.13.2", + "bitflags", "core-foundation 0.9.4", "system-configuration-sys", ] @@ -5700,7 +5515,7 @@ checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" dependencies = [ "proc-macro2", "quote", - "syn 3.0.9", + "syn 3.0.10", ] [[package]] @@ -5794,7 +5609,7 @@ checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" dependencies = [ "proc-macro2", "quote", - "syn 3.0.9", + "syn 3.0.10", ] [[package]] @@ -5854,7 +5669,7 @@ dependencies = [ "serde", "serde_spanned 0.6.9", "toml_datetime 0.6.11", - "toml_edit 0.22.27", + "toml_edit", ] [[package]] @@ -5864,7 +5679,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf92845e79fc2e2def6a5d828f0801e29a2f8acc037becc5ab08595c7d5e9863" dependencies = [ "serde_core", - "serde_spanned 1.1.2", + "serde_spanned 1.1.3", "toml_datetime 0.7.5+spec-1.1.0", "toml_parser", "winnow 0.7.15", @@ -5888,15 +5703,6 @@ dependencies = [ "serde_core", ] -[[package]] -name = "toml_datetime" -version = "1.1.2+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b86d767906c6c42421dcba507eb9d203e779497710a47782a224bb871653053" -dependencies = [ - "serde_core", -] - [[package]] name = "toml_edit" version = "0.22.27" @@ -5911,25 +5717,13 @@ dependencies = [ "winnow 0.7.15", ] -[[package]] -name = "toml_edit" -version = "0.25.17+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3641d5bbb5349a79e1020a242d251efbc546ad8048d133958323ce9c40a9c9c" -dependencies = [ - "indexmap 2.14.2", - "toml_datetime 1.1.2+spec-1.1.0", - "toml_parser", - "winnow 1.0.4", -] - [[package]] name = "toml_parser" version = "1.1.5+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" dependencies = [ - "winnow 1.0.4", + "winnow 1.0.5", ] [[package]] @@ -5972,7 +5766,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" dependencies = [ "async-compression", - "bitflags 2.13.2", + "bitflags", "bytes", "futures-core", "futures-util", @@ -6184,9 +5978,9 @@ checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6" [[package]] name = "uuid" -version = "1.29.0" +version = "1.29.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a0e2d11620c50695fe12bbbfde96b3477fe606e7284c22d505c12ce51214514" +checksum = "bed99139f7dac9b5cfe5f17be4d66dc7079a34dee1d74bcc77217119240e267c" dependencies = [ "getrandom 0.4.3", "js-sys", @@ -6216,7 +6010,6 @@ dependencies = [ "aws-smithy-runtime-api", "bigdecimal", "bytes", - "cached", "chrono", "chrono-tz", "cookie", @@ -6237,7 +6030,6 @@ dependencies = [ "handlebars", "hickory-resolver", "html5gum", - "http 1.5.0", "ipnet", "job_scheduler_ng", "jsonwebtoken", @@ -6257,7 +6049,7 @@ dependencies = [ "pastey 0.2.3", "percent-encoding", "pico-args", - "rand 0.10.3", + "rand 0.10.4", "regex", "reqsign-aws-v4", "reqsign-core", @@ -6275,7 +6067,6 @@ dependencies = [ "subtle", "svg-hush", "syslog", - "time", "tokio", "tokio-util", "totp-lite", @@ -6383,7 +6174,7 @@ dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 3.0.9", + "syn 3.0.10", "wasm-bindgen-shared", ] @@ -6499,9 +6290,9 @@ dependencies = [ [[package]] name = "webpki-root-certs" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e49d0e65abc00c142e8f9428da991da9f1a250c39be97459901eb12b9b49f62a" +checksum = "293198dcebfb821155b5092ab94b5a82ff180eddd7241df3bd6e66a4ffd1a585" dependencies = [ "rustls-pki-types", ] @@ -6567,11 +6358,24 @@ version = "0.62.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" dependencies = [ - "windows-implement", - "windows-interface", - "windows-link", - "windows-result", - "windows-strings", + "windows-implement 0.60.2", + "windows-interface 0.59.3", + "windows-link 0.2.1", + "windows-result 0.4.1", + "windows-strings 0.5.1", +] + +[[package]] +name = "windows-core" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "803590c6856f51d15fa2e9fabe4f4703122c8737f72ef2741b4ac09d4c2192f5" +dependencies = [ + "windows-implement 0.100.0", + "windows-interface 0.100.0", + "windows-link 0.100.0", + "windows-result 0.100.0", + "windows-strings 0.100.0", ] [[package]] @@ -6585,6 +6389,17 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "windows-implement" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc1bc82e5a1b1a4d7255861b07881a0407b552f50a4d8543c0c7276fa96f6e8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "windows-interface" version = "0.59.3" @@ -6596,21 +6411,38 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "windows-interface" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3f7005c3b757b9b82c2f40c0e71094ff1080adddaf3e8b6ce99b545d3c48796" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "windows-link" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" +[[package]] +name = "windows-link" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b39de7c7fe78858b0144c50c3fc000bab3be17d5e9b85b1053871693c7f7415" + [[package]] name = "windows-registry" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" dependencies = [ - "windows-link", - "windows-result", - "windows-strings", + "windows-link 0.2.1", + "windows-result 0.4.1", + "windows-strings 0.5.1", ] [[package]] @@ -6619,7 +6451,16 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" dependencies = [ - "windows-link", + "windows-link 0.2.1", +] + +[[package]] +name = "windows-result" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44873a1ef61c85d5e2991db91fe656cfcf0731097e00dff1ac860f1cb3b752a0" +dependencies = [ + "windows-link 0.100.0", ] [[package]] @@ -6628,7 +6469,16 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" dependencies = [ - "windows-link", + "windows-link 0.2.1", +] + +[[package]] +name = "windows-strings" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a70b590c684f1d2854f74999896f7c0558f1bdde62f599088599e20ea1d2f60" +dependencies = [ + "windows-link 0.100.0", ] [[package]] @@ -6646,7 +6496,7 @@ version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows-link", + "windows-link 0.2.1", ] [[package]] @@ -6781,12 +6631,9 @@ dependencies = [ [[package]] name = "winnow" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" -dependencies = [ - "memchr", -] +checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef" [[package]] name = "wit-bindgen" @@ -6800,8 +6647,8 @@ version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "795ca18b3fdb5e62bf982199278341ddcf7ebf7d32e25e212ad05d496e95f6fa" dependencies = [ - "ff 0.14.0", - "group 0.14.0", + "ff", + "group", "hybrid-array", "primefield", ] @@ -6879,7 +6726,7 @@ checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" dependencies = [ "proc-macro2", "quote", - "syn 3.0.9", + "syn 3.0.10", "synstructure 0.14.0", ] @@ -6933,7 +6780,7 @@ checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" dependencies = [ "proc-macro2", "quote", - "syn 3.0.9", + "syn 3.0.10", "synstructure 0.14.0", ] @@ -6987,7 +6834,7 @@ checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" dependencies = [ "proc-macro2", "quote", - "syn 3.0.9", + "syn 3.0.10", ] [[package]] @@ -7004,27 +6851,27 @@ checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" [[package]] name = "zstd" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3ae9bf90af6e40197bef767eeefc46ad6397420fe873830bd85e5fbbfb3c70" +checksum = "ad5020ab8f27bfc0024ad0a07aed6bf022a16208f479686fbed4fdd0c85eb0b3" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "8.2.0" +version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded520f16b29e1a9b771c722221b2b0a0398c2316d9bb3c42b458a5414d7434b" +checksum = "5a9ea9cc2576c2fcc104e9cec04f46e3ede564f4fbc206831e4ef7e859a4140d" dependencies = [ "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.1.2+zstd.1.5.7" +version = "2.1.3+zstd.1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "481ada9c543b2323cbb7bbdbb5249177fbf0188ed959ed2c15e4b22421c84ed3" +checksum = "f729a06d0257428fd9d997ac8db7e1407bd0262ab016b085b36bc52957c0052d" dependencies = [ "cc", "pkg-config", diff --git a/Cargo.toml b/Cargo.toml index e677b162..4dbb3a81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace.package] edition = "2024" -rust-version = "1.97.1" +rust-version = "1.98.1" license = "AGPL-3.0-only" repository = "https://github.com/dani-garcia/vaultwarden" publish = false @@ -44,7 +44,6 @@ s3 = [ "dep:aws-config", "dep:aws-credential-types", "dep:aws-smithy-runtime-api", - "dep:http", "dep:reqsign-aws-v4", "dep:reqsign-core", ] @@ -61,7 +60,7 @@ unstable = [] unsafe_test_mode = ["dep:serde_cbor_2"] [target."cfg(unix)".dependencies] -nix = { version = "0.31.3", features = ["fs"] } +nix = { version = "0.32.0", features = ["fs"] } # Logging syslog = "7.0.0" @@ -126,18 +125,17 @@ diesel-derive-newtype = "2.1.3" libsqlite3-sys = { version = "0.38.2", optional = true } # Crypto-related libraries -rand = "0.10.3" +rand = "0.10.4" ring = "0.17.14" rustls = { version = "0.23.46", features = ["ring", "std"], default-features = false } subtle = "2.6.1" # UUID generation -uuid = { version = "1.29.0", features = ["v4"] } +uuid = { version = "1.29.2", features = ["v4"] } # Date and time libraries chrono = { version = "0.4.45", default-features = false, features = ["clock", "serde"] } chrono-tz = "0.10.4" -time = "0.3.55" # Job scheduler job_scheduler_ng = "2.5.0" @@ -146,7 +144,7 @@ job_scheduler_ng = "2.5.0" data-encoding = "2.11.1" # JWT library -jsonwebtoken = { version = "11.1.0", default-features = false, features = ["rust_crypto", "use_pem"] } +jsonwebtoken = { version = "12.0.0", default-features = false, features = ["rust_crypto", "use_pem"] } # TOTP library totp-lite = "2.0.1" @@ -208,7 +206,7 @@ reqwest = { version = "0.13.5", default-features = false, features = [ hickory-resolver = "0.26.3" # Favicon extraction libraries -html5gum = "0.9.0" +html5gum = "0.9.1" regex = { version = "1.13.1", default-features = false, features = [ "perf", "std", @@ -218,15 +216,12 @@ data-url = "0.3.2" bytes = "1.12.1" svg-hush = "0.9.7" -# Cache function results (Used for version check and favicon fetching) -cached = { version = "4.1.0", features = ["async"] } - # Used for custom short lived cookie jar during favicon extraction cookie = "0.18.2" cookie_store = "0.22.1" # Used by U2F, JWT and PostgreSQL -openssl = "0.10.81" +openssl = "0.10.82" # CLI argument parsing pico-args = "0.5.0" @@ -240,6 +235,8 @@ ipnet = "2.12.2" # OIDC for SSO openidconnect = { version = "4.1.0", default-features = false } + +# Used for caching for ODIC/SSO and Admin version check moka = { version = "0.12.16", features = ["future"] } # Check client versions for specific features. @@ -255,7 +252,7 @@ which = "8.0.6" argon2 = "0.6.0" # Reading a password from the cli for generating the Argon2id ADMIN_TOKEN -rpassword = "7.5.4" +rpassword = "7.5.5" # Loading a dynamic CSS Stylesheet grass_compiler = { version = "0.13.4", default-features = false } @@ -265,15 +262,14 @@ opendal = { version = "0.59.5", default-features = false, features = ["services- opendal-http-transport-reqwest = { version = "0.59.5", default-features = false, features = ["rustls-no-provider"], optional = true } # For retrieving AWS credentials, including temporary SSO credentials -aws-config = { version = "1.13.0", optional = true, default-features = false, features = [ +aws-config = { version = "1.13.2", optional = true, default-features = false, features = [ "behavior-version-latest", "credentials-process", "rt-tokio", "sso", ] } aws-credential-types = { version = "1.3.1", optional = true } -aws-smithy-runtime-api = { version = "1.19.2", optional = true } -http = { version = "1.5.0", optional = true } +aws-smithy-runtime-api = { version = "1.21.0", optional = true } reqsign-aws-v4 = { version = "3.3.1", optional = true } reqsign-core = { version = "3.3.2", optional = true } @@ -330,6 +326,14 @@ opt-level = 3 # Linting config # https://doc.rust-lang.org/rustc/lints/groups.html [workspace.lints.rust] +# Features +unexpected_cfgs = { level = "warn", check-cfg = [ + 'cfg(sqlite)', + 'cfg(mysql)', + 'cfg(postgresql)', + 'cfg(s3)', +] } + # Forbid unsafe_code = "forbid" non_ascii_idents = "forbid" @@ -359,6 +363,7 @@ unused_import_braces = "deny" unused_lifetimes = "deny" unused_qualifications = "deny" variant_size_differences = "deny" +redundant_imports = "deny" # https://rust-lang.github.io/rust-clippy/stable/index.html [workspace.lints.clippy] @@ -386,11 +391,15 @@ iter_on_empty_collections = "deny" iter_on_single_items = "deny" mem_forget = "deny" needless_collect = "deny" +needless_pass_by_ref_mut = "deny" +or_fun_call = "deny" redundant_clone = "deny" +significant_drop_in_scrutinee = "deny" +str_to_string = "deny" unnecessary_self_imports = "deny" +use_self = "deny" useless_let_if_seq = "deny" verbose_file_reads = "deny" -str_to_string = "deny" # Pedantic Opt-Outs inline_always = "allow" # We use this sparsely diff --git a/build.rs b/build.rs index 32fcf845..bb6038dc 100644 --- a/build.rs +++ b/build.rs @@ -16,13 +16,6 @@ fn main() { #[cfg(feature = "s3")] println!("cargo:rustc-cfg=s3"); - // Use check-cfg to let cargo know which cfg's we define, - // and avoid warnings when they are used in the code. - println!("cargo::rustc-check-cfg=cfg(sqlite)"); - println!("cargo::rustc-check-cfg=cfg(mysql)"); - println!("cargo::rustc-check-cfg=cfg(postgresql)"); - println!("cargo::rustc-check-cfg=cfg(s3)"); - // Rerun when these paths are changed. // Someone could have checked-out a tag or specific commit, but no other files changed. println!("cargo:rerun-if-changed=.git"); diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine index 95e8784d..99bec263 100644 --- a/docker/Dockerfile.alpine +++ b/docker/Dockerfile.alpine @@ -32,10 +32,10 @@ FROM --platform=linux/amd64 docker.io/vaultwarden/web-vault@sha256:7baaa7d534974 ########################## ALPINE BUILD IMAGES ########################## ## NOTE: The Alpine Base Images do not support other platforms then linux/amd64 and linux/arm64 ## And for Alpine we define all build images here, they will only be loaded when actually used -FROM --platform=$BUILDPLATFORM ghcr.io/blackdex/rust-musl:x86_64-musl-stable-1.99.1 AS build_amd64 -FROM --platform=$BUILDPLATFORM ghcr.io/blackdex/rust-musl:aarch64-musl-stable-1.99.1 AS build_arm64 -FROM --platform=$BUILDPLATFORM ghcr.io/blackdex/rust-musl:armv7-musleabihf-stable-1.99.1 AS build_armv7 -FROM --platform=$BUILDPLATFORM ghcr.io/blackdex/rust-musl:arm-musleabi-stable-1.99.1 AS build_armv6 +FROM --platform=$BUILDPLATFORM ghcr.io/blackdex/rust-musl:x86_64-musl-stable-1.100.0 AS build_amd64 +FROM --platform=$BUILDPLATFORM ghcr.io/blackdex/rust-musl:aarch64-musl-stable-1.100.0 AS build_arm64 +FROM --platform=$BUILDPLATFORM ghcr.io/blackdex/rust-musl:armv7-musleabihf-stable-1.100.0 AS build_armv7 +FROM --platform=$BUILDPLATFORM ghcr.io/blackdex/rust-musl:arm-musleabi-stable-1.100.0 AS build_armv6 ########################## BUILD IMAGE ########################## # hadolint ignore=DL3006 diff --git a/docker/Dockerfile.debian b/docker/Dockerfile.debian index 621cfafe..612f132f 100644 --- a/docker/Dockerfile.debian +++ b/docker/Dockerfile.debian @@ -36,7 +36,7 @@ FROM --platform=linux/amd64 docker.io/tonistiigi/xx@sha256:40fe21f44bb8cddf1eb12 ########################## BUILD IMAGE ########################## # hadolint ignore=DL3006 -FROM --platform=$BUILDPLATFORM docker.io/library/rust:1.99.1-slim-trixie AS build +FROM --platform=$BUILDPLATFORM docker.io/library/rust:1.100.0-slim-trixie AS build # hadolint ignore=DL3067 COPY --from=xx / / ARG TARGETARCH diff --git a/macros/Cargo.toml b/macros/Cargo.toml index ee9fd206..46bb3904 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -14,7 +14,7 @@ proc-macro = true [dependencies] quote = "1.0.47" -syn = "3.0.9" +syn = "3.0.10" [lints] workspace = true diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 73b23a22..987209eb 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -18,7 +18,7 @@ fn impl_derive_uuid_macro(ast: &DeriveInput) -> TokenStream { #[inline(always)] fn from_param(param: &'r str) -> Result { - if uuid::Uuid::parse_str(param).is_ok() { + if uuid::Uuid::try_parse(param).is_ok() { Ok(Self(param.to_string())) } else { Err(()) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b195f645..b72dab61 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.99.1" +channel = "1.100.0" components = [ "rustfmt", "clippy" ] profile = "minimal" diff --git a/src/api/admin.rs b/src/api/admin.rs index 621601ad..df55066a 100644 --- a/src/api/admin.rs +++ b/src/api/admin.rs @@ -125,15 +125,15 @@ impl<'r> FromRequest<'r> for IpHeader { async fn from_request(req: &'r Request<'_>) -> Outcome { if req.headers().get_one(&CONFIG.ip_header()).is_some() { - Outcome::Success(IpHeader(Some(CONFIG.ip_header()))) + Outcome::Success(Self(Some(CONFIG.ip_header()))) } else if req.headers().get_one("X-Client-IP").is_some() { - Outcome::Success(IpHeader(Some(String::from("X-Client-IP")))) + Outcome::Success(Self(Some(String::from("X-Client-IP")))) } else if req.headers().get_one("X-Real-IP").is_some() { - Outcome::Success(IpHeader(Some(String::from("X-Real-IP")))) + Outcome::Success(Self(Some(String::from("X-Real-IP")))) } else if req.headers().get_one("X-Forwarded-For").is_some() { - Outcome::Success(IpHeader(Some(String::from("X-Forwarded-For")))) + Outcome::Success(Self(Some(String::from("X-Forwarded-For")))) } else { - Outcome::Success(IpHeader(None)) + Outcome::Success(Self(None)) } } } @@ -210,7 +210,7 @@ fn post_admin_login( let cookie = Cookie::build((COOKIE_NAME, jwt)) .path(admin_path()) - .max_age(time::Duration::minutes(i64::from(CONFIG.admin_session_lifetime()))) + .max_age(rocket::time::Duration::minutes(i64::from(CONFIG.admin_session_lifetime()))) .same_site(SameSite::Strict) .http_only(true) .secure(secure.https); @@ -391,7 +391,7 @@ async fn users_overview(_token: AdminToken, conn: DbConn) -> ApiResult json!("Never"), }; - usr["sso_identifier"] = json!(sso_u.map_or(String::new(), |u| u.identifier.to_string())); + usr["sso_identifier"] = json!(sso_u.map_or_default(|u| u.identifier.to_string())); // The clients are shown a Manager as a Custom member, but the admin panel tells the two roles apart let roles: HashMap = Membership::find_confirmed_by_user(&u.uuid, &conn) @@ -677,46 +677,55 @@ async fn has_http_access() -> bool { let Ok(req) = make_http_request(Method::HEAD, "https://github.com/dani-garcia/vaultwarden") else { return false; }; - match req.send().await { - Ok(r) => r.status().is_success(), - _ => false, - } + req.send().await.is_ok_and(|r| r.status().is_success()) } -use cached::macros::cached; -/// Cache this function to prevent API call rate limit. Github only allows 60 requests per hour, and we use 3 here already -/// It will cache this function for 600 seconds (10 minutes) which should prevent the exhaustion of the rate limit -/// Any cache will be lost if Vaultwarden is restarted -#[cached(ttl_secs = 600, sync_writes = "default")] async fn get_release_info(has_http_access: bool) -> (String, String, String) { - // If the HTTP Check failed, do not even attempt to check for new versions since we were not able to connect with github.com anyway. - if has_http_access { - ( - match get_json_api::("https://api.github.com/repos/dani-garcia/vaultwarden/releases/latest") - .await - { - Ok(r) => r.tag_name, - _ => "-".to_owned(), - }, - match get_json_api::("https://api.github.com/repos/dani-garcia/vaultwarden/commits/main").await { - Ok(mut c) => { - c.sha.truncate(8); - c.sha - } - _ => "-".to_owned(), - }, - // Do not fetch the web-vault version when running within a container - // The web-vault version is embedded within the container it self, and should not be updated manually - match get_json_api::("https://api.github.com/repos/dani-garcia/bw_web_builds/releases/latest") - .await - { - Ok(r) => r.tag_name.trim_start_matches('v').to_owned(), - _ => "-".to_owned(), - }, - ) - } else { - ("-".to_owned(), "-".to_owned(), "-".to_owned()) - } + // Cache this function to prevent API call rate limit. Github only allows 60 requests per hour, and we use 3 here already + // It will cache this function for 600 seconds (10 minutes) which should prevent the exhaustion of the rate limit + // Any cache will be lost if Vaultwarden is restarted + static CACHE: LazyLock> = LazyLock::new(|| { + moka::future::Cache::builder().max_capacity(2).time_to_live(std::time::Duration::from_mins(10)).build() + }); + + CACHE + .get_with(has_http_access, async { + // If the HTTP Check failed, do not even attempt to check for new versions since we were not able to connect with github.com anyway. + if has_http_access { + ( + match get_json_api::( + "https://api.github.com/repos/dani-garcia/vaultwarden/releases/latest", + ) + .await + { + Ok(r) => r.tag_name, + _ => "-".to_owned(), + }, + match get_json_api::("https://api.github.com/repos/dani-garcia/vaultwarden/commits/main") + .await + { + Ok(mut c) => { + c.sha.truncate(8); + c.sha + } + _ => "-".to_owned(), + }, + // Do not fetch the web-vault version when running within a container + // The web-vault version is embedded within the container it self, and should not be updated manually + match get_json_api::( + "https://api.github.com/repos/dani-garcia/bw_web_builds/releases/latest", + ) + .await + { + Ok(r) => r.tag_name.trim_start_matches('v').to_owned(), + _ => "-".to_owned(), + }, + ) + } else { + ("-".to_owned(), "-".to_owned(), "-".to_owned()) + } + }) + .await } async fn get_ntp_time(has_http_access: bool) -> String { diff --git a/src/api/core/accounts.rs b/src/api/core/accounts.rs index 414cdc16..c293756d 100644 --- a/src/api/core/accounts.rs +++ b/src/api/core/accounts.rs @@ -166,8 +166,8 @@ impl RegisterDataCompat { fcu: impl FnOnce(&'a RegisterDataCur) -> &'a T, ) -> &'a T { match self { - RegisterDataCompat::RegisterDataOld(rdc) => fct(rdc), - RegisterDataCompat::RegisterDataCur(rdcu) => fcu(rdcu), + Self::RegisterDataOld(rdc) => fct(rdc), + Self::RegisterDataCur(rdcu) => fcu(rdcu), } } @@ -186,8 +186,8 @@ impl RegisterDataCompat { /// The id of the user key, which only the current format carries. fn key_id(&self) -> Option { match self { - RegisterDataCompat::RegisterDataOld(_) => None, - RegisterDataCompat::RegisterDataCur(rdcu) => rdcu.master_password_unlock.contained_key_id.clone(), + Self::RegisterDataOld(_) => None, + Self::RegisterDataCur(rdcu) => rdcu.master_password_unlock.contained_key_id.clone(), } } @@ -2194,7 +2194,7 @@ async fn password_hint(data: Json, ip: ClientIp, conn: DbConn) use rand::{RngExt, rngs::SmallRng}; let mut rng: SmallRng = rand::make_rng(); let sleep_ms: u64 = rng.random_range(900..=1100); - tokio::time::sleep(tokio::time::Duration::from_millis(sleep_ms)).await; + tokio::time::sleep(std::time::Duration::from_millis(sleep_ms)).await; Ok(()) } else { err!(NO_HINT); @@ -2371,7 +2371,7 @@ impl<'r> FromRequest<'r> for KnownDevice { return Outcome::Error((Status::BadRequest, "X-Device-Identifier value is required")); }; - Outcome::Success(KnownDevice { + Outcome::Success(Self { email, uuid, }) diff --git a/src/api/core/ciphers.rs b/src/api/core/ciphers.rs index 78c27b39..604037c8 100644 --- a/src/api/core/ciphers.rs +++ b/src/api/core/ciphers.rs @@ -1,7 +1,6 @@ use std::collections::{HashMap, HashSet}; use chrono::{NaiveDateTime, Utc}; -use num_traits::ToPrimitive; use rocket::{ Route, form::{Form, FromForm}, @@ -129,12 +128,10 @@ async fn sync(data: SyncData, headers: Headers, client_version: Option=2024.12.0").unwrap(); - ver_match.matches(&client_version.0) - } else { - false - }; + ver_match.matches(&v.0) + }); if !show_ssh_keys { ciphers.retain(|c| c.atype != 5); } @@ -287,7 +284,7 @@ async fn cipher_json_for_scope( } } -#[derive(Debug, Deserialize)] +#[derive(Deserialize)] #[serde(rename_all = "camelCase")] pub struct CipherData { // Id is optional as it is included only in bulk share @@ -341,8 +338,7 @@ pub struct CipherData { pub password_history: Option, // These are used during key rotation - // 'Attachments' is unused, contains map of {id: filename} - #[allow(dead_code)] + #[cfg_attr(not(feature = "unsafe_test_mode"), expect(unused, reason = "Only read by the unsafe test seeder"))] attachments: Option, attachments2: Option>, @@ -553,7 +549,7 @@ async fn post_ciphers(data: Json, headers: Headers, conn: DbConn, nt /// /// Ref: https://bitwarden.com/help/article/policies/#personal-ownership async fn enforce_personal_ownership_policy(data: Option<&CipherData>, headers: &Headers, conn: &DbConn) -> EmptyResult { - if data.is_none() || data.unwrap().organization_id.is_none() { + if data.is_none_or(|d| d.organization_id.is_none()) { let user_id = &headers.user.uuid; let policy_type = OrgPolicyType::PersonalOwnership; if OrgPolicy::is_applicable_to_user(user_id, policy_type, None, conn).await { @@ -1744,7 +1740,7 @@ async fn save_attachment( ) -> Result<(Cipher, DbConn), crate::error::Error> { let data = data.into_inner(); - let Some(size) = data.data.len().to_i64() else { + let Ok(size) = i64::try_from(data.data.len()) else { err!("Attachment data size overflow"); }; if size < 0 { @@ -2844,10 +2840,7 @@ mod custom_role_tests { use crate::{ api::notifications::{WS_USERS, WebSocketUsers}, auth::ClientIp, - db::{ - models::{CustomPermission, Device, User}, - test_db, - }, + db::{models::Device, test_db}, }; use chrono::Datelike; use diesel::connection::SimpleConnection; diff --git a/src/api/core/emergency_access.rs b/src/api/core/emergency_access.rs index b2d8fb59..01b7b946 100644 --- a/src/api/core/emergency_access.rs +++ b/src/api/core/emergency_access.rs @@ -793,8 +793,7 @@ fn is_valid_request( requesting_user_id: &UserId, requested_access_type: EmergencyAccessType, ) -> bool { - emergency_access.grantee_uuid.is_some() - && emergency_access.grantee_uuid.as_ref().unwrap() == requesting_user_id + emergency_access.grantee_uuid.as_ref().is_some_and(|u| u == requesting_user_id) && emergency_access.status == EmergencyAccessStatus::RecoveryApproved as i32 && emergency_access.atype == requested_access_type as i32 } diff --git a/src/api/core/events.rs b/src/api/core/events.rs index 49678c68..094d913a 100644 --- a/src/api/core/events.rs +++ b/src/api/core/events.rs @@ -140,12 +140,10 @@ fn get_continuation_token(events_json: &[Value]) -> Option<&str> { // When the length of the vec equals the max page_size there probably is more data // When it is less, then all events are loaded. #[expect(clippy::cast_possible_truncation, reason = "PAGE_SIZE fits within usize")] - if events_json.len() == Event::PAGE_SIZE as usize { - if let Some(last_event) = events_json.last() { - last_event["date"].as_str() - } else { - None - } + if events_json.len() == Event::PAGE_SIZE as usize + && let Some(last_event) = events_json.last() + { + last_event["date"].as_str() } else { None } diff --git a/src/api/core/organizations.rs b/src/api/core/organizations.rs index ee2165a0..dac23daf 100644 --- a/src/api/core/organizations.rs +++ b/src/api/core/organizations.rs @@ -116,8 +116,8 @@ struct OrgData { key: String, name: String, keys: Option, - #[allow(dead_code)] - plan_type: NumberOrString, // Ignored, always use the same plan + #[expect(unused, reason = "Ignored, always use the same plan")] + plan_type: NumberOrString, } #[derive(Deserialize, Debug)] @@ -1317,7 +1317,7 @@ async fn send_invite( if Group::find_by_uuid_and_org(group_id, &org_id, &conn).await.is_none() { err!("Group not found in Organization") } - let mut group_entry = GroupUser::new(group_id.clone(), new_member.uuid.clone()); + let group_entry = GroupUser::new(group_id.clone(), new_member.uuid.clone()); group_entry.save(&conn).await?; } } @@ -1797,7 +1797,7 @@ async fn edit_member( if Group::find_by_uuid_and_org(group_id, &org_id, &conn).await.is_none() { err!("Group not found in Organization") } - let mut group_entry = GroupUser::new(group_id.clone(), member_to_edit.uuid.clone()); + let group_entry = GroupUser::new(group_id.clone(), member_to_edit.uuid.clone()); group_entry.save(&conn).await?; } @@ -2279,13 +2279,7 @@ async fn post_bulk_collections(data: Json, headers: Headers }; let user_collections: HashMap = collections .into_iter() - .filter_map(|c| { - if data.collection_ids.contains(&c.uuid) { - Some((c.uuid.clone(), c)) - } else { - None - } - }) + .filter_map(|c| data.collection_ids.contains(&c.uuid).then(|| (c.uuid.clone(), c))) .collect(); // Verify if all the collections requested exists and are writable for the user, else abort @@ -2396,10 +2390,9 @@ async fn get_policy(org_id: OrganizationId, pol_type: i32, headers: ManagePolici err!("Invalid or unsupported policy type") }; - let policy = match OrgPolicy::find_by_org_and_type(&org_id, pol_type_enum, &conn).await { - Some(p) => p, - None => OrgPolicy::new(org_id.clone(), pol_type_enum, false, "null".to_owned()), - }; + let policy = OrgPolicy::find_by_org_and_type(&org_id, pol_type_enum, &conn) + .await + .unwrap_or_else(|| OrgPolicy::new(org_id.clone(), pol_type_enum, false, "null".to_owned())); Ok(Json(policy.to_json())) } @@ -2466,11 +2459,9 @@ async fn put_policy( // Maybe we want to enable this by default in the future, but currently it is disabled by default. if CONFIG.enforce_single_org_with_reset_pw_policy() { if pol_type_enum == OrgPolicyType::ResetPassword && data.enabled { - let single_org_policy_enabled = - match OrgPolicy::find_by_org_and_type(&org_id, OrgPolicyType::SingleOrg, &conn).await { - Some(p) => p.enabled, - None => false, - }; + let single_org_policy_enabled = OrgPolicy::find_by_org_and_type(&org_id, OrgPolicyType::SingleOrg, &conn) + .await + .is_some_and(|p| p.enabled); if !single_org_policy_enabled { err!("Single Organization policy is not enabled. It is mandatory for this policy to be enabled.") @@ -2479,11 +2470,9 @@ async fn put_policy( // Also prevent the Single Org Policy to be disabled if the Reset Password policy is enabled if pol_type_enum == OrgPolicyType::SingleOrg && !data.enabled { - let reset_pw_policy_enabled = - match OrgPolicy::find_by_org_and_type(&org_id, OrgPolicyType::ResetPassword, &conn).await { - Some(p) => p.enabled, - None => false, - }; + let reset_pw_policy_enabled = OrgPolicy::find_by_org_and_type(&org_id, OrgPolicyType::ResetPassword, &conn) + .await + .is_some_and(|p| p.enabled); if reset_pw_policy_enabled { err!("Account recovery policy is enabled. It is not allowed to disable this policy.") @@ -3097,12 +3086,12 @@ async fn add_update_group( group.save(conn).await?; for col_selection in collections { - let mut collection_group = col_selection.to_collection_group(group.uuid.clone()); + let collection_group = col_selection.to_collection_group(group.uuid.clone()); collection_group.save(&org_id, conn).await?; } for assigned_member in members { - let mut user_entry = GroupUser::new(group.uuid.clone(), assigned_member.clone()); + let user_entry = GroupUser::new(group.uuid.clone(), assigned_member.clone()); user_entry.save(conn).await?; log_event( diff --git a/src/api/core/public.rs b/src/api/core/public.rs index 1ee80515..9b9bd3af 100644 --- a/src/api/core/public.rs +++ b/src/api/core/public.rs @@ -156,7 +156,7 @@ async fn ldap_import(data: Json, token: PublicToken, conn: DbConn for ext_id in &group_data.member_external_ids { if let Some(member) = Membership::find_by_external_id_and_org(ext_id, &org_id, &conn).await { - let mut group_user = GroupUser::new(group_uuid.clone(), member.uuid.clone()); + let group_user = GroupUser::new(group_uuid.clone(), member.uuid.clone()); group_user.save(&conn).await?; } } @@ -237,6 +237,6 @@ impl<'r> FromRequest<'r> for PublicToken { err_handler!("Token not issued for this client"); } - Outcome::Success(PublicToken(claims.client_sub)) + Outcome::Success(Self(claims.client_sub)) } } diff --git a/src/api/core/sends.rs b/src/api/core/sends.rs index 97d68731..a6d5f4d8 100644 --- a/src/api/core/sends.rs +++ b/src/api/core/sends.rs @@ -1,7 +1,6 @@ use std::{path::Path, sync::LazyLock, time::Duration}; use chrono::{DateTime, TimeDelta, Utc}; -use num_traits::ToPrimitive; use rocket::{ form::Form, fs::{NamedFile, TempFile}, @@ -172,10 +171,7 @@ fn create_send(data: SendData, user_id: UserId) -> ApiResult { let mut send = Send::new(data.r#type, data.name, data_str, data.key, data.deletion_date.naive_utc()); send.user_uuid = Some(user_id); send.notes = data.notes; - send.max_access_count = match data.max_access_count { - Some(m) => Some(m.into_i32()?), - _ => None, - }; + send.max_access_count = data.max_access_count.map(|m| m.into_i32()).transpose()?; send.expiration_date = data.expiration_date.map(|d| d.naive_utc()); send.disabled = data.disabled; send.hide_email = data.hide_email; @@ -303,7 +299,7 @@ async fn post_send_file_v2(data: Json, headers: Headers, conn: DbConn) } #[derive(Deserialize)] -#[allow(non_snake_case)] +#[expect(non_snake_case, reason = "Bitwarden clients use this format")] pub struct SendFileData { id: SendFileId, size: u64, @@ -357,10 +353,7 @@ async fn post_send_file_v2_data( err!("Send file does not match send data.", format!("Expected id {} got {file_id}", send_data.id)); } - let Some(size) = data.data.len().to_u64() else { - err!("Send file size overflow."); - }; - + let size = data.data.len(); if size != send_data.size { err!("Send file size does not match.", format!("Expected a file size of {} got {size}", send_data.size)); } @@ -538,10 +531,7 @@ async fn update_send_from_data( send.akey = data.key; send.deletion_date = data.deletion_date.naive_utc(); send.notes = data.notes; - send.max_access_count = match data.max_access_count { - Some(m) => Some(m.into_i32()?), - _ => None, - }; + send.max_access_count = data.max_access_count.map(|m| m.into_i32()).transpose()?; send.expiration_date = data.expiration_date.map(|d| d.naive_utc()); send.hide_email = data.hide_email; send.disabled = data.disabled; diff --git a/src/api/core/two_factor/authenticator.rs b/src/api/core/two_factor/authenticator.rs index 55984443..c56c9b58 100644 --- a/src/api/core/two_factor/authenticator.rs +++ b/src/api/core/two_factor/authenticator.rs @@ -116,10 +116,9 @@ pub async fn validate_totp_code( err!("Invalid TOTP secret") }; - let mut twofactor = match TwoFactor::find_by_user_and_type(user_id, TwoFactorType::Authenticator, conn).await { - Some(tf) => tf, - _ => TwoFactor::new(user_id.clone(), TwoFactorType::Authenticator, secret.to_owned()), - }; + let mut twofactor = TwoFactor::find_by_user_and_type(user_id, TwoFactorType::Authenticator, conn) + .await + .unwrap_or_else(|| TwoFactor::new(user_id.clone(), TwoFactorType::Authenticator, secret.to_owned())); // The amount of steps back and forward in time // Also check if we need to disable time drifted TOTP codes. diff --git a/src/api/core/two_factor/duo.rs b/src/api/core/two_factor/duo.rs index 23116b2c..87f36de9 100644 --- a/src/api/core/two_factor/duo.rs +++ b/src/api/core/two_factor/duo.rs @@ -32,8 +32,8 @@ enum DuoStatus { impl DuoStatus { fn data(self) -> Option { match self { - DuoStatus::Global(data) | DuoStatus::User(data) => Some(data), - DuoStatus::Disabled(_) => None, + Self::Global(data) | Self::User(data) => Some(data), + Self::Disabled(_) => None, } } } diff --git a/src/api/core/two_factor/duo_oidc.rs b/src/api/core/two_factor/duo_oidc.rs index e5e1df0f..c0a5062c 100644 --- a/src/api/core/two_factor/duo_oidc.rs +++ b/src/api/core/two_factor/duo_oidc.rs @@ -108,8 +108,8 @@ struct DuoClient { impl DuoClient { // Construct a new DuoClient - fn new(client_id: String, client_secret: String, api_host: String, redirect_uri: String) -> DuoClient { - DuoClient { + fn new(client_id: String, client_secret: String, api_host: String, redirect_uri: String) -> Self { + Self { client_id, client_secret, api_host, @@ -137,7 +137,7 @@ impl DuoClient { match jsonwebtoken::encode( &Header::new(JWT_SIGNATURE_ALG), &jwt_payload, - &EncodingKey::from_secret(self.client_secret.as_bytes()), + &EncodingKey::from_secret(self.client_secret.as_bytes())?, ) { Ok(token) => Ok(token), Err(e) => err!(format!("Error encoding Duo JWT: {e:?}")), @@ -157,10 +157,7 @@ impl DuoClient { Err(e) => return Err(e), }; - let mut post_body = HashMap::new(); - post_body.insert("client_assertion", token); - post_body.insert("client_id", self.client_id.clone()); - + let post_body = HashMap::from([("client_assertion", token), ("client_id", self.client_id.clone())]); let res = match make_http_request(reqwest::Method::POST, &health_check_url)? .header(header::USER_AGENT, "vaultwarden:Duo/2.0 (Rust)") .form(&post_body) @@ -291,7 +288,7 @@ impl DuoClient { let token_data = match jsonwebtoken::decode::( &response.id_token, - &DecodingKey::from_secret(self.client_secret.as_bytes()), + &DecodingKey::from_secret(self.client_secret.as_bytes())?, &validation, ) { Ok(c) => c, @@ -422,18 +419,14 @@ pub async fn validate_duo_login( conn: &DbConn, ) -> EmptyResult { // Result supplied to us by clients in the form "|" - let split: Vec<&str> = two_factor_token.split('|').collect(); - if split.len() != 2 { + let Some((code, state)) = two_factor_token.split_once('|').filter(|(_, state)| !state.contains('|')) else { err!( "Invalid response length", ErrorEvent { event: EventType::UserFailedLogIn2fa } ); - } - - let code = split[0]; - let state = split[1]; + }; let (ik, sk, host) = get_duo_keys_email(email, conn).await?; diff --git a/src/api/core/two_factor/email.rs b/src/api/core/two_factor/email.rs index 15bfdbc3..20242fe1 100644 --- a/src/api/core/two_factor/email.rs +++ b/src/api/core/two_factor/email.rs @@ -349,8 +349,8 @@ pub struct EmailTokenData { } impl EmailTokenData { - pub fn new(email: String, token: Option) -> EmailTokenData { - EmailTokenData { + pub fn new(email: String, token: Option) -> Self { + Self { email, last_token: token, token_sent: Utc::now().timestamp(), @@ -376,8 +376,8 @@ impl EmailTokenData { serde_json::to_string(&self).unwrap() } - pub fn from_json(string: &str) -> Result { - let res: Result = serde_json::from_str(string); + pub fn from_json(string: &str) -> Result { + let res: Result = serde_json::from_str(string); if let Ok(x) = res { Ok(x) } else { @@ -398,22 +398,21 @@ pub async fn activate_email_2fa(user: &User, conn: &DbConn) -> EmptyResult { /// Takes an email address and obscures it by replacing it with asterisks except two characters. pub fn obscure_email(email: &str) -> String { - let split: Vec<&str> = email.rsplitn(2, '@').collect(); - - let mut name = split[1].to_owned(); - let domain = &split[0]; - - let name_size = name.chars().count(); + let Some((name, domain)) = email.rsplit_once('@') else { + return "*".repeat(email.chars().count()); + }; - let new_name = if let 1..=3 = name_size { - "*".repeat(name_size) + let len = name.chars().count(); + let keep = if len > 3 { + 2 } else { - let stars = "*".repeat(name_size - 2); - name.truncate(2); - format!("{name}{stars}") + 0 }; - format!("{new_name}@{domain}") + // Byte offset after the first `keep` chars (UTF-8 safe). + let end = name.char_indices().nth(keep).map_or(name.len(), |(i, _)| i); + + format!("{}{}@{domain}", &name[..end], "*".repeat(len - keep)) } pub async fn find_and_activate_email_2fa(user_id: &UserId, conn: &DbConn) -> EmptyResult { @@ -431,7 +430,6 @@ mod tests { #[test] fn test_obscure_email_long() { let email = "bytes@example.ext"; - let result = obscure_email(email); // Only first two characters should be visible. @@ -441,10 +439,37 @@ mod tests { #[test] fn test_obscure_email_short() { let email = "byt@example.ext"; + let result = obscure_email(email); + // If it's smaller than 3 characters it should only show asterisks. + assert_eq!(result, "***@example.ext"); + } + + // Test unicode email address, as that might cut a unicode char in half and cause a panic + #[test] + fn test_obscure_email_unicode_long() { + let email = "bɏtes@example.ext"; + let result = obscure_email(email); + + // Only first two characters should be visible. + assert_eq!(result, "bɏ***@example.ext"); + } + + #[test] + fn test_obscure_email_unicode_short() { + let email = "bɏt@example.ext"; let result = obscure_email(email); // If it's smaller than 3 characters it should only show asterisks. assert_eq!(result, "***@example.ext"); } + + #[test] + fn test_missing_at() { + let email = "bɏt_at_example.ext"; + let result = obscure_email(email); + + // If it's smaller than 3 characters it should only show asterisks. + assert_eq!(result, "******************"); + } } diff --git a/src/api/core/two_factor/webauthn.rs b/src/api/core/two_factor/webauthn.rs index 7eab5546..29760b12 100644 --- a/src/api/core/two_factor/webauthn.rs +++ b/src/api/core/two_factor/webauthn.rs @@ -35,7 +35,7 @@ use crate::{ static WEBAUTHN: LazyLock = LazyLock::new(|| { let domain = CONFIG.domain(); let domain_origin = CONFIG.domain_origin(); - let rp_id = Url::parse(&domain).map(|u| u.domain().map(str::to_owned)).ok().flatten().unwrap_or_default(); + let rp_id = Url::parse(&domain).map_or_default(|u| u.domain().map_or_default(str::to_owned)); let rp_origin = Url::parse(&domain_origin).unwrap(); let webauthn = WebauthnBuilder::new(&rp_id, &rp_origin) @@ -355,13 +355,9 @@ async fn inner_delete_webauthns( let mut removed: HashSet> = HashSet::new(); let mut migrated = false; - keys.retain(|key| { - let retained = retain(key); - if !retained { - removed.insert(key.credential.cred_id().to_vec()); - migrated = migrated || key.migrated; - } - retained + keys.extract_if(.., |key| !retain(key)).for_each(|key| { + removed.insert(key.credential.cred_id().to_vec()); + migrated |= key.migrated; }); if removed.is_empty() { diff --git a/src/api/icons.rs b/src/api/icons.rs index 1c7b2a57..4a0853af 100644 --- a/src/api/icons.rs +++ b/src/api/icons.rs @@ -76,9 +76,6 @@ static CLIENT: LazyLock = LazyLock::new(|| { .expect("Failed to build client") }); -// Build Regex only once since this takes a lot of time. -static ICON_SIZE_REGEX: LazyLock = LazyLock::new(|| Regex::new(r"(?x)(\d+)\D*(\d+)").unwrap()); - // The function name `icon_external` is checked in the `on_response` function in `AppHeaders` // It is used to prevent sending a specific header which breaks icon downloads. // If this function needs to be renamed, also adjust the code in `util.rs` @@ -263,7 +260,7 @@ fn get_favicons_node(dom: Tokenizer, FaviconEmitter>, icons: &m } TAG_BASE => { base_url = if let Some(href) = token.tag.attributes.get(ATTR_HREF) { - let href = std::str::from_utf8(href).unwrap_or_default(); + let href = str::from_utf8(href).unwrap_or_default(); debug!("Found base href: {}", href.escape_debug()); match base_url.join(href) { Ok(inner_url) => inner_url, @@ -282,13 +279,9 @@ fn get_favicons_node(dom: Tokenizer, FaviconEmitter>, icons: &m for icon_tag in icon_tags { if let Some(icon_href) = icon_tag.attributes.get(ATTR_HREF) - && let Ok(full_href) = base_url.join(std::str::from_utf8(icon_href).unwrap_or_default()) + && let Ok(full_href) = base_url.join(str::from_utf8(icon_href).unwrap_or_default()) { - let sizes = if let Some(v) = icon_tag.attributes.get(ATTR_SIZES) { - std::str::from_utf8(v).unwrap_or_default() - } else { - "" - }; + let sizes = icon_tag.attributes.get(ATTR_SIZES).map_or_default(|v| str::from_utf8(v).unwrap_or_default()); let priority = get_icon_priority(full_href.as_str(), sizes); icons.push(Icon::new(priority, full_href.to_string())); } @@ -443,7 +436,7 @@ async fn get_page_with_referer(url: &str, referer: &str) -> Result u8 { static PRIORITY_MAP: LazyLock> = - LazyLock::new(|| [(".png", 10), (".jpg", 20), (".jpeg", 20)].into_iter().collect()); + LazyLock::new(|| HashMap::from([("png", 10), ("jpg", 20), ("jpeg", 20)])); // Check if there is a dimension set let (width, height) = parse_sizes(sizes); @@ -489,20 +482,12 @@ fn get_icon_priority(href: &str, sizes: &str) -> u8 { /// let (width, height) = parse_sizes("32"); // (0, 0) /// ``` fn parse_sizes(sizes: &str) -> (u16, u16) { - let mut width: u16 = 0; - let mut height: u16 = 0; - - if !sizes.is_empty() { - match ICON_SIZE_REGEX.captures(sizes.trim()) { - Some(dimensions) if dimensions.len() >= 3 => { - width = dimensions[1].parse::().unwrap_or_default(); - height = dimensions[2].parse::().unwrap_or_default(); - } - _ => {} - } - } + static ICON_SIZE_REGEX: LazyLock = LazyLock::new(|| Regex::new(r"(\d+)\D+(\d+)").unwrap()); - (width, height) + ICON_SIZE_REGEX + .captures(sizes) + .and_then(|c| Some((c[1].parse::().ok()?, c[2].parse::().ok()?))) + .unwrap_or((0, 0)) } async fn download_icon(domain: &str) -> Result<(Bytes, Option<&str>), Error> { @@ -602,12 +587,10 @@ async fn save_icon(path: &str, icon: Vec) { fn get_icon_type(bytes: &[u8]) -> Option<&'static str> { fn check_svg_after_xml_declaration(bytes: &[u8]) -> Option<&'static str> { // Look for SVG tag within the first 1KB - if let Ok(content) = std::str::from_utf8(&bytes[..bytes.len().min(1024)]) - && (content.contains("); impl reqwest::cookie::CookieStore for Jar { fn set_cookies(&self, cookie_headers: &mut dyn Iterator, url: &url::Url) { - use cookie::{Cookie as RawCookie, ParseError as RawCookieParseError}; - use time::Duration; + use cookie::{Cookie as RawCookie, ParseError as RawCookieParseError, time::Duration}; let mut cookie_store = self.0.write().unwrap(); @@ -675,7 +657,7 @@ impl reqwest::cookie::CookieStore for Jar { } let cookies = cookie_headers.filter_map(|val| { - std::str::from_utf8(val.as_bytes()) + str::from_utf8(val.as_bytes()) .map_err(RawCookieParseError::from) .and_then(RawCookie::parse) .map(|mut c| { @@ -746,8 +728,7 @@ impl FaviconEmitter { if let Some(ref mut token) = self.current_token { let tag_name: &[u8] = &token.tag.name; - if self.current_attribute.is_some() && (tag_name == TAG_BASE || tag_name == TAG_LINK) { - let (k, v) = self.current_attribute.take().unwrap(); + if let Some((k, v)) = self.current_attribute.take_if(|_| tag_name == TAG_BASE || tag_name == TAG_LINK) { token.tag.attributes.entry(k).and_modify(|_| {}).or_insert(v); } @@ -756,8 +737,7 @@ impl FaviconEmitter { TAG_HEAD if token.closing => self.emit_token = true, TAG_BASE if tag_attr.contains_key(ATTR_HREF) => self.emit_token = true, TAG_LINK if emit_current_tag && tag_attr.contains_key(ATTR_REL) && tag_attr.contains_key(ATTR_HREF) => { - let rel_value = - std::str::from_utf8(token.tag.attributes.get(ATTR_REL).unwrap()).unwrap_or_default(); + let rel_value = str::from_utf8(token.tag.attributes.get(ATTR_REL).unwrap()).unwrap_or_default(); if rel_value.contains("icon") && !rel_value.contains("mask-icon") { self.emit_token = true; } @@ -843,10 +823,9 @@ impl Emitter for FaviconEmitter { } fn current_is_appropriate_end_tag_token(&mut self) -> bool { - match &self.current_token { - Some(token) if token.closing => !self.last_start_tag.is_empty() && self.last_start_tag == token.tag.name, - _ => false, - } + self.current_token + .as_ref() + .is_some_and(|t| t.closing && (!self.last_start_tag.is_empty() && self.last_start_tag == t.tag.name)) } // We do not want and need these parts of the HTML document diff --git a/src/api/identity.rs b/src/api/identity.rs index e1da7421..f7244eef 100644 --- a/src/api/identity.rs +++ b/src/api/identity.rs @@ -467,9 +467,9 @@ async fn password_login( let now = Utc::now().naive_utc(); if user.verified_at.is_none() && CONFIG.mail_enabled() && CONFIG.signups_verify() { - if user.last_verifying_at.is_none() - || now.signed_duration_since(user.last_verifying_at.unwrap()).num_seconds() - > i64::from(CONFIG.signups_verify_resend_time()) + if user + .last_verifying_at + .is_none_or(|d| now.signed_duration_since(d).num_seconds() > i64::from(CONFIG.signups_verify_resend_time())) { let resend_limit = i32::from(CONFIG.signups_verify_resend_limit()); if resend_limit == 0 || user.login_verify_count < resend_limit { @@ -1155,7 +1155,7 @@ async fn register_verification_email( use rand::{RngExt, rngs::SmallRng}; let mut rng: SmallRng = rand::make_rng(); let sleep_ms: u64 = rng.random_range(900..=1100); - tokio::time::sleep(tokio::time::Duration::from_millis(sleep_ms)).await; + tokio::time::sleep(std::time::Duration::from_millis(sleep_ms)).await; } else { mail::send_register_verify_email(&data.email, &token).await?; } @@ -1233,10 +1233,10 @@ struct ConnectData { #[field(name = uncased("device_type"))] #[field(name = uncased("devicetype"))] device_type: Option, - #[allow(unused)] + #[expect(unused, reason = "Unused, mobile device push not yet supported")] #[field(name = uncased("device_push_token"))] #[field(name = uncased("devicepushtoken"))] - _device_push_token: Option, // Unused; mobile device push not yet supported. + device_push_token: Option, // Needed for two-factor auth #[field(name = uncased("two_factor_provider"))] @@ -1283,8 +1283,8 @@ fn prevalidate() -> JsonResult { const SSO_BINDING_COOKIE: &str = "VW_SSO_BINDING"; #[get("/connect/oidc-signin?&", rank = 1)] -async fn oidcsignin(code: OIDCCode, state: String, cookies: &CookieJar<'_>, mut conn: DbConn) -> ApiResult { - oidcsignin_redirect(state, code, None, cookies, &mut conn).await +async fn oidcsignin(code: OIDCCode, state: String, cookies: &CookieJar<'_>, conn: DbConn) -> ApiResult { + oidcsignin_redirect(state, code, None, cookies, &conn).await } // Bitwarden client appear to only care for code and state @@ -1296,7 +1296,7 @@ async fn oidcsignin_error( error: String, error_description: Option, cookies: &CookieJar<'_>, - mut conn: DbConn, + conn: DbConn, ) -> ApiResult { oidcsignin_redirect( state.clone(), @@ -1306,7 +1306,7 @@ async fn oidcsignin_error( error_description, }), cookies, - &mut conn, + &conn, ) .await } @@ -1319,7 +1319,7 @@ async fn oidcsignin_redirect( code: OIDCCode, error: Option, cookies: &CookieJar<'_>, - conn: &mut DbConn, + conn: &DbConn, ) -> ApiResult { let state = sso::decode_state(&base64_state)?; @@ -1367,18 +1367,18 @@ struct AuthorizeData { #[field(name = uncased("redirect_uri"))] #[field(name = uncased("redirecturi"))] redirect_uri: String, - #[allow(unused)] + #[expect(unused)] response_type: Option, - #[allow(unused)] + #[expect(unused)] scope: Option, state: OIDCState, code_challenge: OIDCCodeChallenge, code_challenge_method: String, - #[allow(unused)] + #[expect(unused)] response_mode: Option, - #[allow(unused)] + #[expect(unused)] domain_hint: Option, - #[allow(unused)] + #[expect(unused)] #[field(name = uncased("ssoToken"))] sso_token: Option, } @@ -1410,7 +1410,7 @@ async fn authorize(data: AuthorizeData, cookies: &CookieJar<'_>, secure: Secure, cookies.add( Cookie::build((SSO_BINDING_COOKIE, binding_token)) .path(format!("{}/identity/connect/", CONFIG.domain_path())) - .max_age(time::Duration::seconds(sso::SSO_AUTH_EXPIRATION.num_seconds())) + .max_age(rocket::time::Duration::seconds(sso::SSO_AUTH_EXPIRATION.num_seconds())) .same_site(SameSite::Lax) // Lax is needed because the IdP runs on a different FQDN .http_only(true) .secure(secure.https) diff --git a/src/api/mod.rs b/src/api/mod.rs index 4c10f10b..5289e8cf 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -120,7 +120,7 @@ async fn master_password_policy(user: &User, conn: &DbConn) -> Value { } })) } else if CONFIG.sso_enabled() { - CONFIG.sso_master_password_policy_value().unwrap_or(json!({})) + CONFIG.sso_master_password_policy_value().unwrap_or_else(|| json!({})) } else { json!({}) }; diff --git a/src/api/notifications.rs b/src/api/notifications.rs index 304ce447..a44a509a 100644 --- a/src/api/notifications.rs +++ b/src/api/notifications.rs @@ -615,12 +615,11 @@ impl AnonymousWebSocketSubscriptions { /// Releases a slot taken by `try_reserve`. fn release(&self, addr: IpAddr) { - let empty = if let Some(mut count) = self.connections.get_mut(&addr) { - *count = count.saturating_sub(1); - *count == 0 - } else { - false - }; + let empty = self.connections.get_mut(&addr).is_some_and(|mut c| { + *c = c.saturating_sub(1); + *c == 0 + }); + // Only remove once the guard above is dropped, otherwise this deadlocks. if empty { self.connections.remove_if(&addr, |_, count| *count == 0); @@ -629,7 +628,7 @@ impl AnonymousWebSocketSubscriptions { async fn send_update(&self, token: &str, data: &[u8]) { // Clone the senders so the map isn't kept locked while sending. - let senders = self.map.get(token).map(|v| v.clone()).unwrap_or_default(); + let senders = self.map.get(token).map_or_default(|v| v.clone()); for (_, sender) in senders { if let Err(e) = sender.send(Message::binary(data)).await { error!("Error sending WS update {e}"); diff --git a/src/auth.rs b/src/auth.rs index 9da34a85..a54b30a0 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -43,12 +43,12 @@ use crate::{ const JWT_ALGORITHM: Algorithm = Algorithm::RS256; -// Limit when BitWarden consider the token as expired -pub static BW_EXPIRATION: LazyLock = LazyLock::new(|| TimeDelta::try_minutes(5).unwrap()); +// Limit when Bitwarden consider the token as expired +pub static BW_EXPIRATION: TimeDelta = TimeDelta::try_minutes(5).unwrap(); -pub static DEFAULT_REFRESH_VALIDITY: LazyLock = LazyLock::new(|| TimeDelta::try_days(30).unwrap()); -pub static MOBILE_REFRESH_VALIDITY: LazyLock = LazyLock::new(|| TimeDelta::try_days(90).unwrap()); -pub static DEFAULT_ACCESS_VALIDITY: LazyLock = LazyLock::new(|| TimeDelta::try_hours(2).unwrap()); +pub static DEFAULT_REFRESH_VALIDITY: TimeDelta = TimeDelta::try_days(30).unwrap(); +pub static MOBILE_REFRESH_VALIDITY: TimeDelta = TimeDelta::try_days(90).unwrap(); +pub static DEFAULT_ACCESS_VALIDITY: TimeDelta = TimeDelta::try_hours(2).unwrap(); static JWT_HEADER: LazyLock
= LazyLock::new(|| Header::new(JWT_ALGORITHM)); pub static JWT_LOGIN_ISSUER: LazyLock = LazyLock::new(|| format!("{}|login", CONFIG.domain_origin())); @@ -258,7 +258,7 @@ impl LoginJwtClaims { // let orguser: Vec<_> = orgs.iter().filter(|o| o.atype == 2).map(|o| o.org_uuid.clone()).collect(); // let orgmanager: Vec<_> = orgs.iter().filter(|o| o.atype == 3).map(|o| o.org_uuid.clone()).collect(); - if exp <= (now + *BW_EXPIRATION).timestamp() { + if exp <= (now + BW_EXPIRATION).timestamp() { warn!("Raise access_token lifetime to more than 5min."); } @@ -286,7 +286,7 @@ impl LoginJwtClaims { sstamp: user.security_stamp.clone(), device: device.uuid.clone(), devicetype: DeviceType::from_i32(device.atype).to_string(), - client_id: client_id.unwrap_or("undefined".to_owned()), + client_id: client_id.unwrap_or_else(|| "undefined".to_owned()), scope, amr: vec!["Application".into()], } @@ -298,7 +298,7 @@ impl LoginJwtClaims { device, user, time_now.timestamp(), - (time_now + *DEFAULT_ACCESS_VALIDITY).timestamp(), + (time_now + DEFAULT_ACCESS_VALIDITY).timestamp(), auth_method.scope_vec(), client_id, time_now, @@ -623,7 +623,7 @@ impl<'r> FromRequest<'r> for Host { format!("{protocol}://{host}") }; - Outcome::Success(Host { + Outcome::Success(Self { host, }) } @@ -654,7 +654,7 @@ impl<'r> FromRequest<'r> for ClientHeaders { let client_version = request.headers().get_one("Bitwarden-Client-Version").and_then(|v| semver::Version::parse(v).ok()); - Outcome::Success(ClientHeaders { + Outcome::Success(Self { device_type, ip, client_version, @@ -723,7 +723,7 @@ impl<'r> FromRequest<'r> for Headers { } } - Outcome::Success(Headers { + Outcome::Success(Self { host, device, user, @@ -789,7 +789,7 @@ impl<'r> FromRequest<'r> for OrgIdGuard { async fn from_request(request: &'r Request<'_>) -> Outcome { match get_org_id(request) { - Some(_) => Outcome::Success(OrgIdGuard), + Some(_) => Outcome::Success(Self), None => Outcome::Forward(rocket::http::Status::NotFound), } } @@ -1065,8 +1065,8 @@ macro_rules! collection_headers { } impl From<$name> for Headers { - fn from(h: $name) -> Headers { - Headers { + fn from(h: $name) -> Self { + Self { host: h.host, device: h.device, user: h.user, @@ -1132,8 +1132,8 @@ impl<'r> FromRequest<'r> for ManagerHeadersLoose { } impl From for Headers { - fn from(h: ManagerHeadersLoose) -> Headers { - Headers { + fn from(h: ManagerHeadersLoose) -> Self { + Self { host: h.host, device: h.device, user: h.user, @@ -1147,7 +1147,7 @@ impl CollectionDeleteHeaders { h: ManagerHeadersLoose, collections: &Vec, conn: &DbConn, - ) -> Result { + ) -> Result { let is_custom = h.membership.has_type(MembershipType::Custom) && custom_roles_enabled(); for col_id in collections { if uuid::Uuid::parse_str(col_id.as_ref()).is_err() { @@ -1164,7 +1164,7 @@ impl CollectionDeleteHeaders { } } - Ok(CollectionDeleteHeaders { + Ok(Self { host: h.host, device: h.device, user: h.user, @@ -1229,8 +1229,8 @@ impl<'r> FromRequest<'r> for OrgMemberHeaders { } impl From for Headers { - fn from(h: OrgMemberHeaders) -> Headers { - Headers { + fn from(h: OrgMemberHeaders) -> Self { + Self { host: h.host, device: h.device, user: h.user, @@ -1322,7 +1322,7 @@ impl<'r> FromRequest<'r> for ClientIp { let ip = ip.or(remote).unwrap_or_else(|| "0.0.0.0".parse().unwrap()); - Outcome::Success(ClientIp { + Outcome::Success(Self { ip, }) } @@ -1352,7 +1352,7 @@ impl<'r> FromRequest<'r> for Secure { } }; - Outcome::Success(Secure { + Outcome::Success(Self { https: protocol == "https", }) } @@ -1398,7 +1398,7 @@ impl<'r> FromRequest<'r> for ClientVersion { err_handler!("Invalid Bitwarden-Client-Version header provided") }; - Outcome::Success(ClientVersion(version)) + Outcome::Success(Self(version)) } } @@ -1414,9 +1414,9 @@ pub enum AuthMethod { impl AuthMethod { pub fn scope(&self) -> String { match self { - AuthMethod::OrgApiKey => "api.organization".to_owned(), - AuthMethod::UserApiKey => "api".to_owned(), - AuthMethod::Password | AuthMethod::Sso => "api offline_access".to_owned(), + Self::OrgApiKey => "api.organization".to_owned(), + Self::UserApiKey => "api".to_owned(), + Self::Password | Self::Sso => "api offline_access".to_owned(), } } @@ -1486,9 +1486,9 @@ impl AuthTokens { let access_claims = LoginJwtClaims::default(device, user, &sub, client_id); let validity = if device.is_mobile() { - *MOBILE_REFRESH_VALIDITY + MOBILE_REFRESH_VALIDITY } else { - *DEFAULT_REFRESH_VALIDITY + DEFAULT_REFRESH_VALIDITY }; let refresh_claims = RefreshJwtClaims { diff --git a/src/auth/send.rs b/src/auth/send.rs index 85b91d99..d6ae943e 100644 --- a/src/auth/send.rs +++ b/src/auth/send.rs @@ -45,7 +45,7 @@ impl SendTokens { }) } - fn expected_error(msg: &str, error_type: &str) -> ApiResult { + fn expected_error(msg: &str, error_type: &str) -> ApiResult { let err = json!({ "kind": "expected_server", "error": "invalid_request", @@ -55,7 +55,7 @@ impl SendTokens { Err(Error::new_msg(msg).with_kind(ErrorKind::Json(err)).silent()) } - fn invalid_error(msg: &str, error_type: &str, silent: bool) -> ApiResult { + fn invalid_error(msg: &str, error_type: &str, silent: bool) -> ApiResult { let err = json!({ "kind": "expected_server", "error": "invalid_grant", @@ -70,7 +70,7 @@ impl SendTokens { password: Option, ip: &ClientIp, conn: &DbConn, - ) -> ApiResult { + ) -> ApiResult { let Some(send_id) = Self::as_send_id(access_id) else { return Self::invalid_error( &format!("Can't convert {}", access_id.escape_debug()), @@ -140,7 +140,7 @@ impl<'r> FromRequest<'r> for SendHeaders { err_handler!("Invalid claim") }; - Outcome::Success(SendHeaders { + Outcome::Success(Self { send_id: claims.sub.into(), }) } diff --git a/src/config.rs b/src/config.rs index 165ead41..6fecf2bf 100644 --- a/src/config.rs +++ b/src/config.rs @@ -129,7 +129,7 @@ macro_rules! make_config { )+)+ ]; - #[allow(non_camel_case_types)] + #[expect(non_camel_case_types, reason="ConfigBuilder uses different case types")] enum Field { $($( $name, @@ -362,7 +362,6 @@ macro_rules! make_config { elements: Vec, } - #[allow(unused)] impl Config { $($( $(#[doc = $doc])+ @@ -479,13 +478,11 @@ macro_rules! make_config { let mut json = serde_json::Map::new(); $($( json.insert(String::from(stringify!($name)), make_config! { @supportstr $name, cfg.$name, $ty, $none_action }); - )+)+; + )+)+ // Loop through all privacy sensitive keys and mask them for mask_key in PRIVACY_CONFIG { - if let Some(value) = json.get_mut(*mask_key) { - if let Some(s) = value.as_str() { - *value = privacy_mask(s).into(); - } + if let Some(value) = json.get_mut(*mask_key) && let Some(s) = value.as_str() { + *value = privacy_mask(s).into(); } } json @@ -693,7 +690,7 @@ make_config! { /// Set to the string "none" (without quotes), to disable any headers and just use the remote IP ip_header: String, true, def, "X-Real-IP".to_owned(); /// Internal IP header property, used to avoid recomputing each time - _ip_header_enabled: bool, false, generated, |c| &c.ip_header.trim().to_lowercase() != "none"; + _ip_header_enabled: bool, false, generated, |c| !c.ip_header.trim().eq_ignore_ascii_case("none"); /// Trusted proxies |> Which addresses the client IP header is accepted from. Requests from any /// other address use the remote IP instead, so a client can't spoof the header. /// Either the string "local" (the default, any non-global address, which covers a reverse proxy @@ -1422,13 +1419,7 @@ fn extract_url_origin(url: &str) -> String { /// Extracts the path from a URL. /// All trailing '/' chars are trimmed, even if the path is a lone '/'. fn extract_url_path(url: &str) -> String { - match Url::parse(url) { - Ok(u) => u.path().trim_end_matches('/').to_owned(), - Err(_) => { - // We already print it in the method above, no need to do it again - String::new() - } - } + Url::parse(url).map_or_default(|u| u.path().trim_end_matches('/').to_owned()) } fn generate_smtp_img_src(embed_images: bool, domain: &str) -> String { @@ -1463,10 +1454,7 @@ fn generate_icon_service_url(icon_service: &str) -> String { fn generate_icon_service_csp(icon_service: &str, icon_service_url: &str) -> String { // We split on the first '{', since that is the variable delimiter for an icon service URL. // Everything up until the first '{' should be fixed and can be used as an CSP string. - let csp_string = match icon_service_url.split_once('{') { - Some((c, _)) => c.to_owned(), - None => String::new(), - }; + let csp_string = icon_service_url.split_once('{').map_or_default(|(c, _)| c.to_owned()); // Because Google does a second redirect to there gstatic.com domain, we need to add an extra csp string. match icon_service { @@ -1480,9 +1468,9 @@ fn smtp_convert_deprecated_ssl_options(smtp_ssl: Option, smtp_explicit_tls if smtp_explicit_tls.is_some() || smtp_ssl.is_some() { println!("[DEPRECATED]: `SMTP_SSL` or `SMTP_EXPLICIT_TLS` is set. Please use `SMTP_SECURITY` instead."); } - if smtp_explicit_tls.is_some() && smtp_explicit_tls.unwrap() { + if smtp_explicit_tls.is_some_and(|b| b) { return "force_tls".to_owned(); - } else if smtp_ssl.is_some() && !smtp_ssl.unwrap() { + } else if smtp_ssl.is_some_and(|b| !b) { return "off".to_owned(); } // Return the default `starttls` in all other cases @@ -1566,7 +1554,7 @@ impl Config { validate_config(&config, false)?; } - Ok(Config { + Ok(Self { inner: RwLock::new(Inner { rocket_shutdown_handle: None, templates: load_templates(&config.templates_folder), @@ -1625,15 +1613,17 @@ impl Config { /// is in signups_domains_whitelist, or if no whitelist is set (so there /// are no domain restrictions in effect). pub fn is_email_domain_allowed(&self, email: &str) -> bool { - let e: Vec<&str> = email.rsplitn(2, '@').collect(); - if e.len() != 2 || e[0].is_empty() || e[1].is_empty() { + let Some((_, domain)) = email.rsplit_once('@').filter(|(name, domain)| !name.is_empty() && !domain.is_empty()) + else { warn!("Failed to parse email address '{}'", email.escape_debug()); return false; - } - let email_domain = e[0].to_lowercase(); + }; + + let domain = &domain.to_lowercase(); let whitelist = self.signups_domains_whitelist(); + let whitelist = whitelist.trim(); - whitelist.is_empty() || whitelist.split(',').any(|d| d.trim() == email_domain) + whitelist.is_empty() || whitelist.split(',').any(|d| d.trim() == domain) } /// Tests whether signup is allowed for an email address, taking into @@ -1724,8 +1714,7 @@ impl Config { /// Tests whether the admin token is set to a non-empty value. pub fn is_admin_token_set(&self) -> bool { let token = self.admin_token(); - - token.is_some() && !token.unwrap().trim().is_empty() + token.is_some_and(|t| !t.trim().is_empty()) } pub fn opendal_operator_for_path_type(&self, path_type: &PathType) -> Result { diff --git a/src/db/mod.rs b/src/db/mod.rs index 39aea1d3..c0531a47 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -1,7 +1,6 @@ mod query_logger; use std::{ - future::Future, sync::{ Arc, OnceLock, atomic::{AtomicBool, Ordering}, @@ -237,7 +236,7 @@ impl DbPool { error!("Tried to set the active database connection type more than once."); } - Ok(DbPool { + Ok(Self { pool: Some(pool), semaphore: Arc::new(Semaphore::new(max_conns as usize)), }) @@ -268,25 +267,25 @@ impl DbPool { impl DbConnType { pub fn from_url(url: &str) -> Result { // Mysql - if url.len() > 6 && &url[..6] == "mysql:" { + if url.starts_with("mysql:") { #[cfg(mysql)] - return Ok(DbConnType::Mysql); + return Ok(Self::Mysql); #[cfg(not(mysql))] err!("`DATABASE_URL` is a MySQL URL, but the 'mysql' feature is not enabled") // Postgresql - } else if url.len() > 11 && (&url[..11] == "postgresql:" || &url[..9] == "postgres:") { + } else if url.starts_with("postgresql:") || url.starts_with("postgres:") { #[cfg(postgresql)] - return Ok(DbConnType::Postgresql); + return Ok(Self::Postgresql); #[cfg(not(postgresql))] err!("`DATABASE_URL` is a PostgreSQL URL, but the 'postgresql' feature is not enabled") // Sqlite (explicit) - } else if url.len() > 7 && &url[..7] == "sqlite:" { + } else if url.starts_with("sqlite:") { #[cfg(sqlite)] - return Ok(DbConnType::Sqlite); + return Ok(Self::Sqlite); #[cfg(not(sqlite))] err!("`DATABASE_URL` is a SQLite URL, but the 'sqlite' feature is not enabled") @@ -297,7 +296,7 @@ impl DbConnType { #[cfg(sqlite)] { if std::path::Path::new(url).exists() { - return Ok(DbConnType::Sqlite); + return Ok(Self::Sqlite); } err!(format!( "`DATABASE_URL` does not match any known database scheme (mysql://, postgresql://, sqlite://) \ @@ -438,8 +437,6 @@ pub mod models; /// MySQL/MariaDB and PostgreSQL are not supported. #[cfg(sqlite)] pub fn backup_sqlite() -> Result { - use diesel::Connection; - let db_url = CONFIG.database_url(); if DbConnType::from_url(&CONFIG.database_url()).is_ok_and(|t| t == DbConnType::Sqlite) { // Strip the sqlite:// prefix if present to get the raw file path diff --git a/src/db/models/attachment.rs b/src/db/models/attachment.rs index 52d6d207..092ad057 100644 --- a/src/db/models/attachment.rs +++ b/src/db/models/attachment.rs @@ -146,7 +146,7 @@ impl Attachment { } pub async fn delete_all_by_cipher(cipher_uuid: &CipherId, conn: &DbConn) -> EmptyResult { - for attachment in Attachment::find_by_cipher(cipher_uuid, conn).await { + for attachment in Self::find_by_cipher(cipher_uuid, conn).await { attachment.delete(conn).await?; } Ok(()) diff --git a/src/db/models/cipher.rs b/src/db/models/cipher.rs index 97807279..b76572a8 100644 --- a/src/db/models/cipher.rs +++ b/src/db/models/cipher.rs @@ -97,8 +97,8 @@ impl CipherAccessScope { /// Whether `member` reaches every cipher of their organization with this access. fn reaches_all_ciphers(self, member: &Membership) -> bool { match self { - CipherAccessScope::User => member.has_full_access(), - CipherAccessScope::OrganizationAdmin => member.can_edit_any_collection(), + Self::User => member.has_full_access(), + Self::OrganizationAdmin => member.can_edit_any_collection(), } } @@ -106,18 +106,18 @@ impl CipherAccessScope { /// administrative one still needs a member who may edit any collection. pub fn requested(admin_request: Option) -> Self { if admin_request == Some(true) { - CipherAccessScope::OrganizationAdmin + Self::OrganizationAdmin } else { - CipherAccessScope::User + Self::User } } /// The access for a route that does not tell which one it is, from the member's own membership. pub fn for_member(member: Option<&Membership>) -> Self { if member.is_some_and(Membership::can_edit_any_collection) { - CipherAccessScope::OrganizationAdmin + Self::OrganizationAdmin } else { - CipherAccessScope::User + Self::User } } } @@ -306,7 +306,7 @@ impl Cipher { .inspect_err(|e| warn!("Error parsing fields {e:?} for {}", self.uuid)) .ok() }) - .map(|d| { + .map_or_default(|d| { d.into_iter() .map(|mut f| { // Check if the `type` key is a number, strings break some clients @@ -326,8 +326,7 @@ impl Cipher { f.data }) .collect() - }) - .unwrap_or_default(); + }); let password_history_json: Vec<_> = self .password_history @@ -337,7 +336,7 @@ impl Cipher { .inspect_err(|e| warn!("Error parsing password history {e:?} for {}", self.uuid)) .ok() }) - .map(|d| { + .map_or_default(|d| { // Check every password history item if they are valid and return it. // If a password field has the type `null` skip it, it breaks newer Bitwarden clients // A second check is done to verify the lastUsedDate exists and is a valid DateTime string, if not the epoch start time will be used @@ -356,19 +355,14 @@ impl Cipher { d }) .collect() - }) - .unwrap_or_default(); + }); // Like upstream, fields and password history stored as NULL are sent as null, not `[]` let fields_json = self.fields.is_some().then_some(fields_json); let password_history_json = self.password_history.is_some().then_some(password_history_json); let collection_ids = if let Some(cipher_sync_data) = cipher_sync_data { - if let Some(cipher_collections) = cipher_sync_data.cipher_collections.get(&self.uuid) { - Cow::from(cipher_collections) - } else { - Cow::from(Vec::new()) - } + cipher_sync_data.cipher_collections.get(&self.uuid).map_or_default(Cow::from) } else { Cow::from(self.get_admin_collections(user_uuid.clone(), scope, conn).await) }; @@ -688,7 +682,7 @@ impl Cipher { /// Returns whether this cipher is directly owned by the user. pub fn is_owned_by_user(&self, user_uuid: &UserId) -> bool { - self.user_uuid.is_some() && self.user_uuid.as_ref().unwrap() == user_uuid + self.user_uuid.as_ref().is_some_and(|u| u == user_uuid) } /// Returns whether this cipher is owned by an org in which the user reaches every cipher with `scope`. @@ -875,10 +869,9 @@ impl Cipher { scope: CipherAccessScope, conn: &DbConn, ) -> bool { - match self.get_access_restrictions(user_uuid, scope, None, conn).await { - Some((read_only, _hide_passwords, manage)) => !read_only || manage, - None => false, - } + self.get_access_restrictions(user_uuid, scope, None, conn) + .await + .is_some_and(|(read_only, _hide_passwords, manage)| !read_only || manage) } // used for checking if collection can be edited (only if user has access to a collection they @@ -889,10 +882,9 @@ impl Cipher { scope: CipherAccessScope, conn: &DbConn, ) -> bool { - match self.get_access_restrictions(user_uuid, scope, None, conn).await { - Some((read_only, hide_passwords, manage)) => (!read_only && !hide_passwords) || manage, - None => false, - } + self.get_access_restrictions(user_uuid, scope, None, conn) + .await + .is_some_and(|(read_only, hide_passwords, manage)| (!read_only && !hide_passwords) || manage) } pub async fn is_accessible_to_user(&self, user_uuid: &UserId, scope: CipherAccessScope, conn: &DbConn) -> bool { diff --git a/src/db/models/collection.rs b/src/db/models/collection.rs index 4f1533e3..5d450692 100644 --- a/src/db/models/collection.rs +++ b/src/db/models/collection.rs @@ -878,7 +878,7 @@ impl CollectionUser { } pub async fn delete_all_by_collection(collection_uuid: &CollectionId, conn: &DbConn) -> EmptyResult { - for collection in &CollectionUser::find_by_collection(collection_uuid, conn).await { + for collection in &Self::find_by_collection(collection_uuid, conn).await { User::update_uuid_revision(&collection.user_uuid, conn).await; } diff --git a/src/db/models/device.rs b/src/db/models/device.rs index 5e5f1f97..8e855919 100644 --- a/src/db/models/device.rs +++ b/src/db/models/device.rs @@ -51,7 +51,7 @@ impl Device { push_uuid: Some(PushId(get_uuid())), push_token: None, - refresh_token: Device::generate_refresh_token(), + refresh_token: Self::generate_refresh_token(), twofactor_remember: None, } } @@ -268,7 +268,7 @@ impl Device { // We cannot do a single UPDATE with one value because each device needs a unique token. let devices = Self::find_by_user(user_uuid, conn).await; for mut device in devices { - device.refresh_token = Device::generate_refresh_token(); + device.refresh_token = Self::generate_refresh_token(); device.twofactor_remember = None; device.save(false, conn).await?; } @@ -347,36 +347,36 @@ pub enum DeviceType { impl DeviceType { #[expect(clippy::match_same_arms, reason = "Specifically define 14 and have a fallback for new types")] - pub fn from_i32(value: i32) -> DeviceType { + pub fn from_i32(value: i32) -> Self { match value { - 0 => DeviceType::Android, - 1 => DeviceType::Ios, - 2 => DeviceType::ChromeExtension, - 3 => DeviceType::FirefoxExtension, - 4 => DeviceType::OperaExtension, - 5 => DeviceType::EdgeExtension, - 6 => DeviceType::WindowsDesktop, - 7 => DeviceType::MacOsDesktop, - 8 => DeviceType::LinuxDesktop, - 9 => DeviceType::ChromeBrowser, - 10 => DeviceType::FirefoxBrowser, - 11 => DeviceType::OperaBrowser, - 12 => DeviceType::EdgeBrowser, - 13 => DeviceType::IEBrowser, - 14 => DeviceType::UnknownBrowser, - 15 => DeviceType::AndroidAmazon, - 16 => DeviceType::Uwp, - 17 => DeviceType::SafariBrowser, - 18 => DeviceType::VivaldiBrowser, - 19 => DeviceType::VivaldiExtension, - 20 => DeviceType::SafariExtension, - 21 => DeviceType::Sdk, - 22 => DeviceType::Server, - 23 => DeviceType::WindowsCLI, - 24 => DeviceType::MacOsCLI, - 25 => DeviceType::LinuxCLI, - 26 => DeviceType::DuckDuckGoBrowser, - _ => DeviceType::UnknownBrowser, + 0 => Self::Android, + 1 => Self::Ios, + 2 => Self::ChromeExtension, + 3 => Self::FirefoxExtension, + 4 => Self::OperaExtension, + 5 => Self::EdgeExtension, + 6 => Self::WindowsDesktop, + 7 => Self::MacOsDesktop, + 8 => Self::LinuxDesktop, + 9 => Self::ChromeBrowser, + 10 => Self::FirefoxBrowser, + 11 => Self::OperaBrowser, + 12 => Self::EdgeBrowser, + 13 => Self::IEBrowser, + 14 => Self::UnknownBrowser, + 15 => Self::AndroidAmazon, + 16 => Self::Uwp, + 17 => Self::SafariBrowser, + 18 => Self::VivaldiBrowser, + 19 => Self::VivaldiExtension, + 20 => Self::SafariExtension, + 21 => Self::Sdk, + 22 => Self::Server, + 23 => Self::WindowsCLI, + 24 => Self::MacOsCLI, + 25 => Self::LinuxCLI, + 26 => Self::DuckDuckGoBrowser, + _ => Self::UnknownBrowser, } } } diff --git a/src/db/models/emergency_access.rs b/src/db/models/emergency_access.rs index 02c05d5e..40fadea3 100644 --- a/src/db/models/emergency_access.rs +++ b/src/db/models/emergency_access.rs @@ -141,8 +141,8 @@ pub enum EmergencyAccessType { impl EmergencyAccessType { pub fn from_str(s: &str) -> Option { match s { - "0" | "View" => Some(EmergencyAccessType::View), - "1" | "Takeover" => Some(EmergencyAccessType::Takeover), + "0" | "View" => Some(Self::View), + "1" | "Takeover" => Some(Self::Takeover), _ => None, } } @@ -397,7 +397,7 @@ impl EmergencyAccess { } pub async fn accept_invite(&mut self, grantee_uuid: &UserId, grantee_email: &str, conn: &DbConn) -> EmptyResult { - if self.email.is_none() || self.email.as_ref().unwrap() != grantee_email { + if self.email.as_ref().is_none_or(|e| e != grantee_email) { err!("User email does not match invite."); } diff --git a/src/db/models/event.rs b/src/db/models/event.rs index 84a73a0d..09fac4b9 100644 --- a/src/db/models/event.rs +++ b/src/db/models/event.rs @@ -151,11 +151,7 @@ pub enum EventType { /// Local methods impl Event { pub fn new(event_type: i32, event_date: Option) -> Self { - let event_date = match event_date { - Some(d) => d, - None => Utc::now().naive_utc(), - }; - + let event_date = event_date.unwrap_or_else(|| Utc::now().naive_utc()); Self { uuid: EventId(crate::util::get_uuid()), event_type, @@ -230,7 +226,7 @@ impl Event { } } - pub async fn save_user_event(events: Vec, conn: &DbConn) -> EmptyResult { + pub async fn save_user_event(events: Vec, conn: &DbConn) -> EmptyResult { // Special save function which is able to handle multiple events. // SQLite doesn't support the DEFAULT argument, and does not support inserting multiple values at the same time. // MySQL and PostgreSQL do. diff --git a/src/db/models/group.rs b/src/db/models/group.rs index c8df7ef2..1ca86912 100644 --- a/src/db/models/group.rs +++ b/src/db/models/group.rs @@ -315,7 +315,7 @@ impl Group { } impl CollectionGroup { - pub async fn save(&mut self, org_uuid: &OrganizationId, conn: &DbConn) -> EmptyResult { + pub async fn save(&self, org_uuid: &OrganizationId, conn: &DbConn) -> EmptyResult { let group_users = GroupUser::find_by_group(&self.groups_uuid, org_uuid, conn).await; for group_user in group_users { group_user.update_user_revision(conn).await; @@ -448,7 +448,7 @@ impl CollectionGroup { org_uuid: &OrganizationId, conn: &DbConn, ) -> EmptyResult { - let collection_assigned_to_groups = CollectionGroup::find_by_collection(collection_uuid, conn).await; + let collection_assigned_to_groups = Self::find_by_collection(collection_uuid, conn).await; for collection_assigned_to_group in collection_assigned_to_groups { let group_users = GroupUser::find_by_group(&collection_assigned_to_group.groups_uuid, org_uuid, conn).await; for group_user in group_users { @@ -467,7 +467,7 @@ impl CollectionGroup { } impl GroupUser { - pub async fn save(&mut self, conn: &DbConn) -> EmptyResult { + pub async fn save(&self, conn: &DbConn) -> EmptyResult { self.update_user_revision(conn).await; let values = ( @@ -574,7 +574,7 @@ impl GroupUser { } pub async fn delete_all_by_group(group_uuid: &GroupId, org_uuid: &OrganizationId, conn: &DbConn) -> EmptyResult { - let group_users = GroupUser::find_by_group(group_uuid, org_uuid, conn).await; + let group_users = Self::find_by_group(group_uuid, org_uuid, conn).await; for group_user in group_users { group_user.update_user_revision(conn).await; } diff --git a/src/db/models/org_policy.rs b/src/db/models/org_policy.rs index ccb738b2..eed0740d 100644 --- a/src/db/models/org_policy.rs +++ b/src/db/models/org_policy.rs @@ -301,11 +301,9 @@ impl OrgPolicy { exclude_org_uuid: Option<&OrganizationId>, conn: &DbConn, ) -> bool { - for policy in - OrgPolicy::find_accepted_and_confirmed_by_user_and_active_policy(user_uuid, policy_type, conn).await - { + for policy in Self::find_accepted_and_confirmed_by_user_and_active_policy(user_uuid, policy_type, conn).await { // Check if we need to skip this organization. - if exclude_org_uuid.is_some() && *exclude_org_uuid.unwrap() == policy.org_uuid { + if exclude_org_uuid.is_some_and(|u| u == &policy.org_uuid) { continue; } @@ -370,7 +368,7 @@ impl OrgPolicy { return false; } - match OrgPolicy::find_by_org_and_type(org_uuid, OrgPolicyType::ResetPassword, conn).await { + match Self::find_by_org_and_type(org_uuid, OrgPolicyType::ResetPassword, conn).await { Some(policy) => match serde_json::from_str::(&policy.data) { Ok(opts) => { return policy.enabled && opts.auto_enroll_enabled; @@ -386,8 +384,7 @@ impl OrgPolicy { /// Returns true if the user belongs to an org that has enabled the `DisableHideEmail` /// option of the `Send Options` policy, and the user is not an owner or admin of that org. pub async fn is_hide_email_disabled(user_uuid: &UserId, conn: &DbConn) -> bool { - for policy in - OrgPolicy::find_confirmed_by_user_and_active_policy(user_uuid, OrgPolicyType::SendOptions, conn).await + for policy in Self::find_confirmed_by_user_and_active_policy(user_uuid, OrgPolicyType::SendOptions, conn).await { if let Some(user) = Membership::find_confirmed_by_user_and_org(user_uuid, &policy.org_uuid, conn).await && user.atype < MembershipType::Admin @@ -407,7 +404,7 @@ impl OrgPolicy { pub async fn is_enabled_for_member(member_uuid: &MembershipId, policy_type: OrgPolicyType, conn: &DbConn) -> bool { if let Some(member) = Membership::find_by_uuid(member_uuid, conn).await - && let Some(policy) = OrgPolicy::find_by_org_and_type(&member.org_uuid, policy_type, conn).await + && let Some(policy) = Self::find_by_org_and_type(&member.org_uuid, policy_type, conn).await { return policy.enabled; } diff --git a/src/db/models/organization.rs b/src/db/models/organization.rs index 4b859406..6f90a214 100644 --- a/src/db/models/organization.rs +++ b/src/db/models/organization.rs @@ -134,11 +134,11 @@ pub enum MembershipType { impl MembershipType { pub fn from_str(s: &str) -> Option { match s { - "0" | "Owner" => Some(MembershipType::Owner), - "1" | "Admin" => Some(MembershipType::Admin), - "2" | "User" => Some(MembershipType::User), - "3" | "Manager" => Some(MembershipType::Manager), - "4" | "Custom" => Some(MembershipType::Custom), + "0" | "Owner" => Some(Self::Owner), + "1" | "Admin" => Some(Self::Admin), + "2" | "User" => Some(Self::User), + "3" | "Manager" => Some(Self::Manager), + "4" | "Custom" => Some(Self::Custom), _ => None, } } @@ -152,23 +152,23 @@ impl MembershipType { /// keeps their role when the request repeats it, so an unrelated edit never turns one into the other. A /// Manager only becomes a Custom member when the permissions they are shown with are changed. pub fn requested( - requested: MembershipType, + requested: Self, current: Option<&Membership>, custom_permissions: Option<&HashSet>, - ) -> MembershipType { - if requested != MembershipType::Custom { + ) -> Self { + if requested != Self::Custom { return requested; } match (current, custom_permissions) { - (Some(member), _) if member.has_type(MembershipType::Custom) => MembershipType::Custom, + (Some(member), _) if member.has_type(Self::Custom) => Self::Custom, (Some(member), Some(permissions)) - if member.has_type(MembershipType::Manager) && *permissions != member.legacy_manager_permissions() => + if member.has_type(Self::Manager) && *permissions != member.legacy_manager_permissions() => { - MembershipType::Custom + Self::Custom } - (Some(member), _) if member.has_type(MembershipType::Manager) => MembershipType::Manager, - (_, Some(_)) => MembershipType::Custom, - (_, None) => MembershipType::Manager, + (Some(member), _) if member.has_type(Self::Manager) => Self::Manager, + (_, Some(_)) => Self::Custom, + (_, None) => Self::Manager, } } @@ -176,23 +176,23 @@ impl MembershipType { /// its permissions, never from its role, so the role itself ranks right above User and below Manager. const fn rank(self) -> u8 { match self { - MembershipType::User => 0, - MembershipType::Custom => 1, - MembershipType::Manager => 2, - MembershipType::Admin => 3, - MembershipType::Owner => 4, + Self::User => 0, + Self::Custom => 1, + Self::Manager => 2, + Self::Admin => 3, + Self::Owner => 4, } } } impl Ord for MembershipType { - fn cmp(&self, other: &MembershipType) -> Ordering { + fn cmp(&self, other: &Self) -> Ordering { self.rank().cmp(&other.rank()) } } impl PartialOrd for MembershipType { - fn partial_cmp(&self, other: &MembershipType) -> Option { + fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } @@ -222,7 +222,7 @@ impl PartialOrd for MembershipType { impl PartialEq for i32 { fn eq(&self, other: &MembershipType) -> bool { - *self == *other as i32 + *self == *other as Self } } @@ -275,32 +275,32 @@ const SUPPORTED_CUSTOM_PERMISSIONS: &[CustomPermission] = &[ ]; impl CustomPermission { - pub const ALL: [CustomPermission; 10] = [ - CustomPermission::ManageUsers, - CustomPermission::ManageGroups, - CustomPermission::ManagePolicies, - CustomPermission::CreateNewCollections, - CustomPermission::EditAnyCollection, - CustomPermission::DeleteAnyCollection, - CustomPermission::AccessEventLogs, - CustomPermission::AccessImportExport, - CustomPermission::AccessReports, - CustomPermission::ManageResetPassword, + pub const ALL: [Self; 10] = [ + Self::ManageUsers, + Self::ManageGroups, + Self::ManagePolicies, + Self::CreateNewCollections, + Self::EditAnyCollection, + Self::DeleteAnyCollection, + Self::AccessEventLogs, + Self::AccessImportExport, + Self::AccessReports, + Self::ManageResetPassword, ]; /// The key of the permission in the `permissions` object of the Bitwarden clients. pub const fn json_key(self) -> &'static str { match self { - CustomPermission::ManageUsers => "manageUsers", - CustomPermission::ManageGroups => "manageGroups", - CustomPermission::ManagePolicies => "managePolicies", - CustomPermission::CreateNewCollections => "createNewCollections", - CustomPermission::EditAnyCollection => "editAnyCollection", - CustomPermission::DeleteAnyCollection => "deleteAnyCollection", - CustomPermission::AccessEventLogs => "accessEventLogs", - CustomPermission::AccessImportExport => "accessImportExport", - CustomPermission::AccessReports => "accessReports", - CustomPermission::ManageResetPassword => "manageResetPassword", + Self::ManageUsers => "manageUsers", + Self::ManageGroups => "manageGroups", + Self::ManagePolicies => "managePolicies", + Self::CreateNewCollections => "createNewCollections", + Self::EditAnyCollection => "editAnyCollection", + Self::DeleteAnyCollection => "deleteAnyCollection", + Self::AccessEventLogs => "accessEventLogs", + Self::AccessImportExport => "accessImportExport", + Self::AccessReports => "accessReports", + Self::ManageResetPassword => "manageResetPassword", } } @@ -314,9 +314,9 @@ impl CustomPermission { /// replaces the member's permissions, so a malformed value must not silently remove one. Granting a /// permission this version does not enforce is rejected as well. The clients also send permissions /// Vaultwarden does not know at all, like `manageSso`, those are ignored. - pub fn requested(permissions: &HashMap) -> Result, Error> { + pub fn requested(permissions: &HashMap) -> Result, Error> { let mut granted = HashSet::new(); - for permission in CustomPermission::ALL { + for permission in Self::ALL { match permissions.get(permission.json_key()) { None | Some(Value::Bool(false)) => {} Some(Value::Bool(true)) if permission.is_supported() => { @@ -581,7 +581,7 @@ impl Membership { /// Whether this member may act with every Custom role permission stored for `other`, as Bitwarden's /// `Permissions.Includes`. - pub fn has_custom_permissions_of(&self, other: &Membership) -> bool { + pub fn has_custom_permissions_of(&self, other: &Self) -> bool { CustomPermission::ALL.into_iter().all(|p| !other.custom_permission(p) || self.has_custom_permission(p)) } @@ -928,7 +928,7 @@ impl Membership { json!({ "id": self.uuid, "userId": self.user_uuid, - "name": if self.get_unrevoked_status() >= MembershipStatus::Accepted as i32 { Some(user.name) } else { None }, + "name": (self.get_unrevoked_status() >= MembershipStatus::Accepted as i32).then_some(user.name), "email": user.email, "externalId": self.external_id, "avatarColor": user.avatar_color, @@ -1081,9 +1081,9 @@ impl Membership { Ok(()) } - pub async fn find_by_email_and_org(email: &str, org_uuid: &OrganizationId, conn: &DbConn) -> Option { + pub async fn find_by_email_and_org(email: &str, org_uuid: &OrganizationId, conn: &DbConn) -> Option { if let Some(user) = User::find_by_mail(email, conn).await - && let Some(member) = Membership::find_by_user_and_org(&user.uuid, org_uuid, conn).await + && let Some(member) = Self::find_by_user_and_org(&user.uuid, org_uuid, conn).await { return Some(member); } diff --git a/src/db/models/send.rs b/src/db/models/send.rs index 118f947f..fce5d335 100644 --- a/src/db/models/send.rs +++ b/src/db/models/send.rs @@ -58,9 +58,9 @@ pub enum SendType { } enum SendAuthType { - #[allow(dead_code)] + #[expect(unused, reason = "Not yet supported")] // Send requires email OTP verification - Email = 0, // Not yet supported by Vaultwarden + Email = 0, // Send requires a password Password = 1, // Send requires no auth @@ -145,7 +145,7 @@ impl Send { } pub fn to_json(&self) -> Value { - let mut data = serde_json::from_str::>(&self.data).map(|d| d.data).unwrap_or_default(); + let mut data = serde_json::from_str::>(&self.data).map_or_default(|d| d.data); // Mobile clients expect size to be a string instead of a number if let Some(size) = data.get("size").and_then(Value::as_i64) { @@ -159,8 +159,8 @@ impl Send { "name": self.name, "notes": self.notes, - "text": if self.atype == SendType::Text as i32 { Some(&data) } else { None }, - "file": if self.atype == SendType::File as i32 { Some(&data) } else { None }, + "text": (self.atype == SendType::Text as i32).then_some(&data), + "file": (self.atype == SendType::File as i32).then_some(&data), "key": self.akey, "maxAccessCount": self.max_access_count, @@ -178,7 +178,7 @@ impl Send { } pub async fn to_json_access(&self, conn: &DbConn) -> Value { - let mut data = serde_json::from_str::>(&self.data).map(|d| d.data).unwrap_or_default(); + let mut data = serde_json::from_str::>(&self.data).map_or_default(|d| d.data); // Mobile clients expect size to be a string instead of a number if let Some(size) = data.get("size").and_then(Value::as_i64) { @@ -190,8 +190,8 @@ impl Send { "type": self.atype, "name": self.name, - "text": if self.atype == SendType::Text as i32 { Some(&data) } else { None }, - "file": if self.atype == SendType::File as i32 { Some(&data) } else { None }, + "text": (self.atype == SendType::Text as i32).then_some(&data), + "file": (self.atype == SendType::File as i32).then_some(&data), "expirationDate": self.expiration_date.as_ref().map(format_date), "creatorIdentifier": self.creator_identifier(conn).await, diff --git a/src/db/models/sso_auth.rs b/src/db/models/sso_auth.rs index 311e9bf9..0929a2d4 100644 --- a/src/db/models/sso_auth.rs +++ b/src/db/models/sso_auth.rs @@ -67,7 +67,7 @@ impl SsoAuth { ) -> Self { let now = Utc::now().naive_utc(); - SsoAuth { + Self { state, client_challenge, nonce, diff --git a/src/db/models/two_factor.rs b/src/db/models/two_factor.rs index 051ea4df..d7ceb895 100644 --- a/src/db/models/two_factor.rs +++ b/src/db/models/two_factor.rs @@ -227,7 +227,7 @@ impl TwoFactor { u2f.data = serde_json::to_string(®s)?; u2f.save(conn).await?; - TwoFactor::new(u2f.user_uuid.clone(), TwoFactorType::Webauthn, serde_json::to_string(&webauthn_regs)?) + Self::new(u2f.user_uuid.clone(), TwoFactorType::Webauthn, serde_json::to_string(&webauthn_regs)?) .save(conn) .await?; } @@ -254,7 +254,7 @@ impl TwoFactor { let regs = regs.into_iter().map(Into::into).collect::>(); - TwoFactor::new(webauthn_factor.user_uuid.clone(), TwoFactorType::Webauthn, serde_json::to_string(®s)?) + Self::new(webauthn_factor.user_uuid.clone(), TwoFactorType::Webauthn, serde_json::to_string(®s)?) .save(conn) .await?; } diff --git a/src/db/models/user.rs b/src/db/models/user.rs index 49ea67b7..ebb2d3b3 100644 --- a/src/db/models/user.rs +++ b/src/db/models/user.rs @@ -147,7 +147,7 @@ impl User { verified_at: None, last_verifying_at: None, login_verify_count: 0, - name: name.unwrap_or(email.clone()), + name: name.unwrap_or_else(|| email.clone()), email, akey: String::new(), email_new: None, @@ -222,15 +222,11 @@ impl User { } pub fn check_valid_recovery_code(&self, recovery_code: &str) -> bool { - if let Some(ref totp_recover) = self.totp_recover { - crypto::ct_eq(recovery_code, totp_recover.to_lowercase()) - } else { - false - } + self.totp_recover.as_ref().is_some_and(|c| crypto::ct_eq(recovery_code, c.to_lowercase())) } pub fn check_valid_api_key(&self, key: &str) -> bool { - matches!(self.api_key, Some(ref api_key) if crypto::ct_eq(api_key, key)) + self.api_key.as_ref().is_some_and(|k| crypto::ct_eq(key, k)) } /// Set the password hash generated @@ -290,7 +286,7 @@ impl User { grace.push(UserStampException { routes: None, security_stamp: previous_stamp, - expire: (Utc::now() + *DEFAULT_ACCESS_VALIDITY).timestamp(), + expire: (Utc::now() + DEFAULT_ACCESS_VALIDITY).timestamp(), }); let mut exceptions = self.stamp_exceptions(); exceptions.extend(grace); diff --git a/src/http_client.rs b/src/http_client.rs index 6225e233..1c859760 100644 --- a/src/http_client.rs +++ b/src/http_client.rs @@ -161,13 +161,9 @@ pub fn should_block_host>(host: &Host) -> Result<(), CustomHttp }); } - if should_block_address_regex(&host_str) { - return Err(CustomHttpClientError::Blocked { - domain: host_str, - }); - } - - Ok(()) + (!should_block_address_regex(&host_str)).ok_or(CustomHttpClientError::Blocked { + domain: host_str, + }) } #[derive(Debug, Clone)] @@ -211,7 +207,7 @@ impl CustomHttpClientError { while let Some(err) = source { source = err.source(); - if let Some(err) = err.downcast_ref::() { + if let Some(err) = err.downcast_ref::() { return Some(err); } } @@ -258,7 +254,7 @@ impl CustomDns { fn instance(enforce_block: bool) -> Self { static INSTANCE: LazyLock> = LazyLock::new(CustomDnsResolver::new); - CustomDns { + Self { enforce_block, resolver: Arc::clone(&*INSTANCE), } @@ -409,7 +405,7 @@ pub(crate) mod aws { Ok(HttpResponse::new(status, bytes.into())) }; - HttpConnectorFuture::new(Box::pin(future)) + HttpConnectorFuture::new(future) } } @@ -419,7 +415,7 @@ pub(crate) mod aws { _settings: &HttpConnectorSettings, _components: &RuntimeComponents, ) -> SharedHttpConnector { - SharedHttpConnector::new(AwsReqwestConnector { + SharedHttpConnector::new(Self { client: self.client.clone(), }) } @@ -430,8 +426,10 @@ pub(crate) mod aws { mod tests { use super::*; use crate::util::is_global_hardcoded; - use std::net::{Ipv4Addr, Ipv6Addr}; - use url::Host; + use std::{ + assert_matches, + net::{Ipv4Addr, Ipv6Addr}, + }; // === // IPv4 numeric-format normalization @@ -535,19 +533,19 @@ mod tests { #[test] fn get_valid_host_normalizes_decimal_int() { let h = get_valid_host("2130706433").expect("valid"); - assert!(matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::LOCALHOST)); + assert_matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::LOCALHOST); } #[test] fn get_valid_host_normalizes_hex() { let h = get_valid_host("0x7f000001").expect("valid"); - assert!(matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::LOCALHOST)); + assert_matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::LOCALHOST); } #[test] fn get_valid_host_normalizes_octal() { let h = get_valid_host("017700000001").expect("valid"); - assert!(matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::LOCALHOST)); + assert_matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::LOCALHOST); } // === diff --git a/src/mail.rs b/src/mail.rs index 14294213..e3b169e5 100644 --- a/src/mail.rs +++ b/src/mail.rs @@ -74,8 +74,8 @@ fn smtp_transport() -> AsyncSmtpTransport { let mut selected_mechanisms = vec![]; for wanted_mechanism in mechanism.split(',') { for m in &allowed_mechanisms { - if m.to_string().to_lowercase() - == wanted_mechanism.trim_matches(|c| c == '"' || c == '\'' || c == ' ').to_lowercase() + if m.to_string() + .eq_ignore_ascii_case(wanted_mechanism.trim_matches(|c| c == '"' || c == '\'' || c == ' ')) { selected_mechanisms.push(*m); } @@ -127,26 +127,17 @@ fn get_text(template_name: &'static str, data: serde_json::Value) -> Result<(Str } fn get_template(template_name: &str, data: &serde_json::Value) -> Result<(String, String), Error> { + const DELIMITER: &str = ""; let text = CONFIG.render_template(template_name, data)?; - let mut text_split = text.split(""); - - let subject = if let Some(s) = text_split.next() { - s.trim().to_owned() - } else { - err!("Template doesn't contain subject") - }; - - let body = if let Some(s) = text_split.next() { - s.trim().to_owned() - } else { + let Some((subject, body)) = text.split_once(DELIMITER) else { err!("Template doesn't contain body") }; - if text_split.next().is_some() { + if body.contains(DELIMITER) { err!("Template contains more than one body"); } - Ok((subject, body)) + Ok((subject.trim().to_owned(), body.trim().to_owned())) } pub async fn send_password_hint(address: &str, hint: Option) -> EmptyResult { diff --git a/src/main.rs b/src/main.rs index 6d34c850..d3d557eb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -243,7 +243,7 @@ fn init_logging() -> Result { let level = caps .get(1) .and_then(|m| log::LevelFilter::from_str(m.as_str()).ok()) - .ok_or(Error::new("Failed to parse global log level".to_owned(), ""))?; + .ok_or_else(|| Error::new("Failed to parse global log level".to_owned(), ""))?; let levels_override: Vec<(&str, log::LevelFilter)> = caps .get(2) @@ -258,7 +258,7 @@ fn init_logging() -> Result { }) .collect() }) - .ok_or(Error::new("Failed to parse overrides".to_owned(), ""))?; + .ok_or_else(|| Error::new("Failed to parse overrides".to_owned(), ""))?; (level, levels_override) } else { @@ -394,14 +394,7 @@ fn init_logging() -> Result { let thread = thread::current(); let thread = thread.name().unwrap_or("unnamed"); - let msg = match info.payload().downcast_ref::<&'static str>() { - Some(s) => *s, - None => match info.payload().downcast_ref::() { - Some(s) => &**s, - None => "Box", - }, - }; - + let msg = info.payload_as_str().unwrap_or("Box"); let backtrace = std::backtrace::Backtrace::force_capture(); match info.location() { @@ -764,7 +757,7 @@ fn schedule_jobs(pool: db::DbPool) { // tick, the one that was added earlier will run first. loop { sched.tick(); - runtime.block_on(tokio::time::sleep(tokio::time::Duration::from_millis(u64::from( + runtime.block_on(tokio::time::sleep(std::time::Duration::from_millis(u64::from( CONFIG.job_poll_interval_ms(), )))); } diff --git a/src/sso.rs b/src/sso.rs index baa17492..a1c12756 100644 --- a/src/sso.rs +++ b/src/sso.rs @@ -236,7 +236,7 @@ pub struct OIDCIdentifier(String); impl OIDCIdentifier { fn new(issuer: &str, subject: &str) -> Self { - OIDCIdentifier(format!("{issuer}/{subject}")) + Self(format!("{issuer}/{subject}")) } } @@ -283,14 +283,14 @@ pub async fn exchange_code( let user_info = client.user_info(token_response.access_token().to_owned()).await?; - let email = match id_claims.email().or(user_info.email()) { + let email = match id_claims.email().or_else(|| user_info.email()) { None => err!("Neither id token nor userinfo contained an email"), Some(e) => e.to_string().to_lowercase(), }; - let email_verified = id_claims.email_verified().or(user_info.email_verified()); + let email_verified = id_claims.email_verified().or_else(|| user_info.email_verified()); - let user_name = id_claims.preferred_username().or(user_info.preferred_username()).map(|un| un.to_string()); + let user_name = id_claims.preferred_username().or_else(|| user_info.preferred_username()).map(|un| un.to_string()); let refresh_token = token_response.refresh_token().map(openidconnect::RefreshToken::secret); if refresh_token.is_none() && CONFIG.sso_scopes_vec().contains(&"offline_access".to_owned()) { @@ -398,7 +398,7 @@ fn create_auth_tokens_impl( match decode_token_claims("refresh_token", &rt) { Err(_) => { let time_now = Utc::now(); - let exp = (time_now + *DEFAULT_REFRESH_VALIDITY).timestamp(); + let exp = (time_now + DEFAULT_REFRESH_VALIDITY).timestamp(); debug!("Non jwt refresh_token (expiration set to {exp})"); (time_now.timestamp(), exp, TokenWrapper::Refresh(rt)) } @@ -454,7 +454,7 @@ pub async fn exchange_refresh_token( } Some(TokenWrapper::Access(access_token)) => { let now = Utc::now(); - let exp_limit = (now + *BW_EXPIRATION).timestamp(); + let exp_limit = (now + BW_EXPIRATION).timestamp(); if exp < exp_limit { err_silent!("Access token is close to expiration but we have no refresh token") diff --git a/src/sso_client.rs b/src/sso_client.rs index 246e5678..46962c22 100644 --- a/src/sso_client.rs +++ b/src/sso_client.rs @@ -1,4 +1,4 @@ -use std::{borrow::Cow, collections::HashSet, future::Future, pin::Pin, sync::LazyLock, time::Duration}; +use std::{borrow::Cow, collections::HashSet, pin::Pin, sync::LazyLock, time::Duration}; use openidconnect::{ AccessToken, AsyncHttpClient, AuthDisplay, AuthPrompt, AuthType, AuthenticationFlow, AuthorizationCode, @@ -12,7 +12,7 @@ use openidconnect::{ CoreProviderMetadata, CoreResponseType, CoreRevocableToken, CoreRevocationErrorResponse, CoreTokenIntrospectionResponse, CoreTokenResponse, CoreTokenType, CoreUserInfoClaims, }, - http, url, + http, }; use regex::Regex; use url::Url; @@ -25,8 +25,8 @@ use crate::{ sso::{OIDCCode, OIDCCodeChallenge, OIDCCodeVerifier, OIDCState}, }; -static CLIENT_CACHE_KEY: LazyLock = LazyLock::new(|| "sso-client".to_owned()); -static CLIENT_CACHE: LazyLock> = LazyLock::new(|| { +const CLIENT_CACHE_KEY: &str = "sso-client"; +static CLIENT_CACHE: LazyLock> = LazyLock::new(|| { moka::sync::Cache::builder() .max_capacity(1) .time_to_live(Duration::from_secs(u64::from(CONFIG.sso_client_cache_expiration()))) @@ -154,7 +154,7 @@ impl Client { .set_token_uri(token_uri) .set_user_info_url(user_info_url); - Ok(Client { + Ok(Self { http_client, core_client, }) @@ -163,11 +163,11 @@ impl Client { // Simple cache to prevent recalling the discovery endpoint each time pub async fn cached() -> ApiResult { if CONFIG.sso_client_cache_expiration() > 0 { - match CLIENT_CACHE.get(&*CLIENT_CACHE_KEY) { + match CLIENT_CACHE.get(CLIENT_CACHE_KEY) { Some(client) => Ok(client), None => Self::get_client().await.inspect(|client| { debug!("Inserting new client in cache"); - CLIENT_CACHE.insert(CLIENT_CACHE_KEY.clone(), client.clone()); + CLIENT_CACHE.insert(CLIENT_CACHE_KEY, client.clone()); }), } } else { @@ -177,7 +177,7 @@ impl Client { pub fn invalidate() { if CONFIG.sso_client_cache_expiration() > 0 { - CLIENT_CACHE.invalidate(&*CLIENT_CACHE_KEY); + CLIENT_CACHE.invalidate(CLIENT_CACHE_KEY); } } @@ -287,7 +287,7 @@ impl Client { } pub async fn check_validity(access_token: String) -> EmptyResult { - let client = Client::cached().await?; + let client = Self::cached().await?; match client.user_info(AccessToken::new(access_token)).await { Err(err) => { err_silent!(format!("Failed to retrieve user info, token has probably been invalidated: {err}")) @@ -312,7 +312,7 @@ impl Client { } pub async fn exchange_refresh_token(refresh_token: String) -> ApiResult { - let client = Client::cached().await?; + let client = Self::cached().await?; REFRESH_CACHE .get_with(refresh_token.clone(), async move { client.exchange_refresh_token_impl(refresh_token).await }) diff --git a/src/storage.rs b/src/storage.rs index 32562a0d..1350329d 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -147,8 +147,7 @@ mod s3 { fn path_segments(url: &Url) -> Vec { url.path_segments() - .map(|segments| segments.filter(|segment| !segment.is_empty()).map(str::to_owned).collect()) - .unwrap_or_default() + .map_or_default(|segments| segments.filter(|segment| !segment.is_empty()).map(str::to_owned).collect()) } fn set_path_segments(url: &mut Url, segments: &[String]) { diff --git a/src/util.rs b/src/util.rs index 409867b3..77b97942 100644 --- a/src/util.rs +++ b/src/util.rs @@ -151,16 +151,13 @@ pub struct Cors(); impl Cors { fn get_header(headers: &HeaderMap<'_>, name: &str) -> String { - match headers.get_one(name) { - Some(h) => h.to_owned(), - _ => String::new(), - } + headers.get_one(name).map_or_default(ToOwned::to_owned) } // Check a request's `Origin` header against the list of allowed origins. // If a match exists, return it. Otherwise, return None. fn get_allowed_origin(headers: &HeaderMap<'_>) -> Option { - let origin = Cors::get_header(headers, "Origin"); + let origin = Self::get_header(headers, "Origin"); let safari_extension_origin = "file://"; let desktop_custom_file_origin = "bw-desktop-file://bundle"; @@ -188,14 +185,14 @@ impl Fairing for Cors { async fn on_response<'r>(&self, request: &'r Request<'_>, response: &mut Response<'r>) { let req_headers = request.headers(); - if let Some(origin) = Cors::get_allowed_origin(req_headers) { + if let Some(origin) = Self::get_allowed_origin(req_headers) { response.set_header(Header::new("Access-Control-Allow-Origin", origin)); } // Preflight request if request.method() == Method::Options { - let req_allow_headers = Cors::get_header(req_headers, "Access-Control-Request-Headers"); - let req_allow_method = Cors::get_header(req_headers, "Access-Control-Request-Method"); + let req_allow_headers = Self::get_header(req_headers, "Access-Control-Request-Headers"); + let req_allow_method = Self::get_header(req_headers, "Access-Control-Request-Method"); response.set_header(Header::new("Access-Control-Allow-Methods", req_allow_method)); response.set_header(Header::new("Access-Control-Allow-Headers", req_allow_headers)); @@ -214,7 +211,7 @@ pub struct Cached { } impl Cached { - pub fn long(response: R, is_immutable: bool) -> Cached { + pub fn long(response: R, is_immutable: bool) -> Self { Self { response, is_immutable, @@ -222,7 +219,7 @@ impl Cached { } } - pub fn short(response: R, is_immutable: bool) -> Cached { + pub fn short(response: R, is_immutable: bool) -> Self { Self { response, is_immutable, @@ -230,7 +227,7 @@ impl Cached { } } - pub fn ttl(response: R, ttl: u32, is_immutable: bool) -> Cached { + pub fn ttl(response: R, ttl: u32, is_immutable: bool) -> Self { Self { response, is_immutable, @@ -447,19 +444,19 @@ pub fn get_uuid() -> String { #[inline] pub fn upcase_first(s: &str) -> String { let mut c = s.chars(); - match c.next() { - None => String::new(), - Some(f) => f.to_uppercase().collect::() + c.as_str(), - } + c.next().map_or_default(|f| f.to_uppercase().collect::() + c.as_str()) } #[inline] -pub fn lcase_first(s: &str) -> String { - let mut c = s.chars(); - match c.next() { - None => String::new(), - Some(f) => f.to_lowercase().collect::() + c.as_str(), +pub fn lcase_first(mut s: String) -> String { + // get_mut(0..1) is None if empty or if the first char is multi-byte + if let Some(first) = s.get_mut(0..1) { + first.make_ascii_lowercase(); + } else if let Some(c) = s.chars().next() { + let lc: String = c.to_lowercase().collect(); + s.replace_range(..c.len_utf8(), &lc); } + s } pub fn try_parse_string(string: Option) -> Option @@ -467,11 +464,7 @@ where S: AsRef, T: FromStr, { - if let Some(Ok(value)) = string.map(|s| s.as_ref().parse::()) { - Some(value) - } else { - None - } + string.and_then(|s| s.as_ref().parse::().ok()) } // @@ -513,15 +506,15 @@ pub fn get_env_bool(key: &'static str) -> Option { const TRUE_VALUES: &[&str] = &["true", "t", "yes", "y", "1"]; const FALSE_VALUES: &[&str] = &["false", "f", "no", "n", "0"]; - match get_env_str_value(key) { - Some(val) if TRUE_VALUES.contains(&val.to_lowercase().as_ref()) => Some(true), - Some(val) if FALSE_VALUES.contains(&val.to_lowercase().as_ref()) => Some(false), - Some(_) => { - println!("[ERROR] `{key}` contains an invalid boolean value and is ignored, the default is used instead."); - INVALID_ENV_VARS.lock().unwrap().push(key); - None - } - _ => None, + let val = get_env_str_value(key)?; + if TRUE_VALUES.iter().any(|v| val.eq_ignore_ascii_case(v)) { + Some(true) + } else if FALSE_VALUES.iter().any(|v| val.eq_ignore_ascii_case(v)) { + Some(false) + } else { + println!("[ERROR] `{key}` contains an invalid boolean value and is ignored, the default is used instead."); + INVALID_ENV_VARS.lock().unwrap().push(key); + None } } @@ -715,10 +708,12 @@ impl<'de> Visitor<'de> for LowerCaseVisitor { // Inner function to handle a special case for the 'ssn' key. // This key is part of the Identity Cipher (Social Security Number) -fn process_json_key(key: &str) -> String { - match key.to_lowercase().as_ref() { - "ssn" => "ssn".into(), - _ => lcase_first(key), +fn process_json_key(mut key: String) -> String { + if key.eq_ignore_ascii_case("ssn") { + key.make_ascii_lowercase(); + key + } else { + lcase_first(key) } } @@ -747,8 +742,8 @@ pub enum NumberOrString { impl NumberOrString { pub fn into_string(self) -> String { match self { - NumberOrString::Number(n) => n.to_string(), - NumberOrString::String(s) => s, + Self::Number(n) => n.to_string(), + Self::String(s) => s, } } @@ -756,16 +751,14 @@ impl NumberOrString { pub fn into_i32(&self) -> Result { use std::num::ParseIntError as PIE; match self { - NumberOrString::Number(n) => { - if let Some(n) = n.to_i32() { + Self::Number(n) => { + if let Ok(n) = i32::try_from(*n) { Ok(n) } else { err!("Number does not fit in i32") } } - NumberOrString::String(s) => { - s.parse().map_err(|e: PIE| crate::Error::new("Can't convert to number", e.to_string())) - } + Self::String(s) => s.parse().map_err(|e: PIE| crate::Error::new("Can't convert to number", e.to_string())), } } @@ -773,10 +766,8 @@ impl NumberOrString { pub fn into_i64(&self) -> Result { use std::num::ParseIntError as PIE; match self { - NumberOrString::Number(n) => Ok(*n), - NumberOrString::String(s) => { - s.parse().map_err(|e: PIE| crate::Error::new("Can't convert to number", e.to_string())) - } + Self::Number(n) => Ok(*n), + Self::String(s) => s.parse().map_err(|e: PIE| crate::Error::new("Can't convert to number", e.to_string())), } } } @@ -833,50 +824,25 @@ where pub fn convert_json_key_lcase_first(src_json: Value) -> Value { match src_json { - Value::Array(elm) => { - let mut new_array: Vec = Vec::with_capacity(elm.len()); - - for obj in elm { - new_array.push(convert_json_key_lcase_first(obj)); + Value::Array(mut elm) => { + for obj in &mut elm { + *obj = convert_json_key_lcase_first(obj.take()); } - Value::Array(new_array) + Value::Array(elm) } Value::Object(obj) => { let mut json_map = JsonMap::new(); for (key, value) in obj { - match (key, value) { - (key, Value::Object(elm)) => { - let inner_value = convert_json_key_lcase_first(Value::Object(elm)); - json_map.insert(process_json_key(&key), inner_value); - } - - (key, Value::Array(elm)) => { - let mut inner_array: Vec = Vec::with_capacity(elm.len()); - - for inner_obj in elm { - inner_array.push(convert_json_key_lcase_first(inner_obj)); - } - - json_map.insert(process_json_key(&key), Value::Array(inner_array)); - } - - (key, value) => { - json_map.insert(process_json_key(&key), value); - } - } + json_map.insert(process_json_key(key), convert_json_key_lcase_first(value)); } - Value::Object(json_map) } - value => value, } } pub enum FeatureFlagFilter { - #[allow(dead_code)] - Unfiltered, ValidOnly, InvalidOnly, } @@ -891,7 +857,6 @@ pub fn parse_experimental_client_feature_flags( .map(str::trim) .filter(|flag| !flag.is_empty()) .filter(|flag| match filter_mode { - FeatureFlagFilter::Unfiltered => true, FeatureFlagFilter::ValidOnly => SUPPORTED_FEATURE_FLAGS.contains(flag), FeatureFlagFilter::InvalidOnly => !SUPPORTED_FEATURE_FLAGS.contains(flag), }) @@ -911,9 +876,9 @@ pub fn is_client_feature_flag_enabled(flag: &str) -> bool { // #[expect(clippy::nonminimal_bool, reason = "Mostly copy/paste from std, keep as-is")] #[expect(clippy::decimal_bitwise_operands, reason = "Mostly copy/paste from std, keep as-is")] #[cfg(any(not(feature = "unstable"), test))] -pub fn is_global_hardcoded(ip: std::net::IpAddr) -> bool { +pub fn is_global_hardcoded(ip: core::net::IpAddr) -> bool { match ip { - std::net::IpAddr::V4(ip) => { + core::net::IpAddr::V4(ip) => { !(ip.octets()[0] == 0 // "This network" || ip.is_private() || (ip.octets()[0] == 100 && (ip.octets()[1] & 0b1100_0000 == 0b0100_0000)) // ip.is_shared() @@ -925,12 +890,14 @@ pub fn is_global_hardcoded(ip: std::net::IpAddr) -> bool { ip.octets()[0] == 192 && ip.octets()[1] == 0 && ip.octets()[2] == 0 && ip.octets()[3] != 9 && ip.octets()[3] != 10 ) + // 6a44-relay anycast address (`192.88.99.2/32`) + || matches!(ip.octets(), [192, 88, 99, 2]) || ip.is_documentation() || (ip.octets()[0] == 198 && (ip.octets()[1] & 0xfe) == 18) // ip.is_benchmarking() || (ip.octets()[0] & 240 == 240 && !ip.is_broadcast()) // ip.is_reserved() || ip.is_broadcast()) } - std::net::IpAddr::V6(ip) => { + core::net::IpAddr::V6(ip) => { !(ip.is_unspecified() || ip.is_loopback() // IPv4-mapped Address (`::ffff:0:0/96`) @@ -939,6 +906,8 @@ pub fn is_global_hardcoded(ip: std::net::IpAddr) -> bool { || matches!(ip.segments(), [0x64, 0xff9b, 1, _, _, _, _, _]) // Discard-Only Address Block (`100::/64`) || matches!(ip.segments(), [0x100, 0, 0, 0, _, _, _, _]) + // Dummy IPv6 Prefix (100:0:0:1::/64) + || matches!(ip.segments(), [0x100, 0, 0, 1, _, _, _, _]) // IETF Protocol Assignments (`2001::/23`) || (matches!(ip.segments(), [0x2001, b, _, _, _, _, _, _] if b < 0x200) && !( @@ -946,6 +915,8 @@ pub fn is_global_hardcoded(ip: std::net::IpAddr) -> bool { u128::from_be_bytes(ip.octets()) == 0x2001_0001_0000_0000_0000_0000_0000_0001 // Traversal Using Relays around NAT Anycast (`2001:1::2`) || u128::from_be_bytes(ip.octets()) == 0x2001_0001_0000_0000_0000_0000_0000_0002 + // DNS-SD Service Registration Protocol Anycast (`2001:1::3`) + || u128::from_be_bytes(ip.octets()) == 0x2001_0001_0000_0000_0000_0000_0000_0003 // AMT (`2001:3::/32`) || matches!(ip.segments(), [0x2001, 3, _, _, _, _, _, _]) // AS112-v6 (`2001:4:112::/48`) @@ -1027,11 +998,11 @@ mod tests { #[test] #[ignore = "exhaustive IPv4 check is too slow for the regular test suite"] fn test_ipv4_global() { - for a in 0..u8::MAX { + for a in 0..=u8::MAX { println!("Iter: {a}/255"); - for b in 0..u8::MAX { - for c in 0..u8::MAX { - for d in 0..u8::MAX { + for b in 0..=u8::MAX { + for c in 0..=u8::MAX { + for d in 0..=u8::MAX { let ip = IpAddr::V4(std::net::Ipv4Addr::new(a, b, c, d)); assert_eq!(ip.is_global(), is_global_hardcoded(ip), "IP mismatch: {ip}"); }