aboutsummaryrefslogtreecommitdiffstats
path: root/crates/daemon/src/aclient
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--crates/daemon/src/aclient/database/mod.rs24
-rw-r--r--crates/daemon/src/aclient/record/encryption.rs2
2 files changed, 19 insertions, 7 deletions
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::{