Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }

Expand Down
3 changes: 2 additions & 1 deletion ares-cli/src/history/cost.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::Result;
use sqlx::AssertSqlSafe;
use chrono::Utc;

use super::connect_postgres;
Expand Down Expand Up @@ -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}%"));
Expand Down
3 changes: 2 additions & 1 deletion ares-cli/src/history/list.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::Result;
use sqlx::AssertSqlSafe;
use chrono::Utc;

use super::connect_postgres;
Expand Down Expand Up @@ -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}%"));
Expand Down
5 changes: 3 additions & 2 deletions ares-cli/src/history/search.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::Result;
use sqlx::AssertSqlSafe;

use super::connect_postgres;
use super::types::{CredentialSearchRow, HashSearchRow};
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions ares-core/src/persistent_store/queries/credentials.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -201,22 +202,22 @@ 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)
.fetch_all(&self.pool)
.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])
Expand Down
Loading