diff --git a/Cargo.toml b/Cargo.toml index 9aac95ec7..9f1316edc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ anyhow = "1" clap = { version = "4.5.23", features = ["derive", "env"] } serde_yaml = "0.9" regex = "1" -sqlx = { version = "0.8", features = ["runtime-tokio", "postgres", "chrono", "json", "uuid"] } +sqlx = { version = "0.9", features = ["runtime-tokio", "postgres", "chrono", "json", "uuid"] } tera = "2" hickory-resolver = { version = "0.26", default-features = false, features = ["tokio", "system-config"] } diff --git a/ares-cli/src/history/cost.rs b/ares-cli/src/history/cost.rs index fcc4b7d1c..2a36d77db 100644 --- a/ares-cli/src/history/cost.rs +++ b/ares-cli/src/history/cost.rs @@ -1,4 +1,5 @@ use anyhow::Result; +use sqlx::AssertSqlSafe; use chrono::Utc; use super::connect_postgres; @@ -36,7 +37,7 @@ pub(crate) async fn history_cost( bind_idx += 1; query.push_str(&format!(" ORDER BY started_at DESC LIMIT ${bind_idx}")); - let mut q = sqlx::query_as::<_, CostRow>(&query); + let mut q = sqlx::query_as::<_, CostRow>(AssertSqlSafe(query)); if let Some(ref d) = domain { q = q.bind(format!("%{d}%")); diff --git a/ares-cli/src/history/list.rs b/ares-cli/src/history/list.rs index 8ee154bd4..c5f7c3e40 100644 --- a/ares-cli/src/history/list.rs +++ b/ares-cli/src/history/list.rs @@ -1,4 +1,5 @@ use anyhow::Result; +use sqlx::AssertSqlSafe; use chrono::Utc; use super::connect_postgres; @@ -48,7 +49,7 @@ pub(crate) async fn history_list( bind_idx += 1; query.push_str(&format!(" ORDER BY started_at DESC LIMIT ${bind_idx}")); - let mut q = sqlx::query_as::<_, OperationRow>(&query); + let mut q = sqlx::query_as::<_, OperationRow>(AssertSqlSafe(query)); if let Some(ref d) = domain { q = q.bind(format!("%{d}%")); diff --git a/ares-cli/src/history/search.rs b/ares-cli/src/history/search.rs index 449c639e9..ed7352bbe 100644 --- a/ares-cli/src/history/search.rs +++ b/ares-cli/src/history/search.rs @@ -1,4 +1,5 @@ use anyhow::Result; +use sqlx::AssertSqlSafe; use super::connect_postgres; use super::types::{CredentialSearchRow, HashSearchRow}; @@ -40,7 +41,7 @@ pub(crate) async fn history_search_creds( bind_idx += 1; query.push_str(&format!(" ORDER BY c.created_at DESC LIMIT ${bind_idx}")); - let mut q = sqlx::query_as::<_, CredentialSearchRow>(&query); + let mut q = sqlx::query_as::<_, CredentialSearchRow>(AssertSqlSafe(query)); if let Some(ref d) = domain { q = q.bind(d); @@ -139,7 +140,7 @@ pub(crate) async fn history_search_hashes( bind_idx += 1; query.push_str(&format!(" ORDER BY h.created_at DESC LIMIT ${bind_idx}")); - let mut q = sqlx::query_as::<_, HashSearchRow>(&query); + let mut q = sqlx::query_as::<_, HashSearchRow>(AssertSqlSafe(query)); if let Some(ref d) = domain { q = q.bind(d); diff --git a/ares-core/src/persistent_store/queries/credentials.rs b/ares-core/src/persistent_store/queries/credentials.rs index 88356c7eb..4a65b8e1a 100644 --- a/ares-core/src/persistent_store/queries/credentials.rs +++ b/ares-core/src/persistent_store/queries/credentials.rs @@ -1,6 +1,7 @@ //! Credential and hash search queries across all operations. use anyhow::Result; +use sqlx::AssertSqlSafe; use super::rows::{CredentialRow, HashRow}; use super::HistoricalQueryService; @@ -201,14 +202,14 @@ impl HistoricalQueryService { // so we use query_scalar pattern with explicit bind count match bind_values.len() { 1 => { - sqlx::query_as::<_, HashRow>(&sql) + sqlx::query_as::<_, HashRow>(AssertSqlSafe(sql)) .bind(&bind_values[0]) .bind(limit) .fetch_all(&self.pool) .await? } 2 => { - sqlx::query_as::<_, HashRow>(&sql) + sqlx::query_as::<_, HashRow>(AssertSqlSafe(sql)) .bind(&bind_values[0]) .bind(&bind_values[1]) .bind(limit) @@ -216,7 +217,7 @@ impl HistoricalQueryService { .await? } 3 => { - sqlx::query_as::<_, HashRow>(&sql) + sqlx::query_as::<_, HashRow>(AssertSqlSafe(sql)) .bind(&bind_values[0]) .bind(&bind_values[1]) .bind(&bind_values[2])