chore(v1.1.8): clippy --all-targets clean (F2)
Sweep the v1.1.8-introduced clippy warnings under
--workspace --all-targets --all-features -- -D warnings:
* 12x map_unwrap_or in executor-core/sdk/users.rs — rewrite as
map_or; mostly the Option<X> -> Dynamic conversion shape.
* Doc-list-without-indentation in
app_user_password_reset_repo.rs's module docstring — rewrap
so a continuation line doesn't start with `+ `.
* usize-as-i64 cast in app_user_repo.rs list — use
i64::try_from(...).unwrap_or(i64::MAX) for the cursor cap.
* 2x map_unwrap_or in users_service.rs env helpers — map_or.
* single-pattern match in users_service.rs login — let-else
rewrite so the dummy-Argon2 side-effect stays in the
diverging branch (no semantic change).
Also updated the 10 executor-core integration-test bins
(sdk_email, sdk_kv, sdk_docs, sdk_files, sdk_pubsub,
sdk_secrets, sdk_http, sdk_subscriber_token,
module_redaction_logging, modules) to pass the new
NoopUsersService positional arg into Services::new().
NOTE — the brief specifies running this attestation under `cargo
clean` first. I skipped the clean step because an earlier
`cargo test --workspace` froze this host (the user explicitly
asked me to keep subsequent builds lighter). The incremental
cache was hot for every workspace crate when clippy ran; test
binaries appeared in the Checking output as expected. Flagged in
HANDBACK §6 F2 + §7.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -117,9 +117,7 @@ fn bind_get(module: &mut Module, svc: &Arc<dyn UsersService>, cx: &Arc<SdkCallCx
|
|||||||
let svc = svc.clone();
|
let svc = svc.clone();
|
||||||
let cx = cx.clone();
|
let cx = cx.clone();
|
||||||
let user_opt = block_on(async move { svc.get(&cx, id).await })?;
|
let user_opt = block_on(async move { svc.get(&cx, id).await })?;
|
||||||
Ok(user_opt
|
Ok(user_opt.map_or(Dynamic::UNIT, |u| Dynamic::from(user_to_map(&u))))
|
||||||
.map(|u| Dynamic::from(user_to_map(&u)))
|
|
||||||
.unwrap_or(Dynamic::UNIT))
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -134,9 +132,7 @@ fn bind_find_by_email(module: &mut Module, svc: &Arc<dyn UsersService>, cx: &Arc
|
|||||||
let svc = svc.clone();
|
let svc = svc.clone();
|
||||||
let cx = cx.clone();
|
let cx = cx.clone();
|
||||||
let user_opt = block_on(async move { svc.find_by_email(&cx, &email).await })?;
|
let user_opt = block_on(async move { svc.find_by_email(&cx, &email).await })?;
|
||||||
Ok(user_opt
|
Ok(user_opt.map_or(Dynamic::UNIT, |u| Dynamic::from(user_to_map(&u))))
|
||||||
.map(|u| Dynamic::from(user_to_map(&u)))
|
|
||||||
.unwrap_or(Dynamic::UNIT))
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -226,9 +222,7 @@ fn bind_login(module: &mut Module, svc: &Arc<dyn UsersService>, cx: &Arc<SdkCall
|
|||||||
let cx = cx.clone();
|
let cx = cx.clone();
|
||||||
let session_opt: Option<GeneratedSession> =
|
let session_opt: Option<GeneratedSession> =
|
||||||
block_on(async move { svc.login(&cx, &email, &password).await })?;
|
block_on(async move { svc.login(&cx, &email, &password).await })?;
|
||||||
Ok(session_opt
|
Ok(session_opt.map_or(Dynamic::UNIT, |s| Dynamic::from(s.token)))
|
||||||
.map(|s| Dynamic::from(s.token))
|
|
||||||
.unwrap_or(Dynamic::UNIT))
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -243,9 +237,7 @@ fn bind_verify(module: &mut Module, svc: &Arc<dyn UsersService>, cx: &Arc<SdkCal
|
|||||||
let svc = svc.clone();
|
let svc = svc.clone();
|
||||||
let cx = cx.clone();
|
let cx = cx.clone();
|
||||||
let user_opt = block_on(async move { svc.verify(&cx, &token).await })?;
|
let user_opt = block_on(async move { svc.verify(&cx, &token).await })?;
|
||||||
Ok(user_opt
|
Ok(user_opt.map_or(Dynamic::UNIT, |u| Dynamic::from(user_to_map(&u))))
|
||||||
.map(|u| Dynamic::from(user_to_map(&u)))
|
|
||||||
.unwrap_or(Dynamic::UNIT))
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -297,9 +289,7 @@ fn bind_verify_email(module: &mut Module, svc: &Arc<dyn UsersService>, cx: &Arc<
|
|||||||
let svc = svc.clone();
|
let svc = svc.clone();
|
||||||
let cx = cx.clone();
|
let cx = cx.clone();
|
||||||
let user_opt = block_on(async move { svc.verify_email(&cx, &token).await })?;
|
let user_opt = block_on(async move { svc.verify_email(&cx, &token).await })?;
|
||||||
Ok(user_opt
|
Ok(user_opt.map_or(Dynamic::UNIT, |u| Dynamic::from(user_to_map(&u))))
|
||||||
.map(|u| Dynamic::from(user_to_map(&u)))
|
|
||||||
.unwrap_or(Dynamic::UNIT))
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -340,9 +330,7 @@ fn bind_complete_password_reset(
|
|||||||
let user_opt = block_on(async move {
|
let user_opt = block_on(async move {
|
||||||
svc.complete_password_reset(&cx, &token, &new_password).await
|
svc.complete_password_reset(&cx, &token, &new_password).await
|
||||||
})?;
|
})?;
|
||||||
Ok(user_opt
|
Ok(user_opt.map_or(Dynamic::UNIT, |u| Dynamic::from(user_to_map(&u))))
|
||||||
.map(|u| Dynamic::from(user_to_map(&u)))
|
|
||||||
.unwrap_or(Dynamic::UNIT))
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -379,9 +367,7 @@ fn bind_accept_invite(module: &mut Module, svc: &Arc<dyn UsersService>, cx: &Arc
|
|||||||
let cx = cx.clone();
|
let cx = cx.clone();
|
||||||
let accept_opt: Option<GeneratedAccept> =
|
let accept_opt: Option<GeneratedAccept> =
|
||||||
block_on(async move { svc.accept_invite(&cx, &token, &password, None).await })?;
|
block_on(async move { svc.accept_invite(&cx, &token, &password, None).await })?;
|
||||||
Ok(accept_opt
|
Ok(accept_opt.map_or(Dynamic::UNIT, |a| Dynamic::from(a.session.token)))
|
||||||
.map(|a| Dynamic::from(a.session.token))
|
|
||||||
.unwrap_or(Dynamic::UNIT))
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -406,9 +392,7 @@ fn bind_accept_invite(module: &mut Module, svc: &Arc<dyn UsersService>, cx: &Arc
|
|||||||
let accept_opt: Option<GeneratedAccept> = block_on(async move {
|
let accept_opt: Option<GeneratedAccept> = block_on(async move {
|
||||||
svc.accept_invite(&cx, &token, &password, display_name).await
|
svc.accept_invite(&cx, &token, &password, display_name).await
|
||||||
})?;
|
})?;
|
||||||
Ok(accept_opt
|
Ok(accept_opt.map_or(Dynamic::UNIT, |a| Dynamic::from(a.session.token)))
|
||||||
.map(|a| Dynamic::from(a.session.token))
|
|
||||||
.unwrap_or(Dynamic::UNIT))
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -475,20 +459,17 @@ fn user_to_map(user: &AppUser) -> Map {
|
|||||||
"display_name".into(),
|
"display_name".into(),
|
||||||
user.display_name
|
user.display_name
|
||||||
.clone()
|
.clone()
|
||||||
.map(Dynamic::from)
|
.map_or(Dynamic::UNIT, Dynamic::from),
|
||||||
.unwrap_or(Dynamic::UNIT),
|
|
||||||
);
|
);
|
||||||
m.insert(
|
m.insert(
|
||||||
"email_verified_at".into(),
|
"email_verified_at".into(),
|
||||||
user.email_verified_at
|
user.email_verified_at
|
||||||
.map(|d| Dynamic::from(d.to_rfc3339()))
|
.map_or(Dynamic::UNIT, |d| Dynamic::from(d.to_rfc3339())),
|
||||||
.unwrap_or(Dynamic::UNIT),
|
|
||||||
);
|
);
|
||||||
m.insert(
|
m.insert(
|
||||||
"last_login_at".into(),
|
"last_login_at".into(),
|
||||||
user.last_login_at
|
user.last_login_at
|
||||||
.map(|d| Dynamic::from(d.to_rfc3339()))
|
.map_or(Dynamic::UNIT, |d| Dynamic::from(d.to_rfc3339())),
|
||||||
.unwrap_or(Dynamic::UNIT),
|
|
||||||
);
|
);
|
||||||
m.insert("created_at".into(), Dynamic::from(user.created_at.to_rfc3339()));
|
m.insert("created_at".into(), Dynamic::from(user.created_at.to_rfc3339()));
|
||||||
m.insert("updated_at".into(), Dynamic::from(user.updated_at.to_rfc3339()));
|
m.insert("updated_at".into(), Dynamic::from(user.updated_at.to_rfc3339()));
|
||||||
@@ -509,8 +490,7 @@ fn list_page_to_map(page: &UsersListPage) -> Map {
|
|||||||
m.insert(
|
m.insert(
|
||||||
"next_cursor".into(),
|
"next_cursor".into(),
|
||||||
page.next_cursor
|
page.next_cursor
|
||||||
.map(|d| Dynamic::from(d.to_rfc3339()))
|
.map_or(Dynamic::UNIT, |d| Dynamic::from(d.to_rfc3339())),
|
||||||
.unwrap_or(Dynamic::UNIT),
|
|
||||||
);
|
);
|
||||||
m
|
m
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ async fn original_backend_error_is_logged_at_error_level() {
|
|||||||
Arc::new(picloud_shared::NoopPubsubService),
|
Arc::new(picloud_shared::NoopPubsubService),
|
||||||
Arc::new(picloud_shared::NoopSecretsService),
|
Arc::new(picloud_shared::NoopSecretsService),
|
||||||
Arc::new(picloud_shared::NoopEmailService),
|
Arc::new(picloud_shared::NoopEmailService),
|
||||||
|
Arc::new(picloud_shared::NoopUsersService),
|
||||||
);
|
);
|
||||||
let engine = Engine::new(Limits::default(), services);
|
let engine = Engine::new(Limits::default(), services);
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ fn services_with(modules: Arc<dyn ModuleSource>) -> Services {
|
|||||||
Arc::new(picloud_shared::NoopPubsubService),
|
Arc::new(picloud_shared::NoopPubsubService),
|
||||||
Arc::new(picloud_shared::NoopSecretsService),
|
Arc::new(picloud_shared::NoopSecretsService),
|
||||||
Arc::new(picloud_shared::NoopEmailService),
|
Arc::new(picloud_shared::NoopEmailService),
|
||||||
|
Arc::new(picloud_shared::NoopUsersService),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -232,6 +232,7 @@ fn make_engine() -> Arc<Engine> {
|
|||||||
Arc::new(picloud_shared::NoopPubsubService),
|
Arc::new(picloud_shared::NoopPubsubService),
|
||||||
Arc::new(picloud_shared::NoopSecretsService),
|
Arc::new(picloud_shared::NoopSecretsService),
|
||||||
Arc::new(picloud_shared::NoopEmailService),
|
Arc::new(picloud_shared::NoopEmailService),
|
||||||
|
Arc::new(picloud_shared::NoopUsersService),
|
||||||
);
|
);
|
||||||
Arc::new(Engine::new(Limits::default(), services))
|
Arc::new(Engine::new(Limits::default(), services))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ fn engine_with(rec: Arc<RecordingEmail>) -> Arc<Engine> {
|
|||||||
Arc::new(picloud_shared::NoopPubsubService),
|
Arc::new(picloud_shared::NoopPubsubService),
|
||||||
Arc::new(picloud_shared::NoopSecretsService),
|
Arc::new(picloud_shared::NoopSecretsService),
|
||||||
rec,
|
rec,
|
||||||
|
Arc::new(picloud_shared::NoopUsersService),
|
||||||
);
|
);
|
||||||
Arc::new(Engine::new(Limits::default(), services))
|
Arc::new(Engine::new(Limits::default(), services))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,6 +169,7 @@ fn make_engine() -> Arc<Engine> {
|
|||||||
Arc::new(picloud_shared::NoopPubsubService),
|
Arc::new(picloud_shared::NoopPubsubService),
|
||||||
Arc::new(picloud_shared::NoopSecretsService),
|
Arc::new(picloud_shared::NoopSecretsService),
|
||||||
Arc::new(picloud_shared::NoopEmailService),
|
Arc::new(picloud_shared::NoopEmailService),
|
||||||
|
Arc::new(picloud_shared::NoopUsersService),
|
||||||
);
|
);
|
||||||
Arc::new(Engine::new(Limits::default(), services))
|
Arc::new(Engine::new(Limits::default(), services))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ fn engine_with(http: Arc<dyn HttpService>) -> Arc<Engine> {
|
|||||||
Arc::new(picloud_shared::NoopPubsubService),
|
Arc::new(picloud_shared::NoopPubsubService),
|
||||||
Arc::new(picloud_shared::NoopSecretsService),
|
Arc::new(picloud_shared::NoopSecretsService),
|
||||||
Arc::new(picloud_shared::NoopEmailService),
|
Arc::new(picloud_shared::NoopEmailService),
|
||||||
|
Arc::new(picloud_shared::NoopUsersService),
|
||||||
);
|
);
|
||||||
Arc::new(Engine::new(Limits::default(), services))
|
Arc::new(Engine::new(Limits::default(), services))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ fn make_engine() -> Arc<Engine> {
|
|||||||
Arc::new(picloud_shared::NoopPubsubService),
|
Arc::new(picloud_shared::NoopPubsubService),
|
||||||
Arc::new(picloud_shared::NoopSecretsService),
|
Arc::new(picloud_shared::NoopSecretsService),
|
||||||
Arc::new(picloud_shared::NoopEmailService),
|
Arc::new(picloud_shared::NoopEmailService),
|
||||||
|
Arc::new(picloud_shared::NoopUsersService),
|
||||||
);
|
);
|
||||||
Arc::new(Engine::new(Limits::default(), services))
|
Arc::new(Engine::new(Limits::default(), services))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ fn make_engine(svc: Arc<RecordingPubsub>) -> Arc<Engine> {
|
|||||||
svc,
|
svc,
|
||||||
Arc::new(picloud_shared::NoopSecretsService),
|
Arc::new(picloud_shared::NoopSecretsService),
|
||||||
Arc::new(picloud_shared::NoopEmailService),
|
Arc::new(picloud_shared::NoopEmailService),
|
||||||
|
Arc::new(picloud_shared::NoopUsersService),
|
||||||
);
|
);
|
||||||
Arc::new(Engine::new(Limits::default(), services))
|
Arc::new(Engine::new(Limits::default(), services))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ fn make_engine() -> Arc<Engine> {
|
|||||||
Arc::new(picloud_shared::NoopPubsubService),
|
Arc::new(picloud_shared::NoopPubsubService),
|
||||||
Arc::new(InMemorySecrets::default()),
|
Arc::new(InMemorySecrets::default()),
|
||||||
Arc::new(picloud_shared::NoopEmailService),
|
Arc::new(picloud_shared::NoopEmailService),
|
||||||
|
Arc::new(picloud_shared::NoopUsersService),
|
||||||
);
|
);
|
||||||
Arc::new(Engine::new(Limits::default(), services))
|
Arc::new(Engine::new(Limits::default(), services))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ fn make_engine() -> Arc<Engine> {
|
|||||||
Arc::new(FakeMintPubsub),
|
Arc::new(FakeMintPubsub),
|
||||||
Arc::new(picloud_shared::NoopSecretsService),
|
Arc::new(picloud_shared::NoopSecretsService),
|
||||||
Arc::new(picloud_shared::NoopEmailService),
|
Arc::new(picloud_shared::NoopEmailService),
|
||||||
|
Arc::new(picloud_shared::NoopUsersService),
|
||||||
);
|
);
|
||||||
Arc::new(Engine::new(Limits::default(), services))
|
Arc::new(Engine::new(Limits::default(), services))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
//! CRUD over `app_user_password_resets` (v1.1.8 commit 6).
|
//! CRUD over `app_user_password_resets` (v1.1.8 commit 6).
|
||||||
//!
|
//!
|
||||||
//! Same shape and one-shot semantics as
|
//! Same shape and one-shot semantics as `app_user_verification_repo`.
|
||||||
//! `app_user_verification_repo`. Kept as a separate repo so the
|
//! Kept as a separate repo so the distinct lifecycles (consume then
|
||||||
//! distinct lifecycles (consume + revoke-sessions for reset; consume
|
//! revoke-sessions for reset; consume then mark-email-verified for
|
||||||
//! + mark-email-verified for verification) stay obvious at the call
|
//! verification) stay obvious at the call site. A future v1.2 cleanup
|
||||||
//! site. A future v1.2 cleanup may merge them behind a `kind`
|
//! may merge them behind a `kind` discriminator if the duplication
|
||||||
//! discriminator if the duplication becomes load-bearing.
|
//! becomes load-bearing.
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ impl AppUserRepository for PostgresAppUserRepository {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut items: Vec<AppUserRow> = rows.into_iter().map(Into::into).collect();
|
let mut items: Vec<AppUserRow> = rows.into_iter().map(Into::into).collect();
|
||||||
let next_cursor = if items.len() as i64 > limit {
|
let next_cursor = if i64::try_from(items.len()).unwrap_or(i64::MAX) > limit {
|
||||||
let cursor_row = items.pop().expect("len > limit so there is a row");
|
let cursor_row = items.pop().expect("len > limit so there is a row");
|
||||||
Some(cursor_row.created_at)
|
Some(cursor_row.created_at)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -109,16 +109,14 @@ fn env_duration_hours(var: &str, default: Duration) -> Duration {
|
|||||||
std::env::var(var)
|
std::env::var(var)
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|s| s.parse::<u64>().ok())
|
.and_then(|s| s.parse::<u64>().ok())
|
||||||
.map(|h| Duration::from_secs(h * 3600))
|
.map_or(default, |h| Duration::from_secs(h * 3600))
|
||||||
.unwrap_or(default)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn env_duration_days(var: &str, default: Duration) -> Duration {
|
fn env_duration_days(var: &str, default: Duration) -> Duration {
|
||||||
std::env::var(var)
|
std::env::var(var)
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|s| s.parse::<u64>().ok())
|
.and_then(|s| s.parse::<u64>().ok())
|
||||||
.map(|d| Duration::from_secs(d * 24 * 3600))
|
.map_or(default, |d| Duration::from_secs(d * 24 * 3600))
|
||||||
.unwrap_or(default)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Postgres-backed `UsersService`.
|
/// Postgres-backed `UsersService`.
|
||||||
@@ -485,14 +483,11 @@ impl UsersService for UsersServiceImpl {
|
|||||||
.await?;
|
.await?;
|
||||||
// Both branches normalize the email so an attacker can't probe
|
// Both branches normalize the email so an attacker can't probe
|
||||||
// existence via "" / "x" / very-long-string differences.
|
// existence via "" / "x" / very-long-string differences.
|
||||||
let normalized = match validate_email(email) {
|
let Ok(normalized) = validate_email(email) else {
|
||||||
Ok(e) => e,
|
// Still run a dummy verify so the timing of an invalid
|
||||||
Err(_) => {
|
// email shape matches the timing of a legitimate miss.
|
||||||
// Still run a dummy verify so the timing of an invalid
|
let _ = verify_password(TIMING_FLAT_DUMMY_HASH, password);
|
||||||
// email shape matches the timing of a legitimate miss.
|
return Ok(None);
|
||||||
let _ = verify_password(TIMING_FLAT_DUMMY_HASH, password);
|
|
||||||
return Ok(None);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let creds = self
|
let creds = self
|
||||||
.users
|
.users
|
||||||
|
|||||||
Reference in New Issue
Block a user