vw_small

Hardened fork of Vaultwarden (https://github.com/dani-garcia/vaultwarden) with fewer features.
git clone https://git.philomathiclife.com/repos/vw_small
Log | Files | Refs | README

commit 9cca64003aa7fd8e3532d20c18bba6fd9de11eb3
parent 0de52c6c99737cb1ee0c33c138ccedd7ed955fd5
Author: Daniel GarcĂ­a <dani-garcia@users.noreply.github.com>
Date:   Sun,  3 May 2020 17:24:51 +0200

Remove unused dependency and simple feature, update dependencies and fix some clippy lints

Diffstat:
MCargo.lock | 367+++++++++++++++++++++++++++++++++++++------------------------------------------
MCargo.toml | 17+++++++----------
Msrc/api/admin.rs | 3+--
Msrc/api/core/folders.rs | 1-
Msrc/api/core/mod.rs | 2+-
Msrc/api/core/two_factor/duo.rs | 1-
Msrc/api/core/two_factor/email.rs | 1-
Msrc/api/core/two_factor/mod.rs | 11+++++------
Msrc/api/core/two_factor/u2f.rs | 1-
Msrc/api/core/two_factor/yubikey.rs | 1-
Msrc/api/icons.rs | 6+++---
Msrc/api/identity.rs | 3+--
Msrc/api/mod.rs | 2+-
Msrc/api/notifications.rs | 9++++++---
Msrc/config.rs | 2+-
Msrc/db/models/attachment.rs | 3+--
Msrc/db/models/cipher.rs | 1-
Msrc/db/models/collection.rs | 1-
Msrc/db/models/device.rs | 1-
Msrc/db/models/folder.rs | 1-
Msrc/db/models/org_policy.rs | 3+--
Msrc/db/models/organization.rs | 3+--
Msrc/db/models/two_factor.rs | 3+--
Msrc/db/models/user.rs | 3+--
Msrc/error.rs | 7+++----
Msrc/mail.rs | 26+++++++++++++-------------
Msrc/main.rs | 10++--------
Msrc/util.rs | 43++++++++-----------------------------------
28 files changed, 229 insertions(+), 303 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -70,9 +70,9 @@ dependencies = [ [[package]] name = "backtrace-sys" -version = "0.1.35" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7de8aba10a69c8e8d7622c5710229485ec32e9d55fdad160ea559c086fdcd118" +checksum = "18fbebbe1c9d1f383a9cc7e8ccdb471b91c8d024ee9c2ca5b5346121fe8b4399" dependencies = [ "cc", "libc", @@ -130,7 +130,6 @@ dependencies = [ "chrono", "data-encoding", "data-url", - "derive_more", "diesel", "diesel_migrations", "dotenv", @@ -162,7 +161,7 @@ dependencies = [ "soup", "structopt", "syslog", - "time 0.2.9", + "time 0.2.14", "u2f", "uuid", "ws", @@ -248,9 +247,9 @@ checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" [[package]] name = "cc" -version = "1.0.50" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" +checksum = "c3d87b23d6a92cd03af510a5ade527033f6aa6fa92161e2d5863a907d4c5e31d" [[package]] name = "cfg-if" @@ -276,7 +275,7 @@ checksum = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2" dependencies = [ "num-integer", "num-traits", - "time 0.1.42", + "time 0.1.43", ] [[package]] @@ -316,7 +315,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c60ef6d0bbf56ad2674249b6bb74f2c6aeb98b98dd57b5d3e37cace33011d69" dependencies = [ "percent-encoding 2.1.0", - "time 0.2.9", + "time 0.2.14", ] [[package]] @@ -370,17 +369,6 @@ dependencies = [ ] [[package]] -name = "derive_more" -version = "0.99.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2323f3f47db9a0e77ce7a300605d8d2098597fc451ed1a97bb1f6411bb550a7" -dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", -] - -[[package]] name = "devise" version = "0.3.0" source = "git+https://github.com/SergioBenitez/Devise.git?rev=e58b3ac9a#e58b3ac9afc3b6ff10a8aaf02a3e768a8f530089" @@ -395,7 +383,7 @@ version = "0.3.0" source = "git+https://github.com/SergioBenitez/Devise.git?rev=e58b3ac9a#e58b3ac9afc3b6ff10a8aaf02a3e768a8f530089" dependencies = [ "devise_core", - "quote 1.0.3", + "quote 1.0.4", ] [[package]] @@ -404,9 +392,9 @@ version = "0.3.0" source = "git+https://github.com/SergioBenitez/Devise.git?rev=e58b3ac9a#e58b3ac9afc3b6ff10a8aaf02a3e768a8f530089" dependencies = [ "bitflags", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2 1.0.12", + "quote 1.0.4", + "syn 1.0.18", ] [[package]] @@ -433,9 +421,9 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45f5098f628d02a7a0f68ddba586fb61e80edec3bdc1be3b921f4ceec60858d3" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2 1.0.12", + "quote 1.0.4", + "syn 1.0.18", ] [[package]] @@ -505,7 +493,7 @@ dependencies = [ "encoding", "lazy_static", "rand 0.4.6", - "time 0.1.42", + "time 0.1.43", "version_check 0.1.5", ] @@ -755,9 +743,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a5081aa3de1f7542a794a397cde100ed903b0630152d0973479018fd85423a7" dependencies = [ "proc-macro-hack", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2 1.0.12", + "quote 1.0.4", + "syn 1.0.18", ] [[package]] @@ -872,9 +860,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.1.10" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e" +checksum = "61565ff7aaace3525556587bd2dc31d4a07071957be715e63ce7b1eccf51a8f4" dependencies = [ "libc", ] @@ -964,7 +952,7 @@ dependencies = [ "log 0.3.9", "mime 0.2.6", "num_cpus", - "time 0.1.42", + "time 0.1.43", "traitobject", "typeable", "unicase 1.4.2", @@ -973,9 +961,9 @@ dependencies = [ [[package]] name = "hyper" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6081100e960d9d74734659ffc9cc91daf1c0fc7aceb8eaa94ee1a3f5046f2e" +checksum = "96816e1d921eca64d208a85aab4f7798455a8e34229ee5a88c935bdee1b78b14" dependencies = [ "bytes 0.5.4", "futures-channel", @@ -989,7 +977,7 @@ dependencies = [ "log 0.4.8", "net2", "pin-project", - "time 0.1.42", + "time 0.1.43", "tokio", "tower-service", "want", @@ -1014,7 +1002,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3adcd308402b9553630734e9c36b77a7e48b3821251ca2493e8cd596763aafaa" dependencies = [ "bytes 0.5.4", - "hyper 0.13.4", + "hyper 0.13.5", "native-tls", "tokio", "tokio-tls", @@ -1088,9 +1076,9 @@ checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" [[package]] name = "js-sys" -version = "0.3.37" +version = "0.3.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a27d435371a2fa5b6d2b028a74bbdb1234f308da363226a2854ca3ff8ba7055" +checksum = "fa5a448de267e7358beaf4a5d849518fe9a0c13fce7afd44b06e68550e5562a7" dependencies = [ "wasm-bindgen", ] @@ -1153,7 +1141,7 @@ dependencies = [ "nom", "serde", "serde_json", - "time 0.2.9", + "time 0.2.14", "uuid", ] @@ -1172,9 +1160,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.68" +version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0" +checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005" [[package]] name = "libsqlite3-sys" @@ -1189,9 +1177,9 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b" +checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" dependencies = [ "scopeguard", ] @@ -1282,9 +1270,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9753f12909fd8d923f75ae5c3258cae1ed3c8ec052e1b38c93c21a6d157f789c" dependencies = [ "migrations_internals", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2 1.0.12", + "quote 1.0.4", + "syn 1.0.18", ] [[package]] @@ -1326,9 +1314,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.6.21" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" +checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" dependencies = [ "cfg-if", "fuchsia-zircon", @@ -1415,9 +1403,9 @@ dependencies = [ [[package]] name = "net2" -version = "0.2.33" +version = "0.2.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" +checksum = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7" dependencies = [ "cfg-if", "libc", @@ -1482,9 +1470,9 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c8b15b261814f992e33760b1fca9fe8b693d8a65299f20c9901688636cfb746" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2 1.0.12", + "quote 1.0.4", + "syn 1.0.18", ] [[package]] @@ -1508,9 +1496,9 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" dependencies = [ "hermit-abi", "libc", @@ -1595,12 +1583,12 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" +checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" dependencies = [ "lock_api", - "parking_lot_core 0.7.0", + "parking_lot_core 0.7.2", ] [[package]] @@ -1617,15 +1605,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1" +checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" dependencies = [ "cfg-if", "cloudabi", "libc", "redox_syscall", - "smallvec 1.3.0", + "smallvec 1.4.0", "winapi 0.3.8", ] @@ -1701,9 +1689,9 @@ checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" dependencies = [ "pest", "pest_meta", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2 1.0.12", + "quote 1.0.4", + "syn 1.0.18", ] [[package]] @@ -1758,22 +1746,22 @@ dependencies = [ [[package]] name = "pin-project" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7804a463a8d9572f13453c516a5faea534a2403d7ced2f0c7e100eeff072772c" +checksum = "6f6a7f5eee6292c559c793430c55c00aea9d3b3d1905e855806ca4d7253426a2" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "385322a45f2ecf3410c68d2a549a4a2685e8051d0f278e39743ff4e451cb9b3f" +checksum = "8988430ce790d8682672117bc06dda364c0be32d3abd738234f19f3240bad99a" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2 1.0.12", + "quote 1.0.4", + "syn 1.0.18", ] [[package]] @@ -1784,9 +1772,9 @@ checksum = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae" [[package]] name = "pin-utils" -version = "0.1.0-alpha.4" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" @@ -1822,9 +1810,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98e9e4b82e0ef281812565ea4751049f1bdcdfccda7d3f459f2e138a40c08678" dependencies = [ "proc-macro-error-attr", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2 1.0.12", + "quote 1.0.4", + "syn 1.0.18", "version_check 0.9.1", ] @@ -1834,9 +1822,9 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f5444ead4e9935abd7f27dc51f7e852a0569ac888096d5ec2499470794e2e53" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2 1.0.12", + "quote 1.0.4", + "syn 1.0.18", "syn-mid", "version_check 0.9.1", ] @@ -1864,9 +1852,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.10" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" +checksum = "8872cf6f48eee44265156c111456a700ab3483686b3f96df4cf5481c89157319" dependencies = [ "unicode-xid 0.2.0", ] @@ -1888,11 +1876,11 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" +checksum = "4c1f4b0efa5fc5e8ceb705136bfee52cfdb6a4e3509f770b478cd6ed434232a7" dependencies = [ - "proc-macro2 1.0.10", + "proc-macro2 1.0.12", ] [[package]] @@ -1908,7 +1896,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1497e40855348e4a8a40767d8e55174bce1e445a3ac9254ad44ad468ee0485af" dependencies = [ "log 0.4.8", - "parking_lot 0.10.0", + "parking_lot 0.10.2", "scheduled-thread-pool", ] @@ -2089,9 +2077,9 @@ checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" [[package]] name = "regex" -version = "1.3.6" +version = "1.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6946991529684867e47d86474e3a6d0c0ab9b82d5821e314b1ede31fa3a4b3" +checksum = "a6020f034922e3194c711b82a627453881bc4682166cabb07134a10c26ba7692" dependencies = [ "aho-corasick", "memchr", @@ -2127,7 +2115,7 @@ dependencies = [ "futures-util", "http", "http-body", - "hyper 0.13.4", + "hyper 0.13.5", "hyper-tls", "js-sys", "lazy_static", @@ -2140,7 +2128,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "time 0.1.42", + "time 0.1.43", "tokio", "tokio-tls", "url 2.1.1", @@ -2152,13 +2140,13 @@ dependencies = [ [[package]] name = "ring" -version = "0.16.12" +version = "0.16.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba5a8ec64ee89a76c98c549af81ff14813df09c3e6dc4766c3856da48597a0c" +checksum = "703516ae74571f24b465b4a1431e81e2ad51336cb0ded733a55a1aa3eccac196" dependencies = [ "cc", - "lazy_static", "libc", + "once_cell", "spin", "untrusted", "web-sys", @@ -2188,7 +2176,7 @@ dependencies = [ [[package]] name = "rocket" version = "0.5.0-dev" -source = "git+https://github.com/SergioBenitez/Rocket?rev=dfc9e9aab01d349da32c52db393e35b7fffea63c#dfc9e9aab01d349da32c52db393e35b7fffea63c" +source = "git+https://github.com/SergioBenitez/Rocket?rev=1010f6a2a88fac899dec0cd2f642156908038a53#1010f6a2a88fac899dec0cd2f642156908038a53" dependencies = [ "atty", "binascii", @@ -2199,7 +2187,7 @@ dependencies = [ "rocket_codegen", "rocket_http", "state", - "time 0.2.9", + "time 0.2.14", "toml", "version_check 0.9.1", "yansi 0.5.0", @@ -2208,12 +2196,12 @@ dependencies = [ [[package]] name = "rocket_codegen" version = "0.5.0-dev" -source = "git+https://github.com/SergioBenitez/Rocket?rev=dfc9e9aab01d349da32c52db393e35b7fffea63c#dfc9e9aab01d349da32c52db393e35b7fffea63c" +source = "git+https://github.com/SergioBenitez/Rocket?rev=1010f6a2a88fac899dec0cd2f642156908038a53#1010f6a2a88fac899dec0cd2f642156908038a53" dependencies = [ "devise", "glob", "indexmap", - "quote 1.0.3", + "quote 1.0.4", "rocket_http", "version_check 0.9.1", "yansi 0.5.0", @@ -2222,7 +2210,7 @@ dependencies = [ [[package]] name = "rocket_contrib" version = "0.5.0-dev" -source = "git+https://github.com/SergioBenitez/Rocket?rev=dfc9e9aab01d349da32c52db393e35b7fffea63c#dfc9e9aab01d349da32c52db393e35b7fffea63c" +source = "git+https://github.com/SergioBenitez/Rocket?rev=1010f6a2a88fac899dec0cd2f642156908038a53#1010f6a2a88fac899dec0cd2f642156908038a53" dependencies = [ "log 0.4.8", "notify", @@ -2234,7 +2222,7 @@ dependencies = [ [[package]] name = "rocket_http" version = "0.5.0-dev" -source = "git+https://github.com/SergioBenitez/Rocket?rev=dfc9e9aab01d349da32c52db393e35b7fffea63c#dfc9e9aab01d349da32c52db393e35b7fffea63c" +source = "git+https://github.com/SergioBenitez/Rocket?rev=1010f6a2a88fac899dec0cd2f642156908038a53#1010f6a2a88fac899dec0cd2f642156908038a53" dependencies = [ "cookie", "hyper 0.10.16", @@ -2243,9 +2231,9 @@ dependencies = [ "pear", "percent-encoding 1.0.1", "rustls", - "smallvec 1.3.0", + "smallvec 1.4.0", "state", - "time 0.2.9", + "time 0.2.14", "unicode-xid 0.2.0", ] @@ -2284,21 +2272,10 @@ dependencies = [ ] [[package]] -name = "rustversion" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3bba175698996010c4f6dce5e7f173b6eb781fce25d2cfc45e27091ce0b79f6" -dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", -] - -[[package]] name = "ryu" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76" +checksum = "ed3d612bc64430efeb3f7ee6ef26d590dce0c43249217bddc62112540c7941e1" [[package]] name = "safemem" @@ -2331,7 +2308,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0988d7fdf88d5e5fcf5923a0f1e8ab345f3e98ab4bc6bc45a2d5ff7f7458fbf6" dependencies = [ - "parking_lot 0.10.0", + "parking_lot 0.10.2", ] [[package]] @@ -2352,9 +2329,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572dfa3a0785509e7a44b5b4bebcf94d41ba34e9ed9eb9df722545c3b3c4144a" +checksum = "3f331b9025654145cd425b9ded0caf8f5ae0df80d418b326e2dc1c3dc5eb0620" dependencies = [ "bitflags", "core-foundation", @@ -2365,9 +2342,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ddb15a5fec93b7021b8a9e96009c5d8d51c15673569f7c0f6b7204e5b7b404f" +checksum = "17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405" dependencies = [ "core-foundation-sys", "libc", @@ -2403,16 +2380,16 @@ version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2 1.0.12", + "quote 1.0.4", + "syn 1.0.18", ] [[package]] name = "serde_json" -version = "1.0.51" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da07b57ee2623368351e9a0488bb0b261322a15a6e0ae53e243cbdc0f4208da9" +checksum = "a7894c8ed05b7a3a279aeb79025fdec1d3158080b75b98a08faf2806bb799edd" dependencies = [ "itoa", "ryu", @@ -2509,9 +2486,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05720e22615919e4734f6a99ceae50d00226c3c5aca406e102ebc33298214e0a" +checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" [[package]] name = "soup" @@ -2537,9 +2514,9 @@ checksum = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" [[package]] name = "standback" -version = "0.2.2" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee531c64ad0f80d289504bd32fb047f42a9e957cda584276ab96eb587e9abac3" +checksum = "47e4b8c631c998468961a9ea159f064c5c8499b95b5e4a34b77849d45949d540" [[package]] name = "state" @@ -2573,11 +2550,11 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2 1.0.12", + "quote 1.0.4", "serde", "serde_derive", - "syn 1.0.17", + "syn 1.0.18", ] [[package]] @@ -2587,13 +2564,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" dependencies = [ "base-x", - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2 1.0.12", + "quote 1.0.4", "serde", "serde_derive", "serde_json", "sha1", - "syn 1.0.17", + "syn 1.0.18", ] [[package]] @@ -2625,8 +2602,8 @@ checksum = "f0f45ed1b65bf9a4bf2f7b7dc59212d1926e9eaf00fa998988e420fd124467c6" dependencies = [ "phf_generator", "phf_shared", - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2 1.0.12", + "quote 1.0.4", "string_cache_shared", ] @@ -2644,9 +2621,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "structopt" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff6da2e8d107dfd7b74df5ef4d205c6aebee0706c647f6bc6a2d5789905c00fb" +checksum = "863246aaf5ddd0d6928dfeb1a9ca65f505599e4e1b399935ef7e75107516b4ef" dependencies = [ "clap", "lazy_static", @@ -2655,15 +2632,15 @@ dependencies = [ [[package]] name = "structopt-derive" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a489c87c08fbaf12e386665109dd13470dcc9c4583ea3e10dd2b4523e5ebd9ac" +checksum = "d239ca4b13aee7a2142e6795cbd69e457665ff8037aed33b3effdc430d2f927a" dependencies = [ "heck", "proc-macro-error", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2 1.0.12", + "quote 1.0.4", + "syn 1.0.18", ] [[package]] @@ -2691,12 +2668,12 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03" +checksum = "410a7488c0a728c7ceb4ad59b9567eb4053d02e8cc7f5c0e0eeeb39518369213" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2 1.0.12", + "quote 1.0.4", "unicode-xid 0.2.0", ] @@ -2706,9 +2683,9 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2 1.0.12", + "quote 1.0.4", + "syn 1.0.18", ] [[package]] @@ -2720,7 +2697,7 @@ dependencies = [ "error-chain", "libc", "log 0.4.8", - "time 0.1.42", + "time 0.1.43", ] [[package]] @@ -2768,36 +2745,35 @@ dependencies = [ [[package]] name = "threadpool" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" +checksum = "e8dae184447c15d5a6916d973c642aec485105a13cd238192a6927ae3e077d66" dependencies = [ "num_cpus", ] [[package]] name = "time" -version = "0.1.42" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" +checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" dependencies = [ "libc", - "redox_syscall", "winapi 0.3.8", ] [[package]] name = "time" -version = "0.2.9" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6329a7835505d46f5f3a9a2c237f8d6bf5ca6f0015decb3698ba57fcdbb609ba" +checksum = "c19b581e837b3f1a6a211e1d30f11a2da711cc8f6d38c16972eecc0398114446" dependencies = [ "cfg-if", "libc", - "rustversion", "standback", "stdweb", "time-macros", + "version_check 0.9.1", "winapi 0.3.8", ] @@ -2813,21 +2789,22 @@ dependencies = [ [[package]] name = "time-macros-impl" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e987cfe0537f575b5fc99909de6185f6c19c3ad8889e2275e686a873d0869ba1" +checksum = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa" dependencies = [ "proc-macro-hack", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2 1.0.12", + "quote 1.0.4", + "standback", + "syn 1.0.18", ] [[package]] name = "tokio" -version = "0.2.16" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee5a0dd887e37d37390c13ff8ac830f992307fe30a1fff0ab8427af67211ba28" +checksum = "05c1d570eb1a36f0345a5ce9c6c6e665b70b73d11236912c0b477616aeec47b1" dependencies = [ "bytes 0.5.4", "fnv", @@ -2909,9 +2886,9 @@ checksum = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" [[package]] name = "typenum" -version = "1.11.2" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" +checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" [[package]] name = "u2f" @@ -2927,7 +2904,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "time 0.1.42", + "time 0.1.43", ] [[package]] @@ -2969,7 +2946,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4" dependencies = [ - "smallvec 1.3.0", + "smallvec 1.4.0", ] [[package]] @@ -2998,9 +2975,9 @@ checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" [[package]] name = "untrusted" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60369ef7a31de49bcb3f6ca728d4ba7300d9a1658f94c727d4cab8c8d9f4aece" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" @@ -3092,9 +3069,9 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasm-bindgen" -version = "0.2.60" +version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc57ce05287f8376e998cbddfb4c8cb43b84a7ec55cf4551d7c00eef317a47f" +checksum = "e3c7d40d09cdbf0f4895ae58cf57d92e1e57a9dd8ed2e8390514b54a47cc5551" dependencies = [ "cfg-if", "serde", @@ -3104,24 +3081,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.60" +version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d967d37bf6c16cca2973ca3af071d0a2523392e4a594548155d89a678f4237cd" +checksum = "c3972e137ebf830900db522d6c8fd74d1900dcfc733462e9a12e942b00b4ac94" dependencies = [ "bumpalo", "lazy_static", "log 0.4.8", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2 1.0.12", + "quote 1.0.4", + "syn 1.0.18", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.10" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7add542ea1ac7fdaa9dc25e031a6af33b7d63376292bd24140c637d00d1c312a" +checksum = "8a369c5e1dfb7569e14d62af4da642a3cbc2f9a3652fe586e26ac22222aa4b04" dependencies = [ "cfg-if", "js-sys", @@ -3131,38 +3108,38 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.60" +version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bd151b63e1ea881bb742cd20e1d6127cef28399558f3b5d415289bc41eee3a4" +checksum = "2cd85aa2c579e8892442954685f0d801f9129de24fa2136b2c6a539c76b65776" dependencies = [ - "quote 1.0.3", + "quote 1.0.4", "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.60" +version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68a5b36eef1be7868f668632863292e37739656a80fc4b9acec7b0bd35a4931" +checksum = "8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.17", + "proc-macro2 1.0.12", + "quote 1.0.4", + "syn 1.0.18", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.60" +version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daf76fe7d25ac79748a37538b7daeed1c7a6867c92d3245c12c6222e4a20d639" +checksum = "a91c2916119c17a8e316507afaaa2dd94b47646048014bbdf6bef098c1bb58ad" [[package]] name = "web-sys" -version = "0.3.37" +version = "0.3.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d6f51648d8c56c366144378a33290049eafdd784071077f6fe37dae64c1c4cb" +checksum = "8bc359e5dd3b46cb9687a051d50a2fdd228e4ba7cf6fcf861a5365c3d671a642" dependencies = [ "js-sys", "wasm-bindgen", @@ -3217,9 +3194,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa515c5163a99cc82bab70fd3bfdd36d827be85de63737b40fcef2ce084a436e" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ "winapi 0.3.8", ] diff --git a/Cargo.toml b/Cargo.toml @@ -43,7 +43,7 @@ chashmap = "2.2.2" # A generic serialization/deserialization framework serde = "1.0.106" serde_derive = "1.0.106" -serde_json = "1.0.51" +serde_json = "1.0.52" # Logging log = "0.4.8" @@ -57,14 +57,14 @@ diesel_migrations = "1.4.0" libsqlite3-sys = { version = "0.17.3", features = ["bundled"], optional = true } # Crypto library -ring = "0.16.12" +ring = "0.16.13" # UUID generation uuid = { version = "0.8.1", features = ["v4"] } # Date and time librar for Rust chrono = "0.4.11" -time = "0.2.9" +time = "0.2.14" # TOTP library oath = "0.10.2" @@ -87,9 +87,6 @@ dotenv = { version = "0.15.0", default-features = false } # Lazy initialization once_cell = "1.3.1" -# More derives -derive_more = "0.99.5" - # Numerical libraries num-traits = "0.2.11" num-derive = "0.3.0" @@ -104,7 +101,7 @@ handlebars = { version = "3.0.1", features = ["dir_source"] } # For favicon extraction from main website soup = "0.5.0" -regex = "1.3.6" +regex = "1.3.7" data-url = "0.1.0" # Used by U2F, JWT and Postgres @@ -116,15 +113,15 @@ percent-encoding = "2.1.0" idna = "0.2.0" # CLI argument parsing -structopt = "0.3.13" +structopt = "0.3.14" # Logging panics to logfile instead stderr only backtrace = "0.3.46" [patch.crates-io] # Use newest ring -rocket = { git = 'https://github.com/SergioBenitez/Rocket', rev = 'dfc9e9aab01d349da32c52db393e35b7fffea63c' } -rocket_contrib = { git = 'https://github.com/SergioBenitez/Rocket', rev = 'dfc9e9aab01d349da32c52db393e35b7fffea63c' } +rocket = { git = 'https://github.com/SergioBenitez/Rocket', rev = '1010f6a2a88fac899dec0cd2f642156908038a53' } +rocket_contrib = { git = 'https://github.com/SergioBenitez/Rocket', rev = '1010f6a2a88fac899dec0cd2f642156908038a53' } # Use git version for timeout fix #706 lettre = { git = 'https://github.com/lettre/lettre', rev = '245c600c82ee18b766e8729f005ff453a55dce34' } diff --git a/src/api/admin.rs b/src/api/admin.rs @@ -174,10 +174,9 @@ fn invite_user(data: Json<InviteData>, _token: AdminToken, conn: DbConn) -> Empt #[post("/test/smtp", data = "<data>")] fn test_smtp(data: Json<InviteData>, _token: AdminToken) -> EmptyResult { let data: InviteData = data.into_inner(); - let email = data.email.clone(); if CONFIG.mail_enabled() { - mail::send_test(&email) + mail::send_test(&data.email) } else { err!("Mail is not enabled") } diff --git a/src/api/core/folders.rs b/src/api/core/folders.rs @@ -50,7 +50,6 @@ fn get_folder(uuid: String, headers: Headers, conn: DbConn) -> JsonResult { #[derive(Deserialize)] #[allow(non_snake_case)] - pub struct FolderData { pub Name: String, } diff --git a/src/api/core/mod.rs b/src/api/core/mod.rs @@ -2,7 +2,7 @@ mod accounts; mod ciphers; mod folders; mod organizations; -pub(crate) mod two_factor; +pub mod two_factor; pub fn routes() -> Vec<Route> { let mut mod_routes = routes![ diff --git a/src/api/core/two_factor/duo.rs b/src/api/core/two_factor/duo.rs @@ -2,7 +2,6 @@ use chrono::Utc; use data_encoding::BASE64; use rocket::Route; use rocket_contrib::json::Json; -use serde_json; use crate::api::core::two_factor::_generate_recover_code; use crate::api::{ApiResult, EmptyResult, JsonResult, JsonUpcase, PasswordData}; diff --git a/src/api/core/two_factor/email.rs b/src/api/core/two_factor/email.rs @@ -1,6 +1,5 @@ use rocket::Route; use rocket_contrib::json::Json; -use serde_json; use crate::api::core::two_factor::_generate_recover_code; use crate::api::{EmptyResult, JsonResult, JsonUpcase, PasswordData}; diff --git a/src/api/core/two_factor/mod.rs b/src/api/core/two_factor/mod.rs @@ -1,7 +1,6 @@ use data_encoding::BASE32; use rocket::Route; use rocket_contrib::json::Json; -use serde_json; use serde_json::Value; use crate::api::{JsonResult, JsonUpcase, NumberOrString, PasswordData}; @@ -12,11 +11,11 @@ use crate::db::{ DbConn, }; -pub(crate) mod authenticator; -pub(crate) mod duo; -pub(crate) mod email; -pub(crate) mod u2f; -pub(crate) mod yubikey; +pub mod authenticator; +pub mod duo; +pub mod email; +pub mod u2f; +pub mod yubikey; pub fn routes() -> Vec<Route> { let mut routes = routes![ diff --git a/src/api/core/two_factor/u2f.rs b/src/api/core/two_factor/u2f.rs @@ -1,7 +1,6 @@ use once_cell::sync::Lazy; use rocket::Route; use rocket_contrib::json::Json; -use serde_json; use serde_json::Value; use u2f::messages::{RegisterResponse, SignResponse, U2fSignRequest}; use u2f::protocol::{Challenge, U2f}; diff --git a/src/api/core/two_factor/yubikey.rs b/src/api/core/two_factor/yubikey.rs @@ -1,6 +1,5 @@ use rocket::Route; use rocket_contrib::json::Json; -use serde_json; use serde_json::Value; use yubico::config::Config; use yubico::verify; diff --git a/src/api/icons.rs b/src/api/icons.rs @@ -182,7 +182,7 @@ struct Icon { } impl Icon { - fn new(priority: u8, href: String) -> Self { + const fn new(priority: u8, href: String) -> Self { Self { href, priority } } } @@ -213,7 +213,7 @@ fn get_icon_url(domain: &str) -> Result<(Vec<Icon>, String), Error> { let mut cookie_str = String::new(); let resp = get_page(&ssldomain).or_else(|_| get_page(&httpdomain)); - if let Ok(mut content) = resp { + if let Ok(content) = resp { // Extract the URL from the respose in case redirects occured (like @ gitlab.com) let url = content.url().clone(); @@ -235,7 +235,7 @@ fn get_icon_url(domain: &str) -> Result<(Vec<Icon>, String), Error> { // 512KB should be more than enough for the HTML, though as we only really need // the HTML header, it could potentially be reduced even further - let limited_reader = crate::util::LimitedReader::new(&mut content, 512 * 1024); + let limited_reader = content.take(512 * 1024); let soup = Soup::from_reader(limited_reader)?; // Search for and filter diff --git a/src/api/identity.rs b/src/api/identity.rs @@ -216,8 +216,7 @@ fn twofactor_auth( let selected_twofactor = twofactors .into_iter() - .filter(|tf| tf.atype == selected_id && tf.enabled) - .nth(0); + .find(|tf| tf.atype == selected_id && tf.enabled); use crate::api::core::two_factor as _tf; use crate::crypto::ct_eq; diff --git a/src/api/mod.rs b/src/api/mod.rs @@ -1,5 +1,5 @@ mod admin; -pub(crate) mod core; +pub mod core; mod icons; mod identity; mod notifications; diff --git a/src/api/notifications.rs b/src/api/notifications.rs @@ -159,11 +159,12 @@ impl Handler for WSHandler { let (_id, access_token) = match path.split('?').nth(1) { Some(params) => { - let mut params_iter = params.split('&').take(2); + let params_iter = params.split('&').take(2); let mut id = None; let mut access_token = None; - while let Some(val) = params_iter.next() { + + for val in params_iter { if val.starts_with(ID_KEY) { id = Some(&val[ID_KEY.len()..]); } else if val.starts_with(ACCESS_TOKEN_KEY) { @@ -260,7 +261,9 @@ impl Factory for WSFactory { // Remove handler if let Some(user_uuid) = &handler.user_uuid { if let Some(mut user_conn) = self.users.map.get_mut(user_uuid) { - user_conn.remove_item(&handler.out); + if let Some(pos) = user_conn.iter().position(|x| x == &handler.out) { + user_conn.remove(pos); + } } } } diff --git a/src/config.rs b/src/config.rs @@ -640,7 +640,7 @@ impl Config { pub fn is_admin_token_set(&self) -> bool { let token = self.admin_token(); - !token.is_none() && !token.unwrap().trim().is_empty() + token.is_some() && !token.unwrap().trim().is_empty() } pub fn render_template<T: serde::ser::Serialize>( diff --git a/src/db/models/attachment.rs b/src/db/models/attachment.rs @@ -18,7 +18,7 @@ pub struct Attachment { /// Local methods impl Attachment { - pub fn new(id: String, cipher_uuid: String, file_name: String, file_size: i32) -> Self { + pub const fn new(id: String, cipher_uuid: String, file_name: String, file_size: i32) -> Self { Self { id, cipher_uuid, @@ -52,7 +52,6 @@ impl Attachment { use crate::db::schema::{attachments, ciphers}; use crate::db::DbConn; -use diesel; use diesel::prelude::*; use crate::api::EmptyResult; diff --git a/src/db/models/cipher.rs b/src/db/models/cipher.rs @@ -66,7 +66,6 @@ impl Cipher { use crate::db::schema::*; use crate::db::DbConn; -use diesel; use diesel::prelude::*; use crate::api::EmptyResult; diff --git a/src/db/models/collection.rs b/src/db/models/collection.rs @@ -35,7 +35,6 @@ impl Collection { use crate::db::schema::*; use crate::db::DbConn; -use diesel; use diesel::prelude::*; use crate::api::EmptyResult; diff --git a/src/db/models/device.rs b/src/db/models/device.rs @@ -108,7 +108,6 @@ impl Device { use crate::db::schema::devices; use crate::db::DbConn; -use diesel; use diesel::prelude::*; use crate::api::EmptyResult; diff --git a/src/db/models/folder.rs b/src/db/models/folder.rs @@ -63,7 +63,6 @@ impl FolderCipher { use crate::db::schema::{folders, folders_ciphers}; use crate::db::DbConn; -use diesel; use diesel::prelude::*; use crate::api::EmptyResult; diff --git a/src/db/models/org_policy.rs b/src/db/models/org_policy.rs @@ -1,4 +1,3 @@ -use diesel; use diesel::prelude::*; use serde_json::Value; @@ -22,7 +21,7 @@ pub struct OrgPolicy { } #[allow(dead_code)] -#[derive(FromPrimitive)] +#[derive(num_derive::FromPrimitive)] pub enum OrgPolicyType { TwoFactorAuthentication = 0, MasterPassword = 1, diff --git a/src/db/models/organization.rs b/src/db/models/organization.rs @@ -34,7 +34,7 @@ pub enum UserOrgStatus { } #[derive(Copy, Clone, PartialEq, Eq)] -#[derive(FromPrimitive)] +#[derive(num_derive::FromPrimitive)] pub enum UserOrgType { Owner = 0, Admin = 1, @@ -198,7 +198,6 @@ impl UserOrganization { use crate::db::schema::{ciphers_collections, organizations, users_collections, users_organizations}; use crate::db::DbConn; -use diesel; use diesel::prelude::*; use crate::api::EmptyResult; diff --git a/src/db/models/two_factor.rs b/src/db/models/two_factor.rs @@ -1,4 +1,3 @@ -use diesel; use diesel::prelude::*; use serde_json::Value; @@ -23,7 +22,7 @@ pub struct TwoFactor { } #[allow(dead_code)] -#[derive(FromPrimitive)] +#[derive(num_derive::FromPrimitive)] pub enum TwoFactorType { Authenticator = 0, Email = 1, diff --git a/src/db/models/user.rs b/src/db/models/user.rs @@ -121,7 +121,6 @@ impl User { use super::{Cipher, Device, Folder, TwoFactor, UserOrgType, UserOrganization}; use crate::db::schema::{invitations, users}; use crate::db::DbConn; -use diesel; use diesel::prelude::*; use crate::api::EmptyResult; @@ -275,7 +274,7 @@ pub struct Invitation { } impl Invitation { - pub fn new(email: String) -> Self { + pub const fn new(email: String) -> Self { Self { email } } diff --git a/src/error.rs b/src/error.rs @@ -7,7 +7,6 @@ macro_rules! make_error { ( $( $name:ident ( $ty:ty ): $src_fn:expr, $usr_msg_fun:expr ),+ $(,)? ) => { const BAD_REQUEST: u16 = 400; - #[derive(Display)] pub enum ErrorKind { $($name( $ty )),+ } pub struct Error { message: String, error: ErrorKind, error_code: u16 } @@ -48,7 +47,7 @@ use u2f::u2ferror::U2fError as U2fErr; use yubico::yubicoerror::YubicoError as YubiErr; use lettre::smtp::error::Error as LettreErr; -#[derive(Display, Serialize)] +#[derive(Serialize)] pub struct Empty {} // Error struct @@ -118,7 +117,7 @@ impl Error { self } - pub fn with_code(mut self, code: u16) -> Self { + pub const fn with_code(mut self, code: u16) -> Self { self.error_code = code; self } @@ -146,7 +145,7 @@ impl<S> MapResult<S> for Option<S> { } } -fn _has_source<T>(e: T) -> Option<T> { +const fn _has_source<T>(e: T) -> Option<T> { Some(e) } fn _no_source<T, S>(_: T) -> Option<S> { diff --git a/src/mail.rs b/src/mail.rs @@ -46,7 +46,7 @@ fn mailer() -> SmtpTransport { let smtp_client = match CONFIG.smtp_auth_mechanism() { Some(mechanism) => { - let correct_mechanism = format!("\"{}\"", crate::util::upcase_first(&mechanism.trim_matches('"'))); + let correct_mechanism = format!("\"{}\"", crate::util::upcase_first(mechanism.trim_matches('"'))); match serde_json::from_str::<SmtpAuthMechanism>(&correct_mechanism) { Ok(auth_mechanism) => smtp_client.authentication_mechanism(auth_mechanism), @@ -95,7 +95,7 @@ pub fn send_password_hint(address: &str, hint: Option<String>) -> EmptyResult { let (subject, body_html, body_text) = get_text(template_name, json!({ "hint": hint, "url": CONFIG.domain() }))?; - send_email(&address, &subject, &body_html, &body_text) + send_email(address, &subject, &body_html, &body_text) } pub fn send_delete_account(address: &str, uuid: &str) -> EmptyResult { @@ -112,7 +112,7 @@ pub fn send_delete_account(address: &str, uuid: &str) -> EmptyResult { }), )?; - send_email(&address, &subject, &body_html, &body_text) + send_email(address, &subject, &body_html, &body_text) } pub fn send_verify_email(address: &str, uuid: &str) -> EmptyResult { @@ -129,7 +129,7 @@ pub fn send_verify_email(address: &str, uuid: &str) -> EmptyResult { }), )?; - send_email(&address, &subject, &body_html, &body_text) + send_email(address, &subject, &body_html, &body_text) } pub fn send_welcome(address: &str) -> EmptyResult { @@ -140,7 +140,7 @@ pub fn send_welcome(address: &str) -> EmptyResult { }), )?; - send_email(&address, &subject, &body_html, &body_text) + send_email(address, &subject, &body_html, &body_text) } pub fn send_welcome_must_verify(address: &str, uuid: &str) -> EmptyResult { @@ -156,7 +156,7 @@ pub fn send_welcome_must_verify(address: &str, uuid: &str) -> EmptyResult { }), )?; - send_email(&address, &subject, &body_html, &body_text) + send_email(address, &subject, &body_html, &body_text) } pub fn send_invite( @@ -188,7 +188,7 @@ pub fn send_invite( }), )?; - send_email(&address, &subject, &body_html, &body_text) + send_email(address, &subject, &body_html, &body_text) } pub fn send_invite_accepted(new_user_email: &str, address: &str, org_name: &str) -> EmptyResult { @@ -201,7 +201,7 @@ pub fn send_invite_accepted(new_user_email: &str, address: &str, org_name: &str) }), )?; - send_email(&address, &subject, &body_html, &body_text) + send_email(address, &subject, &body_html, &body_text) } pub fn send_invite_confirmed(address: &str, org_name: &str) -> EmptyResult { @@ -213,7 +213,7 @@ pub fn send_invite_confirmed(address: &str, org_name: &str) -> EmptyResult { }), )?; - send_email(&address, &subject, &body_html, &body_text) + send_email(address, &subject, &body_html, &body_text) } pub fn send_new_device_logged_in(address: &str, ip: &str, dt: &NaiveDateTime, device: &str) -> EmptyResult { @@ -232,7 +232,7 @@ pub fn send_new_device_logged_in(address: &str, ip: &str, dt: &NaiveDateTime, de }), )?; - send_email(&address, &subject, &body_html, &body_text) + send_email(address, &subject, &body_html, &body_text) } pub fn send_token(address: &str, token: &str) -> EmptyResult { @@ -244,7 +244,7 @@ pub fn send_token(address: &str, token: &str) -> EmptyResult { }), )?; - send_email(&address, &subject, &body_html, &body_text) + send_email(address, &subject, &body_html, &body_text) } pub fn send_change_email(address: &str, token: &str) -> EmptyResult { @@ -256,7 +256,7 @@ pub fn send_change_email(address: &str, token: &str) -> EmptyResult { }), )?; - send_email(&address, &subject, &body_html, &body_text) + send_email(address, &subject, &body_html, &body_text) } pub fn send_test(address: &str) -> EmptyResult { @@ -267,7 +267,7 @@ pub fn send_test(address: &str) -> EmptyResult { }), )?; - send_email(&address, &subject, &body_html, &body_text) + send_email(address, &subject, &body_html, &body_text) } fn send_email(address: &str, subject: &str, body_html: &str, body_text: &str) -> EmptyResult { diff --git a/src/main.rs b/src/main.rs @@ -1,7 +1,7 @@ -#![feature(proc_macro_hygiene, vec_remove_item, try_trait, ip)] +#![forbid(unsafe_code)] +#![feature(proc_macro_hygiene, try_trait, ip)] #![recursion_limit = "256"] -extern crate openssl; #[macro_use] extern crate rocket; #[macro_use] @@ -14,12 +14,6 @@ extern crate log; extern crate diesel; #[macro_use] extern crate diesel_migrations; -#[macro_use] -extern crate derive_more; -#[macro_use] -extern crate num_derive; - -extern crate backtrace; use std::{ fs::create_dir_all, diff --git a/src/util.rs b/src/util.rs @@ -65,13 +65,13 @@ impl Fairing for CORS { let req_headers = request.headers(); // We need to explicitly get the Origin header for Access-Control-Allow-Origin - let req_allow_origin = CORS::valid_url(CORS::get_header(&req_headers, "Origin")); + let req_allow_origin = CORS::valid_url(CORS::get_header(req_headers, "Origin")); response.set_header(Header::new("Access-Control-Allow-Origin", req_allow_origin)); 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 = CORS::get_header(req_headers, "Access-Control-Request-Headers"); + let req_allow_method = CORS::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)); @@ -86,14 +86,14 @@ impl Fairing for CORS { pub struct Cached<R>(R, &'static str); impl<R> Cached<R> { - pub fn long(r: R) -> Cached<R> { + pub const fn long(r: R) -> Cached<R> { // 7 days - Cached(r, "public, max-age=604800") + Self(r, "public, max-age=604800") } - pub fn short(r: R) -> Cached<R> { + pub const fn short(r: R) -> Cached<R> { // 10 minutes - Cached(r, "public, max-age=600") + Self(r, "public, max-age=600") } } @@ -177,7 +177,7 @@ impl Fairing for BetterLogging { let uri_subpath = request.uri().path().trim_start_matches(&CONFIG.domain_path()); if self.0 || LOGGED_ROUTES.iter().any(|r| uri_subpath.starts_with(r)) { let status = response.status(); - if let Some(ref route) = request.route() { + if let Some(route) = request.route() { info!(target: "response", "{} => {} {}", route, status.code, status.reason) } else { info!(target: "response", "{} {}", status.code, status.reason) @@ -227,33 +227,6 @@ pub fn delete_file(path: &str) -> IOResult<()> { res } -pub struct LimitedReader<'a> { - reader: &'a mut dyn std::io::Read, - limit: usize, // In bytes - count: usize, -} -impl<'a> LimitedReader<'a> { - pub fn new(reader: &'a mut dyn std::io::Read, limit: usize) -> LimitedReader<'a> { - LimitedReader { - reader, - limit, - count: 0, - } - } -} - -impl<'a> std::io::Read for LimitedReader<'a> { - fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> { - self.count += buf.len(); - - if self.count > self.limit { - Ok(0) // End of the read - } else { - self.reader.read(buf) - } - } -} - const UNITS: [&str; 6] = ["bytes", "KB", "MB", "GB", "TB", "PB"]; pub fn get_display_size(size: i32) -> String {