diff --git a/Cargo.toml b/Cargo.toml index 4783c66..a0a05af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,40 +1,46 @@ [workspace.package] -edition = "2021" -authors = ["saying121 "] -homepage = "https://github.com/saying121/tidy-browser" +edition = "2021" +authors = ["saying121 "] +homepage = "https://github.com/saying121/tidy-browser" rust-version = "1.77" -license = "LGPL-3.0-or-later" -repository = "https://github.com/saying121/tidy-browser" -keywords = ["cookies", "decrypt", "Chromium", "Firefox", "Safari"] -categories = ["asynchronous", "authentication", "cryptography", "encoding"] +license = "LGPL-3.0-or-later" +repository = "https://github.com/saying121/tidy-browser" +keywords = ["cookies", "decrypt", "Chromium", "Firefox", "Safari"] +categories = ["asynchronous", "authentication", "cryptography", "encoding"] [workspace] -members = ["crates/*"] +members = ["crates/*"] resolver = "2" -exclude = [".github", "sample/"] +exclude = [".github", "sample/"] [profile.release] -opt-level = 3 -lto = true -strip = true +opt-level = 3 +lto = true +strip = true codegen-units = 1 -panic = "abort" +panic = "abort" [workspace.dependencies] tokio = { version = "^1", features = ["macros"] } # futures = { version = "^0.3", default-features = false } -sea-orm = { version = "^1", default-features = false, features = ["sqlx-sqlite", "runtime-tokio-rustls", "macros"] } +sea-orm = { version = "^1", default-features = false, features = [ + "sqlx-sqlite", + "runtime-tokio-rustls", + "macros", +] } dirs = { version = "^5" } -tracing = { version = "^0.1" } -tracing-subscriber = { version = "^0.3", default-features = true, features = ["env-filter"] } +tracing = { version = "^0.1" } +tracing-subscriber = { version = "^0.3", default-features = true, features = [ + "env-filter", +] } miette = { version = "^7", default-features = true } -serde = { version = "^1", default-features = false, features = ["derive"] } +serde = { version = "^1", default-features = false, features = ["derive"] } serde_json = { version = "^1", default-features = false } strum = { version = "^0.26" } @@ -45,256 +51,129 @@ decrypt-cookies = { path = "./crates/decrypt-cookies", version = "^0.6" } temporary_cstring_as_ptr = "deny" [workspace.lints.clippy] -absurd_extreme_comparisons = "allow" +perf = { level = "deny", priority = -1 } -empty_enum_variants_with_brackets = "warn" -match_same_arms = "warn" -missing_asserts_for_indexing = "warn" -multiple_unsafe_ops_per_block = "warn" -uninhabited_references = "warn" -wildcard_dependencies = "warn" - -# missing_errors_doc = "warn" -# missing_panics_doc = "warn" -unnecessary_safety_doc = "warn" -doc_link_with_quotes = "warn" -doc_markdown = "warn" -# empty_line_after_doc_comments = "warn" - -string_slice = "warn" -str_to_string = "warn" -str_split_at_newline = "warn" -string_add_assign = "warn" -string_lit_as_bytes = "warn" -string_to_string = "warn" -manual_string_new = "warn" -inefficient_to_string = "warn" -needless_raw_strings = "warn" - -filter_map_next = "warn" -flat_map_option = "warn" -option_if_let_else = "warn" -option_option = "warn" -option_as_ref_cloned = "warn" -map_err_ignore = "warn" -map_unwrap_or = "warn" -zero_sized_map_values = "warn" - -maybe_infinite_iter = "warn" -from_iter_instead_of_collect = "warn" -iter_not_returning_iterator = "warn" -iter_on_empty_collections = "warn" -iter_on_single_items = "warn" -iter_with_drain = "warn" -iter_filter_is_ok = "warn" -iter_filter_is_some = "warn" -iter_without_into_iter = "warn" -copy_iterator = "warn" - -let_underscore_untyped = "warn" -useless_let_if_seq = "warn" -equatable_if_let = "warn" -bool_to_int_with_if = "warn" -if_not_else = "warn" -if_then_some_else_none = "warn" -# else_if_without_else = "warn" - -manual_is_variant_and = "warn" -manual_assert = "warn" -manual_clamp = "warn" -manual_instant_elapsed = "warn" -manual_let_else = "warn" -manual_ok_or = "warn" -decimal_literal_representation = "warn" -unreadable_literal = "warn" - -redundant_closure_for_method_calls = "warn" -redundant_clone = "warn" -redundant_else = "warn" -redundant_feature_names = "warn" -redundant_pub_crate = "warn" - -unwrap_used = "warn" -unwrap_in_result = "warn" - -alloc_instead_of_core = "warn" -allow_attributes = "warn" -allow_attributes_without_reason = "warn" - -branches_sharing_code = "warn" -case_sensitive_file_extension_comparisons = "warn" - -clear_with_drain = "warn" -collection_is_never_read = "warn" - -float_arithmetic = "warn" -float_cmp = "warn" -float_cmp_const = "warn" -lossy_float_literal = "warn" -imprecise_flops = "warn" -suboptimal_flops = "warn" -modulo_arithmetic = "warn" +### nursery group +nursery = { level = "warn", priority = -1 } +trivial_regex = "allow" # see: -explicit_deref_methods = "warn" -explicit_into_iter_loop = "warn" -explicit_iter_loop = "warn" - -rc_buffer = "warn" -rc_mutex = "warn" - -mutex_atomic = "warn" -mutex_integer = "warn" - -invalid_upcast_comparisons = "warn" -linkedlist = "warn" -match_on_vec_items = "warn" -match_wild_err_arm = "warn" - -match_bool = "warn" +### pedantic group +inconsistent_struct_constructor = "warn" +match_on_vec_items = "warn" +match_same_arms = "warn" +single_char_pattern = "warn" +missing_fields_in_debug = "warn" +assigning_clones = "warn" +rc_mutex = "warn" needless_bitwise_bool = "warn" - -needless_pass_by_ref_mut = "warn" -needless_collect = "warn" -needless_continue = "warn" -needless_for_each = "warn" -needless_pass_by_value = "warn" - +needless_continue = "warn" +needless_pass_by_value = "warn" range_minus_one = "warn" -range_plus_one = "warn" - +range_plus_one = "warn" semicolon_if_nothing_returned = "warn" -semicolon_inside_block = "warn" -semicolon_outside_block = "warn" - -unnecessary_box_returns = "warn" -unnecessary_join = "warn" -unnecessary_safety_comment = "warn" -unnecessary_self_imports = "warn" -unnecessary_struct_initialization = "warn" -unnecessary_wraps = "warn" - -stable_sort_primitive = "warn" -cloned_instead_of_copied = "warn" - -unused_async = "warn" -unused_peekable = "warn" -unused_rounding = "warn" -unused_self = "warn" - -use_self = "warn" - -create_dir = "warn" -verbose_file_reads = "warn" -verbose_bit_mask = "warn" - -unneeded_field_pattern = "warn" -unnested_or_patterns = "warn" -type_repetition_in_bounds = "warn" +verbose_bit_mask = "warn" +unneeded_field_pattern = "warn" +unnested_or_patterns = "warn" unchecked_duration_subtraction = "warn" -unicode_not_nfc = "warn" -missing_const_for_fn = "warn" -mut_mut = "warn" -filetype_is_file = "warn" -readonly_write_lock = "warn" -try_err = "warn" same_functions_in_if_condition = "warn" -same_name_method = "warn" - -large_digit_groups = "warn" -large_futures = "warn" -large_include_file = "warn" -large_stack_arrays = "warn" -large_stack_frames = "warn" -large_types_passed_by_value = "warn" - -mem_forget = "warn" -empty_drop = "warn" -empty_line_after_outer_attr = "warn" -empty_structs_with_brackets = "warn" -empty_enum = "warn" -enum_glob_use = "warn" - -error_impl_error = "warn" -exit = "warn" -ignored_unit_patterns = "warn" -clone_on_ref_ptr = "warn" - -trait_duplication_in_bounds = "warn" -default_trait_access = "warn" -impl_trait_in_params = "warn" - -trivial_regex = "warn" +same_name_method = "warn" +zero_sized_map_values = "warn" +map_unwrap_or = "warn" +option_as_ref_cloned = "warn" +flat_map_option = "warn" +unnecessary_join = "warn" +unnecessary_safety_comment = "warn" +unnecessary_self_imports = "warn" +unnecessary_wraps = "warn" +cloned_instead_of_copied = "warn" +stable_sort_primitive = "warn" +unused_async = "warn" +unused_self = "warn" +large_futures = "warn" +large_stack_arrays = "warn" +large_digit_groups = "warn" +default_trait_access = "warn" trivially_copy_pass_by_ref = "warn" - -# as_conversions = "warn" -checked_conversions = "warn" -as_underscore = "warn" -borrow_as_ptr = "warn" -as_ptr_cast_mut = "warn" -cast_lossless = "warn" -# cast_possible_truncation = "warn" -cast_possible_wrap = "warn" -cast_precision_loss = "warn" -cast_ptr_alignment = "warn" -cast_sign_loss = "warn" -ptr_as_ptr = "warn" -ptr_cast_constness = "warn" -tuple_array_conversions = "warn" -fn_to_numeric_cast_any = "warn" - -transmute_ptr_to_ptr = "warn" -transmute_undefined_repr = "warn" - -# panic = "warn" -# panic_in_result_fn = "warn" +doc_link_with_quotes = "warn" +doc_markdown = "warn" +naive_bytecount = "warn" +expl_impl_clone_on_copy = "warn" +mismatching_type_param_order = "warn" +many_single_char_names = "warn" +no_mangle_with_rust_abi = "warn" +index_refutable_slice = "warn" +macro_use_imports = "warn" +implicit_clone = "warn" should_panic_without_expect = "warn" -significant_drop_tightening = "warn" -pub_without_shorthand = "warn" - -ref_binding_to_reference = "warn" -ref_option_ref = "warn" -# ref_patterns = "warn" - -rest_pat_in_fully_bound_structs = "warn" - -implicit_hasher = "warn" -implicit_clone = "warn" - -macro_use_imports = "warn" -nonstandard_macro_braces = "warn" - -fn_params_excessive_bools = "warn" -# struct_excessive_bools = "warn" - -unseparated_literal_suffix = "warn" -# default_numeric_fallback = "warn" - -debug_assert_with_mut_call = "warn" +ptr_cast_constness = "warn" +ptr_as_ptr = "warn" +cast_ptr_alignment = "warn" +borrow_as_ptr = "warn" +cast_sign_loss = "warn" +str_split_at_newline = "warn" +string_add_assign = "warn" +manual_string_new = "warn" +inefficient_to_string = "warn" +enum_glob_use = "warn" +explicit_deref_methods = "warn" +redundant_closure_for_method_calls = "warn" +redundant_else = "warn" +manual_c_str_literals = "warn" +explicit_iter_loop = "warn" +explicit_into_iter_loop = "warn" +maybe_infinite_iter = "warn" +from_iter_instead_of_collect = "warn" +iter_not_returning_iterator = "warn" +iter_filter_is_ok = "warn" +iter_filter_is_some = "warn" +iter_without_into_iter = "warn" +into_iter_without_iter = "warn" +filter_map_next = "warn" +manual_is_variant_and = "warn" +manual_assert = "warn" +manual_instant_elapsed = "warn" +manual_let_else = "warn" +manual_ok_or = "warn" +if_not_else = "warn" +bool_to_int_with_if = "warn" + +### restriction group +unwrap_used = "warn" +# unwrap_in_result = "warn" +semicolon_outside_block = "warn" +verbose_file_reads = "warn" +try_err = "warn" +allow_attributes = "warn" +allow_attributes_without_reason = "warn" +as_underscore = "warn" +clone_on_ref_ptr = "warn" +create_dir = "warn" default_union_representation = "warn" -deref_by_slicing = "warn" -derive_partial_eq_without_eq = "warn" -disallowed_script_idents = "warn" - -index_refutable_slice = "warn" - -or_fun_call = "warn" - -path_buf_push_overwrite = "warn" - -no_mangle_with_rust_abi = "warn" - -many_single_char_names = "warn" -mismatching_type_param_order = "warn" -expl_impl_clone_on_copy = "warn" -fallible_impl_from = "warn" -implied_bounds_in_impls = "warn" -inconsistent_struct_constructor = "warn" -mixed_read_write_in_expression = "warn" -naive_bytecount = "warn" -negative_feature_names = "warn" -no_effect_underscore_binding = "warn" - -cargo_common_metadata = "warn" - -# exhaustive_enums = "warn" -# exhaustive_structs = "warn" +deref_by_slicing = "warn" +disallowed_script_idents = "warn" +empty_drop = "warn" +empty_enum_variants_with_brackets = "warn" +empty_structs_with_brackets = "warn" +rest_pat_in_fully_bound_structs = "warn" +error_impl_error = "warn" +filetype_is_file = "warn" +fn_to_numeric_cast_any = "warn" +if_then_some_else_none = "warn" +impl_trait_in_params = "warn" +lossy_float_literal = "warn" +missing_asserts_for_indexing = "warn" +mixed_read_write_in_expression = "warn" +modulo_arithmetic = "warn" +multiple_unsafe_ops_per_block = "warn" +unnecessary_safety_doc = "warn" +ref_option_ref = "warn" +pub_without_shorthand = "warn" +panic_in_result_fn = "warn" +format_push_string = "warn" +str_to_string = "warn" +string_to_string = "warn" + +### cargo group +cargo = { level = "warn", priority = -1 } +multiple_crate_versions = "allow" +exhaustive_structs = "warn" diff --git a/crates/decrypt-cookies/src/browser/cookies.rs b/crates/decrypt-cookies/src/browser/cookies.rs index 62c9de5..5fa03d3 100644 --- a/crates/decrypt-cookies/src/browser/cookies.rs +++ b/crates/decrypt-cookies/src/browser/cookies.rs @@ -6,6 +6,7 @@ use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize)] #[derive(Debug)] #[derive(PartialEq, Eq, PartialOrd, Ord)] +#[non_exhaustive] pub struct LeetCodeCookies { pub csrf: String, pub session: String, diff --git a/crates/decrypt-cookies/src/browser/info.rs b/crates/decrypt-cookies/src/browser/info.rs index ff31070..3a31bee 100644 --- a/crates/decrypt-cookies/src/browser/info.rs +++ b/crates/decrypt-cookies/src/browser/info.rs @@ -340,6 +340,7 @@ pub mod linux { use super::{ChromiumInfo, FfInfo, TempPath}; use crate::Browser; + #[allow(clippy::exhaustive_structs)] #[derive(Clone)] #[derive(Debug)] #[derive(Default)] diff --git a/crates/decrypt-cookies/src/chromium/crypto/linux.rs b/crates/decrypt-cookies/src/chromium/crypto/linux.rs index b1ad185..4991732 100644 --- a/crates/decrypt-cookies/src/chromium/crypto/linux.rs +++ b/crates/decrypt-cookies/src/chromium/crypto/linux.rs @@ -13,6 +13,7 @@ use crate::{browser::info::need_safe_storage, Browser}; // const K_DERIVED_KEY_SIZE_IN_BITS: u32 = 128; type Aes128CbcDec = cbc::Decryptor; +#[allow(clippy::empty_line_after_doc_comments)] // https://source.chromium.org/chromium/chromium/src/+/main:components/os_crypt/sync/os_crypt_linux.cc;l=50 /// The UMA metric name for whether the false was decryptable with an empty key. // const K_METRIC_DECRYPTED_WITH_EMPTY_KEY: &[u8] = b"OSCrypt.Linux.DecryptedWithEmptyKey"; diff --git a/crates/decrypt-cookies/src/chromium/items/cookie/cookie_dao.rs b/crates/decrypt-cookies/src/chromium/items/cookie/cookie_dao.rs index 908afd8..0f02c2e 100644 --- a/crates/decrypt-cookies/src/chromium/items/cookie/cookie_dao.rs +++ b/crates/decrypt-cookies/src/chromium/items/cookie/cookie_dao.rs @@ -19,7 +19,7 @@ pub struct CookiesQuery { impl CookiesQuery { /// * `browser`: `edge`, `chrome` - pub async fn new>(path: P) -> Result { + pub async fn new + Send>(path: P) -> Result { let db_conn_str = format!("sqlite:{}?mode=rwc", path.as_ref().to_string_lossy()); let db = Database::connect(db_conn_str) @@ -31,7 +31,7 @@ impl CookiesQuery { /// get raw Cookies pub async fn query_cookie_filter(&self, filter: F) -> Result> where - F: IntoCondition, + F: IntoCondition + Send, { CookiesDB::find() .filter(filter) diff --git a/crates/decrypt-cookies/src/chromium/items/cookie/mod.rs b/crates/decrypt-cookies/src/chromium/items/cookie/mod.rs index 888e10e..ff981ca 100644 --- a/crates/decrypt-cookies/src/chromium/items/cookie/mod.rs +++ b/crates/decrypt-cookies/src/chromium/items/cookie/mod.rs @@ -7,6 +7,7 @@ use crate::browser::cookies::{CookiesInfo, SameSite}; pub mod cookie_dao; pub mod cookie_entities; +#[allow(clippy::exhaustive_structs)] #[derive(Clone)] #[derive(Debug)] #[derive(PartialEq, Eq)] diff --git a/crates/decrypt-cookies/src/chromium/items/passwd/login_data_dao.rs b/crates/decrypt-cookies/src/chromium/items/passwd/login_data_dao.rs index 3fada09..5c3a232 100644 --- a/crates/decrypt-cookies/src/chromium/items/passwd/login_data_dao.rs +++ b/crates/decrypt-cookies/src/chromium/items/passwd/login_data_dao.rs @@ -17,7 +17,7 @@ pub struct LoginDataQuery { } impl LoginDataQuery { - pub async fn new>(path: P) -> Result { + pub async fn new + Send>(path: P) -> Result { let db_conn_str = format!("sqlite:{}?mode=rwc", path.as_ref().to_string_lossy()); let db = Database::connect(db_conn_str) @@ -29,7 +29,7 @@ impl LoginDataQuery { /// filter login data pub async fn query_login_dt_filter(&self, filter: F) -> Result> where - F: IntoCondition, + F: IntoCondition + Send, { Logins::find() .filter(filter) diff --git a/crates/decrypt-cookies/src/chromium/items/passwd/mod.rs b/crates/decrypt-cookies/src/chromium/items/passwd/mod.rs index 771bb29..e830d2c 100644 --- a/crates/decrypt-cookies/src/chromium/items/passwd/mod.rs +++ b/crates/decrypt-cookies/src/chromium/items/passwd/mod.rs @@ -6,6 +6,7 @@ use super::I64ToChromiumDateTime; pub mod login_data_dao; pub mod login_data_entities; +#[non_exhaustive] #[derive(Clone)] #[derive(Debug)] #[derive(PartialEq, Eq)] diff --git a/crates/decrypt-cookies/src/chromium/local_state.rs b/crates/decrypt-cookies/src/chromium/local_state.rs index 87216ba..7240c8b 100644 --- a/crates/decrypt-cookies/src/chromium/local_state.rs +++ b/crates/decrypt-cookies/src/chromium/local_state.rs @@ -1,3 +1,4 @@ +#![allow(clippy::exhaustive_structs)] use serde::{Deserialize, Serialize}; #[derive(Clone)] diff --git a/crates/decrypt-cookies/src/chromium/mod.rs b/crates/decrypt-cookies/src/chromium/mod.rs index b7ae716..149e881 100644 --- a/crates/decrypt-cookies/src/chromium/mod.rs +++ b/crates/decrypt-cookies/src/chromium/mod.rs @@ -226,7 +226,7 @@ impl ChromiumGetter { /// ``` pub async fn get_logins_filter(&self, filter: F) -> Result> where - F: IntoCondition, + F: IntoCondition + Send, { let raw_login = self .login_data_query @@ -238,7 +238,7 @@ impl ChromiumGetter { /// contains passwords pub async fn get_logins_by_host(&self, host: F) -> Result> where - F: AsRef, + F: AsRef + Send, { let raw_login = self .login_data_query @@ -281,7 +281,7 @@ impl ChromiumGetter { /// ``` pub async fn get_cookies_filter(&self, filter: F) -> Result> where - F: IntoCondition, + F: IntoCondition + Send, { let raw_ck = self .cookies_query @@ -290,7 +290,10 @@ impl ChromiumGetter { self.par_decrypt_ck(raw_ck).await } /// decrypt Cookies - pub async fn get_cookies_by_host>(&self, host: A) -> Result> { + pub async fn get_cookies_by_host + Send>( + &self, + host: A, + ) -> Result> { let raw_ck = self .cookies_query .query_cookie_by_host(host.as_ref()) @@ -308,7 +311,7 @@ impl ChromiumGetter { } /// get `LEETCODE_SESSION` and `csrftoken` for leetcode - pub async fn get_cookies_session_csrf>( + pub async fn get_cookies_session_csrf + Send>( &self, host: A, ) -> Result { diff --git a/crates/decrypt-cookies/src/firefox/items/cookie/dao.rs b/crates/decrypt-cookies/src/firefox/items/cookie/dao.rs index 7fb2345..23d71c0 100644 --- a/crates/decrypt-cookies/src/firefox/items/cookie/dao.rs +++ b/crates/decrypt-cookies/src/firefox/items/cookie/dao.rs @@ -22,7 +22,7 @@ pub struct CookiesQuery { impl CookiesQuery { pub async fn new

