Skip to content

Commit 737513c

Browse files
committed
improve: globalize deny(unsafe_code)
1 parent d888035 commit 737513c

File tree

14 files changed

+49
-32
lines changed

14 files changed

+49
-32
lines changed

crates/inferadb-control-api/src/handlers/auth.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -397,13 +397,13 @@ pub async fn logout(
397397
jar: CookieJar,
398398
) -> Result<(CookieJar, Json<LogoutResponse>)> {
399399
// Get session ID from cookie
400-
if let Some(cookie) = jar.get(SESSION_COOKIE_NAME) {
401-
if let Ok(session_id) = cookie.value().parse::<i64>() {
402-
let repos = RepositoryContext::new((*state.storage).clone());
403-
// Revoke session
404-
// Ignore errors if session doesn't exist
405-
let _ = repos.user_session.revoke(session_id).await;
406-
}
400+
if let Some(cookie) = jar.get(SESSION_COOKIE_NAME)
401+
&& let Ok(session_id) = cookie.value().parse::<i64>()
402+
{
403+
let repos = RepositoryContext::new((*state.storage).clone());
404+
// Revoke session
405+
// Ignore errors if session doesn't exist
406+
let _ = repos.user_session.revoke(session_id).await;
407407
}
408408

409409
// Remove session cookie

crates/inferadb-control-api/src/handlers/organizations.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -703,18 +703,17 @@ pub async fn create_invitation(
703703
}
704704

705705
// Check if user with this email already exists and is a member
706-
if let Some(existing_email) = repos.user_email.get_by_email(&payload.email).await? {
707-
if repos
706+
if let Some(existing_email) = repos.user_email.get_by_email(&payload.email).await?
707+
&& repos
708708
.org_member
709709
.get_by_org_and_user(org_ctx.organization_id, existing_email.user_id)
710710
.await?
711711
.is_some()
712-
{
713-
return Err(CoreError::AlreadyExists(
714-
"User is already a member of this organization".to_string(),
715-
)
716-
.into());
717-
}
712+
{
713+
return Err(CoreError::AlreadyExists(
714+
"User is already a member of this organization".to_string(),
715+
)
716+
.into());
718717
}
719718

720719
// Check for existing invitation

crates/inferadb-control-api/src/handlers/users.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ pub async fn delete_user(
9999
if membership.role == inferadb_control_core::entities::OrganizationRole::Owner {
100100
// Check if this user is the only owner
101101
let owner_count = repos.org_member.count_owners(membership.organization_id).await?;
102-
if owner_count <= 1 {
103-
if let Some(org) = repos.org.get(membership.organization_id).await? {
104-
return Err(CoreError::Validation(format!(
105-
"Cannot delete account while being the only owner of organization '{}'. Please transfer ownership or delete the organization first.",
106-
org.name
107-
))
108-
.into());
109-
}
102+
if owner_count <= 1
103+
&& let Some(org) = repos.org.get(membership.organization_id).await?
104+
{
105+
return Err(CoreError::Validation(format!(
106+
"Cannot delete account while being the only owner of organization '{}'. Please transfer ownership or delete the organization first.",
107+
org.name
108+
))
109+
.into());
110110
}
111111
}
112112
}

crates/inferadb-control-api/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// REST API handlers and routes
22

3+
#![deny(unsafe_code)]
4+
35
use std::sync::Arc;
46

57
use inferadb_control_core::{ControlConfig, startup};

crates/inferadb-control-api/src/middleware/engine_auth.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ impl JwksCache {
7676
// Check cache first
7777
{
7878
let cache = self.jwks.read().await;
79-
if let Some((jwks, cached_at)) = cache.as_ref() {
80-
if cached_at.elapsed() < self.ttl {
81-
return Ok(jwks.clone());
82-
}
79+
if let Some((jwks, cached_at)) = cache.as_ref()
80+
&& cached_at.elapsed() < self.ttl
81+
{
82+
return Ok(jwks.clone());
8383
}
8484
}
8585

crates/inferadb-control-config/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
//! The control service reads its configuration from the `control:` section. Any `engine:` section
2727
//! is ignored by control (and vice versa when engine reads the same file).
2828
29+
#![deny(unsafe_code)]
30+
2931
pub mod refresh;
3032

3133
use std::path::Path;

crates/inferadb-control-const/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
//! - Business limit constants (max sessions, passkeys, organizations)
99
//! - Rate limit category identifiers
1010
11+
#![deny(unsafe_code)]
12+
1113
pub mod auth;
1214
pub mod duration;
1315
pub mod limits;

crates/inferadb-control-core/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(unsafe_code)]
2+
13
// Re-export configuration from dedicated config crate
24
pub use inferadb_control_config as config;
35
pub use inferadb_control_config::{ConfigRefresher, ControlConfig};

crates/inferadb-control-discovery/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
//! - **Static**: Use service URL directly (no discovery)
1010
//! - **Kubernetes**: Discover pod IPs from Kubernetes Endpoints API
1111
12+
#![deny(unsafe_code)]
13+
1214
use std::fmt;
1315

1416
use async_trait::async_trait;

crates/inferadb-control-engine-client/src/client.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,11 @@ impl EngineClient {
230230
// Check cache first
231231
{
232232
let cache = self.endpoint_cache.read();
233-
if let Some(cached) = cache.as_ref() {
234-
if cached.is_valid() {
235-
debug!(count = cached.endpoints.len(), "Using cached engine endpoints");
236-
return cached.endpoints.clone();
237-
}
233+
if let Some(cached) = cache.as_ref()
234+
&& cached.is_valid()
235+
{
236+
debug!(count = cached.endpoints.len(), "Using cached engine endpoints");
237+
return cached.endpoints.clone();
238238
}
239239
}
240240

0 commit comments

Comments
 (0)