From 1261fd5d7ff67c907c72fbbd6959d68bd7c8063b Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 22 Aug 2026 21:54:12 +0200 Subject: treewide: Upgrade and update dependencies `rusty_paseto` was left explicitly on v0.8 because the v0.10 is no longer compatible with `rusty_paserk`. --- crates/daemon/src/aclient/database/mod.rs | 24 ++++++++++++++++++------ crates/daemon/src/aclient/record/encryption.rs | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) (limited to 'crates/daemon/src/aclient') diff --git a/crates/daemon/src/aclient/database/mod.rs b/crates/daemon/src/aclient/database/mod.rs index f24eb777..7cee866e 100644 --- a/crates/daemon/src/aclient/database/mod.rs +++ b/crates/daemon/src/aclient/database/mod.rs @@ -3,7 +3,7 @@ use std::{path::Path, str::FromStr, time::Duration}; use fs_err::{self as fs}; use sql_builder::{SqlBuilder, SqlName}; use sqlx::{ - Result, Row, + AssertSqlSafe, Result, Row, sqlite::{SqliteConnectOptions, SqliteJournalMode, SqlitePool, SqliteRow, SqliteSynchronous}, }; use time::OffsetDateTime; @@ -56,8 +56,11 @@ impl ClientSqlite { async fn save_raw(tx: &mut sqlx::Transaction<'_, sqlx::Sqlite>, h: &History) -> Result<()> { sqlx::query( - "insert or ignore into history(id, timestamp, duration, exit, command, cwd, session, hostname, author, intent, deleted_at) - values(?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11)", + " + INSERT OR IGNORE + INTO history (id, timestamp, duration, exit, command, cwd, session, hostname, author, intent, deleted_at) + VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11) + ", ) .bind(h.id.to_string().as_str()) .bind(h.timestamp.unix_timestamp_nanos() as i64) @@ -156,12 +159,16 @@ impl ClientSqlite { } if let Some(max) = max { + let max: usize = max; query.limit(max); } let query = query.sql().expect("bug in list query. please report"); - let res = sqlx::query(&query) + // SAFETY: + // - The query is constructed via sql_bulider, and as such should be safe. + // - The only value, that is directly added to the query is a `usize`. + let res = sqlx::query(AssertSqlSafe(query)) .map(Self::query_history_inner) .fetch_all(&self.pool) .await?; @@ -177,11 +184,16 @@ impl ClientSqlite { debug!("listing history from {:?} to {:?}", from, to); let res = sqlx::query( - "select * from history where timestamp >= ?1 and timestamp <= ?2 order by timestamp asc", + " + SELECT * + FROM history + WHERE timestamp >= ?1 AND timestamp <= ?2 + ORDER BY timestamp ASC + ", ) .bind(from.unix_timestamp_nanos() as i64) .bind(to.unix_timestamp_nanos() as i64) - .map(Self::query_history_inner) + .map(Self::query_history_inner) .fetch_all(&self.pool) .await?; diff --git a/crates/daemon/src/aclient/record/encryption.rs b/crates/daemon/src/aclient/record/encryption.rs index 67f191e9..11de96d5 100644 --- a/crates/daemon/src/aclient/record/encryption.rs +++ b/crates/daemon/src/aclient/record/encryption.rs @@ -2,7 +2,7 @@ use base64::{Engine, engine::general_purpose}; use eyre::{Context, Result, ensure}; use rusty_paserk::{Key, KeyId, Local, PieWrappedKey}; use rusty_paseto::core::{ - ImplicitAssertion, Key as DataKey, Local as LocalPurpose, Paseto, PasetoNonce, Payload, V4, + ImplicitAssertion, Key as DataKey, Local as LocalPurpose, Paseto, PasetoNonce, Payload, V4 }; use serde::{Deserialize, Serialize}; use turtle_common::record::{ -- cgit v1.3.1