(path: P) -> miette::Result where - P: AsRef, + P: AsRef + Send, { let db_conn_str = format!("sqlite:{}?mode=rwc", path.as_ref().to_string_lossy()); @@ -36,7 +36,7 @@ impl CookiesQuery { pub async fn query_cookie_filter(&self, filter: F) -> Result> where - F: IntoCondition, + F: IntoCondition + Send, { let res = MozCookies::find() .filter(filter) diff --git a/crates/decrypt-cookies/src/firefox/items/cookie/mod.rs b/crates/decrypt-cookies/src/firefox/items/cookie/mod.rs index 5e9937b..2471b94 100644 --- a/crates/decrypt-cookies/src/firefox/items/cookie/mod.rs +++ b/crates/decrypt-cookies/src/firefox/items/cookie/mod.rs @@ -1,3 +1,5 @@ +#![allow(clippy::exhaustive_structs)] + use chrono::{DateTime, Utc}; use self::entities::moz_cookies; @@ -10,6 +12,7 @@ pub mod entities; #[derive(Clone)] #[derive(Debug)] #[derive(PartialEq, Eq)] +#[non_exhaustive] pub struct MozCookies { pub id: i32, pub origin_attributes: String, diff --git a/crates/decrypt-cookies/src/firefox/mod.rs b/crates/decrypt-cookies/src/firefox/mod.rs index 30683d5..431e65b 100644 --- a/crates/decrypt-cookies/src/firefox/mod.rs +++ b/crates/decrypt-cookies/src/firefox/mod.rs @@ -117,7 +117,7 @@ impl FirefoxGetter { /// ``` pub async fn get_cookies_filter(&self, filter: F) -> Result> where - F: IntoCondition, + F: IntoCondition + Send, { let res = self .cookies_query diff --git a/crates/decrypt-cookies/src/lib.rs b/crates/decrypt-cookies/src/lib.rs index 6288cd5..30a7679 100644 --- a/crates/decrypt-cookies/src/lib.rs +++ b/crates/decrypt-cookies/src/lib.rs @@ -21,7 +21,7 @@ cfg_if::cfg_if!( /// * `borwser`: Firefox, Librewolf, edge, chrome pub async fn get_cookie(browser: T, host: &str) -> Result where - T: Into + Clone, + T: Into + Clone + Send, { let res = match browser.clone().into() { Browser::Firefox | Browser::Librewolf => {