fix clippy

This commit is contained in:
nab138
2026-02-01 01:03:27 -05:00
parent 41e29caea8
commit a944dc79c7
6 changed files with 24 additions and 32 deletions

View File

@@ -52,8 +52,7 @@ impl AnisetteData {
// "X-Mme-Client-Info".to_string(), // "X-Mme-Client-Info".to_string(),
// self.device_description.clone(), // self.device_description.clone(),
// ), // ),
] ],
.into_iter(),
) )
} }
@@ -125,11 +124,10 @@ impl AnisetteDataGenerator {
&mut self, &mut self,
gs: Arc<GrandSlam>, gs: Arc<GrandSlam>,
) -> Result<Arc<AnisetteData>, Report> { ) -> Result<Arc<AnisetteData>, Report> {
if let Some(data) = &self.data { if let Some(data) = &self.data
if !data.needs_refresh() { && !data.needs_refresh() {
return Ok(data.clone()); return Ok(data.clone());
} }
}
// trying to avoid locking as write unless necessary to promote concurrency // trying to avoid locking as write unless necessary to promote concurrency
let provider = self.provider.read().await; let provider = self.provider.read().await;

View File

@@ -97,7 +97,7 @@ impl AnisetteProvider for RemoteV3AnisetteProvider {
.header(CONTENT_TYPE, "application/json") .header(CONTENT_TYPE, "application/json")
.body( .body(
serde_json::json!({ serde_json::json!({
"identifier": BASE64_STANDARD.encode(&state.keychain_identifier), "identifier": BASE64_STANDARD.encode(state.keychain_identifier),
"adi_pb": BASE64_STANDARD.encode(adi_pb) "adi_pb": BASE64_STANDARD.encode(adi_pb)
}) })
.to_string(), .to_string(),
@@ -120,7 +120,7 @@ impl AnisetteProvider for RemoteV3AnisetteProvider {
routing_info, routing_info,
_device_description: client_info.client_info.clone(), _device_description: client_info.client_info.clone(),
device_unique_identifier: state.get_device_id(), device_unique_identifier: state.get_device_id(),
_local_user_id: hex::encode(&state.get_md_lu()), _local_user_id: hex::encode(state.get_md_lu()),
generated_at: SystemTime::now(), generated_at: SystemTime::now(),
}; };
@@ -128,8 +128,7 @@ impl AnisetteProvider for RemoteV3AnisetteProvider {
} }
AnisetteHeaders::GetHeadersError { message } => { AnisetteHeaders::GetHeadersError { message } => {
Err(report!("Failed to get anisette headers") Err(report!("Failed to get anisette headers")
.attach(message) .attach(message))
.into())
} }
} }
} }
@@ -253,7 +252,7 @@ impl RemoteV3AnisetteProvider {
ws_stream ws_stream
.send(Message::Text( .send(Message::Text(
serde_json::json!({ serde_json::json!({
"identifier": BASE64_STANDARD.encode(&state.keychain_identifier), "identifier": BASE64_STANDARD.encode(state.keychain_identifier),
}) })
.to_string() .to_string()
.into(), .into(),
@@ -337,15 +336,13 @@ impl RemoteV3AnisetteProvider {
ProvisioningMessage::StartProvisioningError { message } => { ProvisioningMessage::StartProvisioningError { message } => {
return Err( return Err(
report!("Anisette provisioning failed: start provisioning error") report!("Anisette provisioning failed: start provisioning error")
.attach(message) .attach(message),
.into(),
); );
} }
ProvisioningMessage::EndProvisioningError { message } => { ProvisioningMessage::EndProvisioningError { message } => {
return Err( return Err(
report!("Anisette provisioning failed: end provisioning error") report!("Anisette provisioning failed: end provisioning error")
.attach(message) .attach(message),
.into(),
); );
} }
} }

View File

@@ -17,7 +17,7 @@ fn bin_serialize_opt<S>(x: &Option<Vec<u8>>, s: S) -> Result<S::Ok, S::Error>
where where
S: Serializer, S: Serializer,
{ {
x.clone().map(|i| Data::new(i)).serialize(s) x.clone().map(Data::new).serialize(s)
} }
fn bin_deserialize_opt<'de, D>(d: D) -> Result<Option<Vec<u8>>, D::Error> fn bin_deserialize_opt<'de, D>(d: D) -> Result<Option<Vec<u8>>, D::Error>
@@ -71,7 +71,7 @@ impl AnisetteState {
pub fn get_md_lu(&self) -> [u8; 32] { pub fn get_md_lu(&self) -> [u8; 32] {
let mut hasher = Sha256::new(); let mut hasher = Sha256::new();
hasher.update(&self.keychain_identifier); hasher.update(self.keychain_identifier);
hasher.finalize().into() hasher.finalize().into()
} }

View File

@@ -300,9 +300,9 @@ impl AppleAccount {
.await .await
.context("Failed to read SMS 2FA error response text")?; .context("Failed to read SMS 2FA error response text")?;
// try to parse as json, if it fails, just bail with the text // try to parse as json, if it fails, just bail with the text
if let Ok(json) = serde_json::from_str::<serde_json::Value>(&text) { if let Ok(json) = serde_json::from_str::<serde_json::Value>(&text)
if let Some(service_errors) = json.get("serviceErrors") { && let Some(service_errors) = json.get("serviceErrors")
if let Some(first_error) = service_errors.as_array().and_then(|arr| arr.get(0)) && let Some(first_error) = service_errors.as_array().and_then(|arr| arr.first())
{ {
let code = first_error let code = first_error
.get("code") .get("code")
@@ -323,8 +323,6 @@ impl AppleAccount {
message message
); );
} }
}
}
bail!( bail!(
"SMS 2FA code submission failed with http status {}: {}", "SMS 2FA code submission failed with http status {}: {}",
status, status,
@@ -435,7 +433,7 @@ impl AppleAccount {
let hashed_password = Sha256::digest(password.as_bytes()); let hashed_password = Sha256::digest(password.as_bytes());
let password_hash = if selected_protocol == "s2k_fo" { let password_hash = if selected_protocol == "s2k_fo" {
hex::encode(&hashed_password).into_bytes() hex::encode(hashed_password).into_bytes()
} else { } else {
hashed_password.to_vec() hashed_password.to_vec()
}; };
@@ -445,7 +443,7 @@ impl AppleAccount {
.context("Failed to derive password using PBKDF2")?; .context("Failed to derive password using PBKDF2")?;
let verifier: SrpClientVerifier<Sha256> = srp_client let verifier: SrpClientVerifier<Sha256> = srp_client
.process_reply(&a, &self.email.as_bytes(), &password_buf, salt, b_pub) .process_reply(&a, self.email.as_bytes(), &password_buf, salt, b_pub)
.unwrap(); .unwrap();
let req2 = plist!(dict { let req2 = plist!(dict {
@@ -486,7 +484,7 @@ impl AppleAccount {
.get_data("spd") .get_data("spd")
.context("Failed to get SPD from login response")?; .context("Failed to get SPD from login response")?;
let spd_decrypted = Self::decrypt_cbc(&verifier, &spd_encrypted) let spd_decrypted = Self::decrypt_cbc(&verifier, spd_encrypted)
.context("Failed to decrypt SPD from login response")?; .context("Failed to decrypt SPD from login response")?;
let spd: plist::Dictionary = let spd: plist::Dictionary =
plist::from_bytes(&spd_decrypted).context("Failed to parse decrypted SPD plist")?; plist::from_bytes(&spd_decrypted).context("Failed to parse decrypted SPD plist")?;
@@ -575,7 +573,7 @@ impl AppleAccount {
.get_data("et") .get_data("et")
.context("Failed to get encrypted token")?; .context("Failed to get encrypted token")?;
let decrypted_token = Self::decrypt_gcm(&encrypted_token, &session_key) let decrypted_token = Self::decrypt_gcm(encrypted_token, session_key)
.context("Failed to decrypt app token")?; .context("Failed to decrypt app token")?;
let token: Dictionary = plist::from_bytes(&decrypted_token) let token: Dictionary = plist::from_bytes(&decrypted_token)
@@ -612,7 +610,7 @@ impl AppleAccount {
fn create_session_key(usr: &SrpClientVerifier<Sha256>, name: &str) -> Result<Vec<u8>, Report> { fn create_session_key(usr: &SrpClientVerifier<Sha256>, name: &str) -> Result<Vec<u8>, Report> {
Ok( Ok(
<hmac::Hmac<Sha256> as hmac::Mac>::new_from_slice(&usr.key())? <hmac::Hmac<Sha256> as hmac::Mac>::new_from_slice(usr.key())?
.chain_update(name.as_bytes()) .chain_update(name.as_bytes())
.finalize() .finalize()
.into_bytes() .into_bytes()
@@ -627,7 +625,7 @@ impl AppleAccount {
Ok( Ok(
cbc::Decryptor::<aes::Aes256>::new_from_slices(&extra_data_key, extra_data_iv)? cbc::Decryptor::<aes::Aes256>::new_from_slices(&extra_data_key, extra_data_iv)?
.decrypt_padded_vec_mut::<Pkcs7>(&data)?, .decrypt_padded_vec_mut::<Pkcs7>(data)?,
) )
} }

View File

@@ -105,7 +105,7 @@ impl GrandSlam {
) -> Result<Dictionary, Report> { ) -> Result<Dictionary, Report> {
let resp = self let resp = self
.post(url)? .post(url)?
.headers(additional_headers.unwrap_or_else(|| reqwest::header::HeaderMap::new())) .headers(additional_headers.unwrap_or_else(reqwest::header::HeaderMap::new))
.body(plist_to_xml_string(body)) .body(plist_to_xml_string(body))
.send() .send()
.await .await

View File

@@ -69,7 +69,7 @@ impl DeveloperSession {
url: &str, url: &str,
body: impl Into<Option<Dictionary>>, body: impl Into<Option<Dictionary>>,
) -> Result<(Dictionary, Option<String>), Report> { ) -> Result<(Dictionary, Option<String>), Report> {
let body = body.into().unwrap_or_else(|| Dictionary::new()); let body = body.into().unwrap_or_else(Dictionary::new);
let base = plist!(dict { let base = plist!(dict {
"clientId": "XABBG36SBA", "clientId": "XABBG36SBA",
@@ -147,11 +147,10 @@ impl DeveloperSession {
let result: Result<T, _> = dict.get_struct(response_key); let result: Result<T, _> = dict.get_struct(response_key);
if let Err(_) = &result { if result.is_err()
if let Some(err) = server_error { && let Some(err) = server_error {
bail!(err); bail!(err);
} }
}
Ok(result.context("Failed to extract developer request result")?) Ok(result.context("Failed to extract developer request result")?)
} }