Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Fix download counts #524

Fix download counts

Fix download counts #524

Triggered via push November 6, 2023 06:17
Status Success
Total duration 1m 58s
Artifacts

security.yml

on: push
security_audit
19s
security_audit
Fit to window
Zoom out
Zoom in

Annotations

3 errors and 9 warnings
&-masking with zero: /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bitflags-1.3.2/src/lib.rs#L464
error: &-masking with zero --> src/models/users.rs:14:1 | 14 | / bitflags::bitflags! { 15 | | #[derive(Serialize, Deserialize)] 16 | | #[serde(transparent)] 17 | | pub struct Badges: u64 { ... | 29 | | } 30 | | } | |_^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bad_bit_mask = note: this error originates in the macro `__impl_bitflags` which comes from the expansion of the macro `bitflags::bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)
&-masking with zero: /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bitflags-1.3.2/src/lib.rs#L464
error: &-masking with zero --> src/models/teams.rs:79:1 | 79 | / bitflags::bitflags! { 80 | | #[derive(Serialize, Deserialize)] 81 | | #[serde(transparent)] 82 | | pub struct OrganizationPermissions: u64 { ... | 94 | | } 95 | | } | |_^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bad_bit_mask = note: this error originates in the macro `__impl_bitflags` which comes from the expansion of the macro `bitflags::bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)
&-masking with zero: /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bitflags-1.3.2/src/lib.rs#L464
error: &-masking with zero --> src/models/pats.rs:12:1 | 12 | / bitflags::bitflags! { 13 | | #[derive(Serialize, Deserialize)] 14 | | #[serde(transparent)] 15 | | pub struct Scopes: u64 { ... | 109 | | } 110 | | } | |_^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bad_bit_mask = note: `#[deny(clippy::bad_bit_mask)]` on by default = note: this error originates in the macro `__impl_bitflags` which comes from the expansion of the macro `bitflags::bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)
security_audit
The following actions uses node12 which is deprecated and will be forced to run on node16: actions-rs/audit-check@v1. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/
security_audit
3 warnings found!
security_audit
Unknown warning kind unsound found, please, file a bug
security_audit
Unknown warning kind unsound found, please, file a bug
called `unwrap` on `projects` after checking its variant with `is_some`: src/clickhouse/fetch.rs#L233
warning: called `unwrap` on `projects` after checking its variant with `is_some` --> src/clickhouse/fetch.rs:233:28 | 232 | if projects.is_some() { | --------------------- help: try: `if let Some(..) = projects` 233 | query = query.bind(projects.unwrap().iter().map(|x| x.0).collect::<Vec<_>>()); | ^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
called `unwrap` on `projects` after checking its variant with `is_some`: src/clickhouse/fetch.rs#L170
warning: called `unwrap` on `projects` after checking its variant with `is_some` --> src/clickhouse/fetch.rs:170:28 | 169 | if projects.is_some() { | --------------------- help: try: `if let Some(..) = projects` 170 | query = query.bind(projects.unwrap().iter().map(|x| x.0).collect::<Vec<_>>()); | ^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
called `unwrap` on `projects` after checking its variant with `is_some`: src/clickhouse/fetch.rs#L125
warning: called `unwrap` on `projects` after checking its variant with `is_some` --> src/clickhouse/fetch.rs:125:28 | 124 | if projects.is_some() { | --------------------- help: try: `if let Some(..) = projects` 125 | query = query.bind(projects.unwrap().iter().map(|x| x.0).collect::<Vec<_>>()); | ^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
called `unwrap` on `projects` after checking its variant with `is_some`: src/clickhouse/fetch.rs#L79
warning: called `unwrap` on `projects` after checking its variant with `is_some` --> src/clickhouse/fetch.rs:79:28 | 78 | if projects.is_some() { | --------------------- help: try: `if let Some(..) = projects` 79 | query = query.bind(projects.unwrap().iter().map(|x| x.0).collect::<Vec<_>>()); | ^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap = note: `#[warn(clippy::unnecessary_unwrap)]` on by default
try not to call a closure in the expression where it is declared: src/auth/flows.rs#L1015
warning: try not to call a closure in the expression where it is declared --> src/auth/flows.rs:1015:58 | 1015 | let res: Result<HttpResponse, AuthenticationError> = (|| async move { | __________________________________________________________^ 1016 | | 1017 | | let flow = Flow::get(&state, &redis).await?; 1018 | | ... | 1176 | | } 1177 | | })().await; | |________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_call = note: `#[warn(clippy::redundant_closure_call)]` on by default help: try doing something like | 1015 ~ let res: Result<HttpResponse, AuthenticationError> = async async move { 1016 + 1017 + let flow = Flow::get(&state, &redis).await?; 1018 + 1019 + // Extract cookie header from request 1020 + if let Some(Flow::OAuth { 1021 + user_id, 1022 + provider, 1023 + url, 1024 + }) = flow 1025 + { 1026 + Flow::remove(&state, &redis).await?; 1027 + 1028 + let token = provider.get_token(query).await?; 1029 + let oauth_user = provider.get_user(&token).await?; 1030 + 1031 + let user_id_opt = provider.get_user_id(&oauth_user.id, &**client).await?; 1032 + 1033 + let mut transaction = client.begin().await?; 1034 + if let Some(id) = user_id { 1035 + if user_id_opt.is_some() { 1036 + return Err(AuthenticationError::DuplicateUser); 1037 + } 1038 + 1039 + provider 1040 + .update_user_id(id, Some(&oauth_user.id), &mut transaction) 1041 + .await?; 1042 + 1043 + let user = crate::database::models::User::get_id(id, &**client, &redis).await?; 1044 + if let Some(email) = user.and_then(|x| x.email) { 1045 + send_email( 1046 + email, 1047 + "Authentication method added", 1048 + &format!("When logging into Modrinth, you can now log in using the {} authentication provider.", provider.as_str()), 1049 + "If you did not make this change, please contact us immediately through our support channels on Discord or via email ([email protected]).", 1050 + None, 1051 + )?; 1052 + } 1053 + 1054 + crate::database::models::User::clear_caches(&[(id, None)], &redis).await?; 1055 + transaction.commit().await?; 1056 + 1057 + if let Some(url) = url { 1058 + Ok(HttpResponse::TemporaryRedirect() 1059 + .append_header(("Location", &*url)) 1060 + .json(serde_json::json!({ "url": url }))) 1061 + } else { 1062 + Err(AuthenticationError::InvalidCredentials) 1063 + } 1064 + } else { 1065 + let user_id = if let Some(user_id) = user_id_opt { 1066 + let user = crate::database::models::User::get_id(user_id, &**client, &redis) 1067 + .await? 1068 + .ok_or_else(|| AuthenticationError::InvalidCredentials)?; 1069 + 1070 + if user.totp_secret.is_some() { 1071 + let flow = Flow::Login2FA { user_id: user.id } 1072 + .insert(Duration::minutes(30), &redis) 1073 + .await?; 1074 + 1075 + if let Some(url) = url { 1076 + let redirect_url = format!( 1077 + "{}{}error=2fa_required&flow={}", 1078 + url, 1079 + if url.contains('?') { "&" } else { "?" }, 1080 + flow 1081 + ); 1082 + 1083 + return Ok(HttpResponse::TemporaryRedirect() 1084 + .append_header(("Location", &*redirect_url)) 1085 + .json(serde_json::json!({ "url": redirect_url }))); 1086 + } else { 1087 + let mut ws_conn = { 1088 + let db = sockets.read().await; 1089 + 1090 + let mut x = db 1091 + .auth_sockets 1092 + .get_mut(&state) 1093 + .ok_or_else(|| AuthenticationError::SocketError)?; 1094 + 1095 + x.value_mut().clone() 1096 + }; 1097 + 1098 + ws_conn 1099 + .text( 1100 + serde_json::json!({ 1101 + "error": "2fa_required", 1102 + "flow": flow, 1103 + }).to_string() 1104 + ) 1105 + .await.map_err(|_| AuthenticationError::SocketError)?; 1106 + 1107 + let _ = ws_conn.close(None).await; 1108 + 1109 + return Ok(super::templates::Success { 1110 + icon: user.avatar_url.as_deref().unwrap_or("https://cdn-raw.modrinth.com/placeholder.svg"), 1111 + name: &user.username, 1112 + }.render()); 1113 + } 1114 + } 1115 + 1116 + user_id 1117 + } else { 1118 + oauth_user.create_account(provider, &mut transaction, &client, &file_host, &redis).await? 1119 + }; 1120 + 1121 + let session = issue_session(req, user_id, &mut transaction, &redis).await?; 1122 + transaction.commit().await?; 1123 + 1124 + if let Some(url) = url { 1125 + let redirect_url = format!( 1126 + "{}{}code={}{}", 1127 + url, 1128 + if url.contains('?') { '&' } else { '?' }, 1129 + session.session, 1130 + if user_id_opt.is_none() { 1131 + "&new_account=true" 1132 + } else { 1133 + "" 1134 + } 1135 + ); 1136 + 1137 + Ok(HttpResponse::TemporaryRedirect() 1138 + .append_header(("Location", &*redirect_url)) 1139 + .json(serde_json::json!({ "url": redirect_url }))) 1140 + } else { 1141 + let user = crate::database::models::user_item::User::get_id( 1142 + user_id, 1143 + &**client, 1144 + &redis, 1145 + ) 1146 + .await?.ok_or_else(|| AuthenticationError::InvalidCredentials)?; 1147 + 1148 + let mut ws_conn = { 1149 + let db = sockets.read().await; 1150 + 1151 + let mut x = db 1152 + .auth_sockets 1153 + .get_mut(&state) 1154 + .ok_or_else(|| AuthenticationError::SocketError)?; 1155 + 1156 + x.value_mut().clone() 1157 + }; 1158 + 1159 + ws_conn 1160 + .text( 1161 + serde_json::json!({ 1162 + "code": session.session, 1163 + }).to_string() 1164 + ) 1165 + .await.map_err(|_| AuthenticationError::SocketError)?; 1166 + let _ = ws_conn.close(None).await; 1167 + 1168 + return Ok(super::templates::Success { 1169 + icon: user.avatar_url.as_deref().unwrap_or("https://cdn-raw.modrinth.com/placeholder.svg"), 1170 + name: &user.username, 1171 + }.render()); 1172 + } 1173 + } 1174 + } else { 1175 + Err::<HttpResponse, AuthenticationError>(AuthenticationError::InvalidCredentials) 1176 + } 1177 ~ }.await; |