aboutsummaryrefslogtreecommitdiffstats
path: root/crates/atuin-client
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@atuin.sh>2025-03-19 12:44:20 +0000
committerGitHub <noreply@github.com>2025-03-19 12:44:20 +0000
commit14ec768b4520d4fc34dbf24e663ea7db940c18b7 (patch)
treea37db707ab8676cad5b3e6ca47af3f2997958906 /crates/atuin-client
parentfeat: Use readline binding for ctrl-a when it is not the prefix (#2626) (diff)
downloadatuin-14ec768b4520d4fc34dbf24e663ea7db940c18b7.zip
chore: migrate to rust 2024 (#2635)
* chore: upgrade to 2024 edition * ugh unsafe * format * nixxxxxxxxxxx why
Diffstat (limited to 'crates/atuin-client')
-rw-r--r--crates/atuin-client/Cargo.toml2
-rw-r--r--crates/atuin-client/src/api_client.rs26
-rw-r--r--crates/atuin-client/src/database.rs14
-rw-r--r--crates/atuin-client/src/encryption.rs16
-rw-r--r--crates/atuin-client/src/history.rs4
-rw-r--r--crates/atuin-client/src/history/store.rs17
-rw-r--r--crates/atuin-client/src/import/bash.rs12
-rw-r--r--crates/atuin-client/src/import/fish.rs8
-rw-r--r--crates/atuin-client/src/import/mod.rs2
-rw-r--r--crates/atuin-client/src/import/nu.rs4
-rw-r--r--crates/atuin-client/src/import/nu_histdb.rs4
-rw-r--r--crates/atuin-client/src/import/replxx.rs15
-rw-r--r--crates/atuin-client/src/import/resh.rs4
-rw-r--r--crates/atuin-client/src/import/xonsh.rs6
-rw-r--r--crates/atuin-client/src/import/xonsh_sqlite.rs8
-rw-r--r--crates/atuin-client/src/import/zsh.rs6
-rw-r--r--crates/atuin-client/src/import/zsh_histdb.rs8
-rw-r--r--crates/atuin-client/src/kv.rs4
-rw-r--r--crates/atuin-client/src/lib.rs2
-rw-r--r--crates/atuin-client/src/login.rs35
-rw-r--r--crates/atuin-client/src/record/encryption.rs4
-rw-r--r--crates/atuin-client/src/record/sqlite_store.rs8
-rw-r--r--crates/atuin-client/src/record/sync.rs2
-rw-r--r--crates/atuin-client/src/secrets.rs36
-rw-r--r--crates/atuin-client/src/settings.rs15
-rw-r--r--crates/atuin-client/src/sync.rs17
-rw-r--r--crates/atuin-client/src/theme.rs5
27 files changed, 163 insertions, 121 deletions
diff --git a/crates/atuin-client/Cargo.toml b/crates/atuin-client/Cargo.toml
index cd32cc4b..568de4e0 100644
--- a/crates/atuin-client/Cargo.toml
+++ b/crates/atuin-client/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "atuin-client"
-edition = "2021"
+edition = "2024"
description = "client library for atuin"
rust-version = { workspace = true }
diff --git a/crates/atuin-client/src/api_client.rs b/crates/atuin-client/src/api_client.rs
index 19820b29..0bd16c50 100644
--- a/crates/atuin-client/src/api_client.rs
+++ b/crates/atuin-client/src/api_client.rs
@@ -2,13 +2,17 @@ use std::collections::HashMap;
use std::env;
use std::time::Duration;
-use eyre::{bail, Result};
+use eyre::{Result, bail};
use reqwest::{
- header::{HeaderMap, AUTHORIZATION, USER_AGENT},
Response, StatusCode, Url,
+ header::{AUTHORIZATION, HeaderMap, USER_AGENT},
};
use atuin_common::{
+ api::{ATUIN_CARGO_VERSION, ATUIN_HEADER_VERSION, ATUIN_VERSION},
+ record::{EncryptedData, HostId, Record, RecordIdx},
+};
+use atuin_common::{
api::{
AddHistoryRequest, ChangePasswordRequest, CountResponse, DeleteHistoryRequest,
ErrorResponse, LoginRequest, LoginResponse, MeResponse, RegisterResponse,
@@ -17,14 +21,10 @@ use atuin_common::{
},
record::RecordStatus,
};
-use atuin_common::{
- api::{ATUIN_CARGO_VERSION, ATUIN_HEADER_VERSION, ATUIN_VERSION},
- record::{EncryptedData, HostId, Record, RecordIdx},
-};
use semver::Version;
-use time::format_description::well_known::Rfc3339;
use time::OffsetDateTime;
+use time::format_description::well_known::Rfc3339;
use crate::{history::History, sync::hash_str, utils::get_host_user};
@@ -126,7 +126,9 @@ pub fn ensure_version(response: &Response) -> Result<bool> {
// If the client is newer than the server
if version.major < ATUIN_VERSION.major {
- println!("Atuin version mismatch! In order to successfully sync, the server needs to run a newer version of Atuin");
+ println!(
+ "Atuin version mismatch! In order to successfully sync, the server needs to run a newer version of Atuin"
+ );
println!("Client: {}", ATUIN_CARGO_VERSION);
println!("Server: {}", version);
@@ -157,10 +159,14 @@ async fn handle_resp_error(resp: Response) -> Result<Response> {
bail!("Invalid request to the service: {status} - {reason}.")
}
- bail!("There was an error with the atuin sync service, server error {status}: {reason}.\nIf the problem persists, contact the host")
+ bail!(
+ "There was an error with the atuin sync service, server error {status}: {reason}.\nIf the problem persists, contact the host"
+ )
}
- bail!("There was an error with the atuin sync service: Status {status:?}.\nIf the problem persists, contact the host")
+ bail!(
+ "There was an error with the atuin sync service: Status {status:?}.\nIf the problem persists, contact the host"
+ )
}
Ok(resp)
diff --git a/crates/atuin-client/src/database.rs b/crates/atuin-client/src/database.rs
index b64ff4ce..fd0284ba 100644
--- a/crates/atuin-client/src/database.rs
+++ b/crates/atuin-client/src/database.rs
@@ -10,14 +10,14 @@ use async_trait::async_trait;
use atuin_common::utils;
use fs_err as fs;
use itertools::Itertools;
-use rand::{distributions::Alphanumeric, Rng};
-use sql_builder::{bind::Bind, esc, quote, SqlBuilder, SqlName};
+use rand::{Rng, distributions::Alphanumeric};
+use sql_builder::{SqlBuilder, SqlName, bind::Bind, esc, quote};
use sqlx::{
+ Result, Row,
sqlite::{
SqliteConnectOptions, SqliteJournalMode, SqlitePool, SqlitePoolOptions, SqliteRow,
SqliteSynchronous,
},
- Result, Row,
};
use time::OffsetDateTime;
@@ -55,7 +55,9 @@ pub struct OptFilters {
pub fn current_context() -> Context {
let Ok(session) = env::var("ATUIN_SESSION") else {
- eprintln!("ERROR: Failed to find $ATUIN_SESSION in the environment. Check that you have correctly set up your shell.");
+ eprintln!(
+ "ERROR: Failed to find $ATUIN_SESSION in the environment. Check that you have correctly set up your shell."
+ );
std::process::exit(1);
};
let hostname = get_host_user();
@@ -131,7 +133,9 @@ impl Sqlite {
debug!("opening sqlite database at {:?}", path);
if utils::broken_symlink(path) {
- eprintln!("Atuin: Sqlite db path ({path:?}) is a broken symlink. Unable to read or create replacement.");
+ eprintln!(
+ "Atuin: Sqlite db path ({path:?}) is a broken symlink. Unable to read or create replacement."
+ );
std::process::exit(1);
}
diff --git a/crates/atuin-client/src/encryption.rs b/crates/atuin-client/src/encryption.rs
index 02e5e3fb..a1e844e7 100644
--- a/crates/atuin-client/src/encryption.rs
+++ b/crates/atuin-client/src/encryption.rs
@@ -10,17 +10,17 @@
use std::{io::prelude::*, path::PathBuf};
-use base64::prelude::{Engine, BASE64_STANDARD};
+use base64::prelude::{BASE64_STANDARD, Engine};
pub use crypto_secretbox::Key;
use crypto_secretbox::{
- aead::{Nonce, OsRng},
AeadCore, AeadInPlace, KeyInit, XSalsa20Poly1305,
+ aead::{Nonce, OsRng},
};
-use eyre::{bail, ensure, eyre, Context, Result};
+use eyre::{Context, Result, bail, ensure, eyre};
use fs_err as fs;
-use rmp::{decode::Bytes, Marker};
+use rmp::{Marker, decode::Bytes};
use serde::{Deserialize, Serialize};
-use time::{format_description::well_known::Rfc3339, macros::format_description, OffsetDateTime};
+use time::{OffsetDateTime, format_description::well_known::Rfc3339, macros::format_description};
use crate::{history::History, settings::Settings};
@@ -265,9 +265,9 @@ fn error_report<E: std::fmt::Debug>(err: E) -> eyre::Report {
#[cfg(test)]
mod test {
- use crypto_secretbox::{aead::OsRng, KeyInit, XSalsa20Poly1305};
+ use crypto_secretbox::{KeyInit, XSalsa20Poly1305, aead::OsRng};
use pretty_assertions::assert_eq;
- use time::{macros::datetime, OffsetDateTime};
+ use time::{OffsetDateTime, macros::datetime};
use crate::history::History;
@@ -392,7 +392,7 @@ mod test {
#[test]
fn key_encodings() {
- use super::{decode_key, encode_key, Key};
+ use super::{Key, decode_key, encode_key};
// a history of our key encodings.
// v11.0.0 xCAbWypb0msJ2Kq+8j4GVEWUlDX7deKnrTRSIopuqXxc5Q==
diff --git a/crates/atuin-client/src/history.rs b/crates/atuin-client/src/history.rs
index 6469740e..d9d5a203 100644
--- a/crates/atuin-client/src/history.rs
+++ b/crates/atuin-client/src/history.rs
@@ -1,13 +1,13 @@
use core::fmt::Formatter;
use rmp::decode::ValueReadError;
-use rmp::{decode::Bytes, Marker};
+use rmp::{Marker, decode::Bytes};
use std::env;
use std::fmt::Display;
use atuin_common::record::DecryptedData;
use atuin_common::utils::uuid_v7;
-use eyre::{bail, eyre, Result};
+use eyre::{Result, bail, eyre};
use crate::secrets::SECRET_PATTERNS_RE;
use crate::settings::Settings;
diff --git a/crates/atuin-client/src/history/store.rs b/crates/atuin-client/src/history/store.rs
index b0341a26..b8ac6ff4 100644
--- a/crates/atuin-client/src/history/store.rs
+++ b/crates/atuin-client/src/history/store.rs
@@ -1,16 +1,16 @@
use std::{collections::HashSet, fmt::Write, time::Duration};
-use eyre::{bail, eyre, Result};
+use eyre::{Result, bail, eyre};
use indicatif::{ProgressBar, ProgressState, ProgressStyle};
use rmp::decode::Bytes;
use crate::{
- database::{current_context, Database},
+ database::{Database, current_context},
record::{encryption::PASETO_V4, sqlite_store::SqliteStore, store::Store},
};
use atuin_common::record::{DecryptedData, Host, HostId, Record, RecordId, RecordIdx};
-use super::{History, HistoryId, HISTORY_TAG, HISTORY_VERSION};
+use super::{HISTORY_TAG, HISTORY_VERSION, History, HistoryId};
#[derive(Debug, Clone)]
pub struct HistoryStore {
@@ -246,10 +246,11 @@ impl HistoryStore {
for id in ids {
let record = self.store.get(*id).await;
- let record = if let Ok(record) = record {
- record
- } else {
- continue;
+ let record = match record {
+ Ok(record) => record,
+ _ => {
+ continue;
+ }
};
if record.tag != HISTORY_TAG {
@@ -342,7 +343,7 @@ mod tests {
use atuin_common::record::DecryptedData;
use time::macros::datetime;
- use crate::history::{store::HistoryRecord, HISTORY_VERSION};
+ use crate::history::{HISTORY_VERSION, store::HistoryRecord};
use super::History;
diff --git a/crates/atuin-client/src/import/bash.rs b/crates/atuin-client/src/import/bash.rs
index ade1f751..93d1fcf5 100644
--- a/crates/atuin-client/src/import/bash.rs
+++ b/crates/atuin-client/src/import/bash.rs
@@ -2,11 +2,11 @@ use std::{path::PathBuf, str};
use async_trait::async_trait;
use directories::UserDirs;
-use eyre::{eyre, Result};
+use eyre::{Result, eyre};
use itertools::Itertools;
use time::{Duration, OffsetDateTime};
-use super::{get_histpath, unix_byte_lines, Importer, Loader};
+use super::{Importer, Loader, get_histpath, unix_byte_lines};
use crate::history::History;
use crate::import::read_to_end;
@@ -73,7 +73,9 @@ impl Importer for Bash {
LineType::Empty => {} // do nothing
LineType::Timestamp(t) => {
if t < next_timestamp {
- warn!("Time reversal detected in Bash history! Commands may be ordered incorrectly.");
+ warn!(
+ "Time reversal detected in Bash history! Commands may be ordered incorrectly."
+ );
}
next_timestamp = t;
}
@@ -126,9 +128,9 @@ fn try_parse_line_as_timestamp(line: &str) -> Option<OffsetDateTime> {
mod test {
use std::cmp::Ordering;
- use itertools::{assert_equal, Itertools};
+ use itertools::{Itertools, assert_equal};
- use crate::import::{tests::TestLoader, Importer};
+ use crate::import::{Importer, tests::TestLoader};
use super::Bash;
diff --git a/crates/atuin-client/src/import/fish.rs b/crates/atuin-client/src/import/fish.rs
index 714b2d01..9fcf624c 100644
--- a/crates/atuin-client/src/import/fish.rs
+++ b/crates/atuin-client/src/import/fish.rs
@@ -5,10 +5,10 @@ use std::path::PathBuf;
use async_trait::async_trait;
use directories::BaseDirs;
-use eyre::{eyre, Result};
+use eyre::{Result, eyre};
use time::OffsetDateTime;
-use super::{unix_byte_lines, Importer, Loader};
+use super::{Importer, Loader, unix_byte_lines};
use crate::history::History;
use crate::import::read_to_end;
@@ -110,7 +110,7 @@ impl Importer for Fish {
#[cfg(test)]
mod test {
- use crate::import::{tests::TestLoader, Importer};
+ use crate::import::{Importer, tests::TestLoader};
use super::Fish;
@@ -160,7 +160,7 @@ ERROR
// simple wrapper for fish history entry
macro_rules! fishtory {
- ($timestamp:expr, $command:expr) => {
+ ($timestamp:expr_2021, $command:expr_2021) => {
let h = history.next().expect("missing entry in history");
assert_eq!(h.command.as_str(), $command);
assert_eq!(h.timestamp.unix_timestamp(), $timestamp);
diff --git a/crates/atuin-client/src/import/mod.rs b/crates/atuin-client/src/import/mod.rs
index eb3ce045..1d4f29f3 100644
--- a/crates/atuin-client/src/import/mod.rs
+++ b/crates/atuin-client/src/import/mod.rs
@@ -3,7 +3,7 @@ use std::io::Read;
use std::path::PathBuf;
use async_trait::async_trait;
-use eyre::{bail, Result};
+use eyre::{Result, bail};
use memchr::Memchr;
use crate::history::History;
diff --git a/crates/atuin-client/src/import/nu.rs b/crates/atuin-client/src/import/nu.rs
index a45d83c5..cae90ac4 100644
--- a/crates/atuin-client/src/import/nu.rs
+++ b/crates/atuin-client/src/import/nu.rs
@@ -5,10 +5,10 @@ use std::path::PathBuf;
use async_trait::async_trait;
use directories::BaseDirs;
-use eyre::{eyre, Result};
+use eyre::{Result, eyre};
use time::OffsetDateTime;
-use super::{unix_byte_lines, Importer, Loader};
+use super::{Importer, Loader, unix_byte_lines};
use crate::history::History;
use crate::import::read_to_end;
diff --git a/crates/atuin-client/src/import/nu_histdb.rs b/crates/atuin-client/src/import/nu_histdb.rs
index f0e8e95c..a13cb2b4 100644
--- a/crates/atuin-client/src/import/nu_histdb.rs
+++ b/crates/atuin-client/src/import/nu_histdb.rs
@@ -5,8 +5,8 @@ use std::path::PathBuf;
use async_trait::async_trait;
use directories::BaseDirs;
-use eyre::{eyre, Result};
-use sqlx::{sqlite::SqlitePool, Pool};
+use eyre::{Result, eyre};
+use sqlx::{Pool, sqlite::SqlitePool};
use time::{Duration, OffsetDateTime};
use super::Importer;
diff --git a/crates/atuin-client/src/import/replxx.rs b/crates/atuin-client/src/import/replxx.rs
index b73522ce..e1590c69 100644
--- a/crates/atuin-client/src/import/replxx.rs
+++ b/crates/atuin-client/src/import/replxx.rs
@@ -2,10 +2,10 @@ use std::{path::PathBuf, str};
use async_trait::async_trait;
use directories::UserDirs;
-use eyre::{eyre, Result};
-use time::{macros::format_description, OffsetDateTime, PrimitiveDateTime};
+use eyre::{Result, eyre};
+use time::{OffsetDateTime, PrimitiveDateTime, macros::format_description};
-use super::{get_histpath, unix_byte_lines, Importer, Loader};
+use super::{Importer, Loader, get_histpath, unix_byte_lines};
use crate::history::History;
use crate::import::read_to_end;
@@ -72,7 +72,7 @@ fn try_parse_line_as_timestamp(line: &str) -> Option<OffsetDateTime> {
#[cfg(test)]
mod test {
- use crate::import::{tests::TestLoader, Importer};
+ use crate::import::{Importer, tests::TestLoader};
use super::Replxx;
@@ -100,7 +100,7 @@ CREATE TABLE test( stamp DateTime('UTC'))ENGINE = MergeTreePARTITION BY toDat
// simple wrapper for replxx history entry
macro_rules! history {
- ($timestamp:expr, $command:expr) => {
+ ($timestamp:expr_2021, $command:expr_2021) => {
let h = history.next().expect("missing entry in history");
assert_eq!(h.command.as_str(), $command);
assert_eq!(h.timestamp.unix_timestamp(), $timestamp);
@@ -114,6 +114,9 @@ CREATE TABLE test( stamp DateTime('UTC'))ENGINE = MergeTreePARTITION BY toDat
history!(1707603396, "select * from numbers(10)");
history!(1707603401, "select * from system.numbers");
history!(1707603568, "select 1");
- history!(1708600533, "CREATE TABLE test\n( stamp DateTime('UTC'))\nENGINE = MergeTree\nPARTITION BY toDate(stamp)\norder by tuple() as select toDateTime('2020-01-01')+number*60 from numbers(80000);");
+ history!(
+ 1708600533,
+ "CREATE TABLE test\n( stamp DateTime('UTC'))\nENGINE = MergeTree\nPARTITION BY toDate(stamp)\norder by tuple() as select toDateTime('2020-01-01')+number*60 from numbers(80000);"
+ );
}
}
diff --git a/crates/atuin-client/src/import/resh.rs b/crates/atuin-client/src/import/resh.rs
index 396d11fd..1be23396 100644
--- a/crates/atuin-client/src/import/resh.rs
+++ b/crates/atuin-client/src/import/resh.rs
@@ -2,13 +2,13 @@ use std::path::PathBuf;
use async_trait::async_trait;
use directories::UserDirs;
-use eyre::{eyre, Result};
+use eyre::{Result, eyre};
use serde::Deserialize;
use atuin_common::utils::uuid_v7;
use time::OffsetDateTime;
-use super::{get_histpath, unix_byte_lines, Importer, Loader};
+use super::{Importer, Loader, get_histpath, unix_byte_lines};
use crate::history::History;
use crate::import::read_to_end;
diff --git a/crates/atuin-client/src/import/xonsh.rs b/crates/atuin-client/src/import/xonsh.rs
index 19ce4cf6..d041c648 100644
--- a/crates/atuin-client/src/import/xonsh.rs
+++ b/crates/atuin-client/src/import/xonsh.rs
@@ -4,13 +4,13 @@ use std::path::{Path, PathBuf};
use async_trait::async_trait;
use directories::BaseDirs;
-use eyre::{eyre, Result};
+use eyre::{Result, eyre};
use serde::Deserialize;
use time::OffsetDateTime;
-use uuid::timestamp::{context::NoContext, Timestamp};
use uuid::Uuid;
+use uuid::timestamp::{Timestamp, context::NoContext};
-use super::{get_histpath, Importer, Loader};
+use super::{Importer, Loader, get_histpath};
use crate::history::History;
use crate::utils::get_host_user;
diff --git a/crates/atuin-client/src/import/xonsh_sqlite.rs b/crates/atuin-client/src/import/xonsh_sqlite.rs
index 2817dc63..1b8d76fc 100644
--- a/crates/atuin-client/src/import/xonsh_sqlite.rs
+++ b/crates/atuin-client/src/import/xonsh_sqlite.rs
@@ -3,14 +3,14 @@ use std::path::PathBuf;
use async_trait::async_trait;
use directories::BaseDirs;
-use eyre::{eyre, Result};
+use eyre::{Result, eyre};
use futures::TryStreamExt;
-use sqlx::{sqlite::SqlitePool, FromRow, Row};
+use sqlx::{FromRow, Row, sqlite::SqlitePool};
use time::OffsetDateTime;
-use uuid::timestamp::{context::NoContext, Timestamp};
use uuid::Uuid;
+use uuid::timestamp::{Timestamp, context::NoContext};
-use super::{get_histpath, Importer, Loader};
+use super::{Importer, Loader, get_histpath};
use crate::history::History;
use crate::utils::get_host_user;
diff --git a/crates/atuin-client/src/import/zsh.rs b/crates/atuin-client/src/import/zsh.rs
index 07785967..f4b83cac 100644
--- a/crates/atuin-client/src/import/zsh.rs
+++ b/crates/atuin-client/src/import/zsh.rs
@@ -6,10 +6,10 @@ use std::path::PathBuf;
use async_trait::async_trait;
use directories::UserDirs;
-use eyre::{eyre, Result};
+use eyre::{Result, eyre};
use time::OffsetDateTime;
-use super::{get_histpath, unix_byte_lines, Importer, Loader};
+use super::{Importer, Loader, get_histpath, unix_byte_lines};
use crate::history::History;
use crate::import::read_to_end;
@@ -38,7 +38,7 @@ fn default_histpath() -> Result<PathBuf> {
None => {
break Err(eyre!(
"Could not find history file. Try setting and exporting $HISTFILE"
- ))
+ ));
}
}
}
diff --git a/crates/atuin-client/src/import/zsh_histdb.rs b/crates/atuin-client/src/import/zsh_histdb.rs
index eb72baa3..cac85566 100644
--- a/crates/atuin-client/src/import/zsh_histdb.rs
+++ b/crates/atuin-client/src/import/zsh_histdb.rs
@@ -38,8 +38,8 @@ use std::path::{Path, PathBuf};
use async_trait::async_trait;
use atuin_common::utils::uuid_v7;
use directories::UserDirs;
-use eyre::{eyre, Result};
-use sqlx::{sqlite::SqlitePool, Pool};
+use eyre::{Result, eyre};
+use sqlx::{Pool, sqlite::SqlitePool};
use time::PrimitiveDateTime;
use super::Importer;
@@ -178,10 +178,12 @@ mod test {
use sqlx::sqlite::SqlitePoolOptions;
use std::env;
#[tokio::test(flavor = "multi_thread")]
+ #[allow(unsafe_code)]
async fn test_env_vars() {
let test_env_db = "nonstd-zsh-history.db";
let key = "HISTDB_FILE";
- env::set_var(key, test_env_db);
+ // TODO: Audit that the environment access only happens in single-threaded code.
+ unsafe { env::set_var(key, test_env_db) };
// test the env got set
assert_eq!(env::var(key).unwrap(), test_env_db.to_string());
diff --git a/crates/atuin-client/src/kv.rs b/crates/atuin-client/src/kv.rs
index 6c522a0e..530b58b7 100644
--- a/crates/atuin-client/src/kv.rs
+++ b/crates/atuin-client/src/kv.rs
@@ -1,7 +1,7 @@
use std::collections::BTreeMap;
use atuin_common::record::{DecryptedData, Host, HostId};
-use eyre::{bail, ensure, eyre, Result};
+use eyre::{Result, bail, ensure, eyre};
use serde::Deserialize;
use crate::record::encryption::PASETO_V4;
@@ -200,7 +200,7 @@ mod tests {
use crate::record::sqlite_store::SqliteStore;
use crate::settings::test_local_timeout;
- use super::{KvRecord, KvStore, KV_VERSION};
+ use super::{KV_VERSION, KvRecord, KvStore};
#[test]
fn encode_decode() {
diff --git a/crates/atuin-client/src/lib.rs b/crates/atuin-client/src/lib.rs
index d0f6ee73..99640682 100644
--- a/crates/atuin-client/src/lib.rs
+++ b/crates/atuin-client/src/lib.rs
@@ -1,4 +1,4 @@
-#![forbid(unsafe_code)]
+#![deny(unsafe_code)]
#[macro_use]
extern crate log;
diff --git a/crates/atuin-client/src/login.rs b/crates/atuin-client/src/login.rs
index 05303464..78168c7e 100644
--- a/crates/atuin-client/src/login.rs
+++ b/crates/atuin-client/src/login.rs
@@ -1,13 +1,13 @@
use std::path::PathBuf;
use atuin_common::api::LoginRequest;
-use eyre::{bail, Context, Result};
+use eyre::{Context, Result, bail};
use tokio::fs::File;
use tokio::io::AsyncWriteExt;
use crate::{
api_client,
- encryption::{decode_key, encode_key, load_key, Key},
+ encryption::{Key, decode_key, encode_key, load_key},
record::{sqlite_store::SqliteStore, store::Store},
settings::Settings,
};
@@ -23,22 +23,25 @@ pub async fn login(
let key = match bip39::Mnemonic::from_phrase(&key, bip39::Language::English) {
Ok(mnemonic) => encode_key(Key::from_slice(mnemonic.entropy()))?,
Err(err) => {
- if let Some(err) = err.downcast_ref::<bip39::ErrorKind>() {
- match err {
- // assume they copied in the base64 key
- bip39::ErrorKind::InvalidWord => key,
- bip39::ErrorKind::InvalidChecksum => {
- bail!("key mnemonic was not valid")
- }
- bip39::ErrorKind::InvalidKeysize(_)
- | bip39::ErrorKind::InvalidWordLength(_)
- | bip39::ErrorKind::InvalidEntropyLength(_, _) => {
- bail!("key was not the correct length")
+ match err.downcast_ref::<bip39::ErrorKind>() {
+ Some(err) => {
+ match err {
+ // assume they copied in the base64 key
+ bip39::ErrorKind::InvalidWord => key,
+ bip39::ErrorKind::InvalidChecksum => {
+ bail!("key mnemonic was not valid")
+ }
+ bip39::ErrorKind::InvalidKeysize(_)
+ | bip39::ErrorKind::InvalidWordLength(_)
+ | bip39::ErrorKind::InvalidEntropyLength(_, _) => {
+ bail!("key was not the correct length")
+ }
}
}
- } else {
- // unknown error. assume they copied the base64 key
- key
+ _ => {
+ // unknown error. assume they copied the base64 key
+ key
+ }
}
}
};
diff --git a/crates/atuin-client/src/record/encryption.rs b/crates/atuin-client/src/record/encryption.rs
index 3ad3be66..176d75f5 100644
--- a/crates/atuin-client/src/record/encryption.rs
+++ b/crates/atuin-client/src/record/encryption.rs
@@ -1,8 +1,8 @@
use atuin_common::record::{
AdditionalData, DecryptedData, EncryptedData, Encryption, HostId, RecordId, RecordIdx,
};
-use base64::{engine::general_purpose, Engine};
-use eyre::{ensure, Context, Result};
+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,
diff --git a/crates/atuin-client/src/record/sqlite_store.rs b/crates/atuin-client/src/record/sqlite_store.rs
index c42476d4..a3e7228b 100644
--- a/crates/atuin-client/src/record/sqlite_store.rs
+++ b/crates/atuin-client/src/record/sqlite_store.rs
@@ -6,12 +6,12 @@ use std::str::FromStr;
use std::{path::Path, time::Duration};
use async_trait::async_trait;
-use eyre::{eyre, Result};
+use eyre::{Result, eyre};
use fs_err as fs;
use sqlx::{
- sqlite::{SqliteConnectOptions, SqliteJournalMode, SqlitePool, SqlitePoolOptions, SqliteRow},
Row,
+ sqlite::{SqliteConnectOptions, SqliteJournalMode, SqlitePool, SqlitePoolOptions, SqliteRow},
};
use atuin_common::record::{
@@ -35,7 +35,9 @@ impl SqliteStore {
debug!("opening sqlite database at {:?}", path);
if utils::broken_symlink(path) {
- eprintln!("Atuin: Sqlite db path ({path:?}) is a broken symlink. Unable to read or create replacement.");
+ eprintln!(
+ "Atuin: Sqlite db path ({path:?}) is a broken symlink. Unable to read or create replacement."
+ );
std::process::exit(1);
}
diff --git a/crates/atuin-client/src/record/sync.rs b/crates/atuin-client/src/record/sync.rs
index e8d0fbf7..1c6b0e01 100644
--- a/crates/atuin-client/src/record/sync.rs
+++ b/crates/atuin-client/src/record/sync.rs
@@ -133,7 +133,7 @@ pub async fn operations(
msg: String::from(
"diff has nothing for local or remote - (host, tag) does not exist",
),
- })
+ });
}
};
diff --git a/crates/atuin-client/src/secrets.rs b/crates/atuin-client/src/secrets.rs
index e249910d..25e8db9a 100644
--- a/crates/atuin-client/src/secrets.rs
+++ b/crates/atuin-client/src/secrets.rs
@@ -38,7 +38,9 @@ pub static SECRET_PATTERNS: &[(&str, &str, TestValue)] = &[
(
"Atuin login",
r"atuin\s+login",
- TestValue::Single("atuin login -u mycoolusername -p mycoolpassword -k \"lots of random words\""),
+ TestValue::Single(
+ "atuin login -u mycoolusername -p mycoolpassword -k \"lots of random words\"",
+ ),
),
(
"GitHub PAT (old)",
@@ -51,32 +53,34 @@ pub static SECRET_PATTERNS: &[(&str, &str, TestValue)] = &[
TestValue::Multiple(&[
"gh1_1234567890abcdefghijk_1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklm",
"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", // also legit, also expired
- ])
+ ]),
),
(
"GitHub OAuth Access Token",
"gho_[A-Za-z0-9]{36}",
- TestValue::Single("gho_1234567890abcdefghijklmnopqrstuvwx000"), // not a real token
+ TestValue::Single("gho_1234567890abcdefghijklmnopqrstuvwx000"), // not a real token
),
(
"GitHub OAuth Access Token (user)",
"ghu_[A-Za-z0-9]{36}",
- TestValue::Single("ghu_1234567890abcdefghijklmnopqrstuvwx000"), // not a real token
+ TestValue::Single("ghu_1234567890abcdefghijklmnopqrstuvwx000"), // not a real token
),
(
"GitHub App Installation Access Token",
"ghs_[A-Za-z0-9]{36}",
- TestValue::Single("ghs_1234567890abcdefghijklmnopqrstuvwx000"), // not a real token
+ TestValue::Single("ghs_1234567890abcdefghijklmnopqrstuvwx000"), // not a real token
),
(
"GitHub Refresh Token",
"ghr_[A-Za-z0-9]{76}",
- TestValue::Single("ghr_1234567890abcdefghijklmnopqrstuvwx1234567890abcdefghijklmnopqrstuvwx1234567890abcdefghijklmnopqrstuvwx"), // not a real token
+ TestValue::Single(
+ "ghr_1234567890abcdefghijklmnopqrstuvwx1234567890abcdefghijklmnopqrstuvwx1234567890abcdefghijklmnopqrstuvwx",
+ ), // not a real token
),
(
"GitHub App Installation Access Token v1",
"v1\\.[0-9A-Fa-f]{40}",
- TestValue::Single("v1.1234567890abcdef1234567890abcdef12345678"), // not a real token
+ TestValue::Single("v1.1234567890abcdef1234567890abcdef12345678"), // not a real token
),
(
"GitLab PAT",
@@ -96,10 +100,20 @@ pub static SECRET_PATTERNS: &[(&str, &str, TestValue)] = &[
(
"Slack webhook",
"T[a-zA-Z0-9_]{8}/B[a-zA-Z0-9_]{8}/[a-zA-Z0-9_]{24}",
- TestValue::Single("https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"),
+ TestValue::Single(
+ "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX",
+ ),
+ ),
+ (
+ "Stripe test key",
+ "sk_test_[0-9a-zA-Z]{24}",
+ TestValue::Single("sk_test_1234567890abcdefghijklmnop"),
+ ),
+ (
+ "Stripe live key",
+ "sk_live_[0-9a-zA-Z]{24}",
+ TestValue::Single("sk_live_1234567890abcdefghijklmnop"),
),
- ("Stripe test key", "sk_test_[0-9a-zA-Z]{24}", TestValue::Single("sk_test_1234567890abcdefghijklmnop")),
- ("Stripe live key", "sk_live_[0-9a-zA-Z]{24}", TestValue::Single("sk_live_1234567890abcdefghijklmnop")),
(
"Netlify authentication token",
"nf[pcoub]_[0-9a-zA-Z]{36}",
@@ -127,7 +141,7 @@ pub static SECRET_PATTERNS_RE: LazyLock<RegexSet> = LazyLock::new(|| {
mod tests {
use regex::Regex;
- use crate::secrets::{TestValue, SECRET_PATTERNS};
+ use crate::secrets::{SECRET_PATTERNS, TestValue};
#[test]
fn test_secrets() {
diff --git a/crates/atuin-client/src/settings.rs b/crates/atuin-client/src/settings.rs
index e99153b1..91ccb6b8 100644
--- a/crates/atuin-client/src/settings.rs
+++ b/crates/atuin-client/src/settings.rs
@@ -6,19 +6,19 @@ use atuin_common::record::HostId;
use atuin_common::utils;
use clap::ValueEnum;
use config::{
- builder::DefaultState, Config, ConfigBuilder, Environment, File as ConfigFile, FileFormat,
+ Config, ConfigBuilder, Environment, File as ConfigFile, FileFormat, builder::DefaultState,
};
-use eyre::{bail, eyre, Context, Error, Result};
-use fs_err::{create_dir_all, File};
+use eyre::{Context, Error, Result, bail, eyre};
+use fs_err::{File, create_dir_all};
use humantime::parse_duration;
use regex::RegexSet;
use semver::Version;
use serde::{Deserialize, Serialize};
use serde_with::DeserializeFromStr;
use time::{
- format_description::{well_known::Rfc3339, FormatItem},
- macros::format_description,
OffsetDateTime, UtcOffset,
+ format_description::{FormatItem, well_known::Rfc3339},
+ macros::format_description,
};
use uuid::Uuid;
@@ -141,8 +141,9 @@ impl fmt::Display for Timezone {
}
}
/// format: <+|-><hour>[:<minute>[:<second>]]
-static OFFSET_FMT: &[FormatItem<'_>] =
- format_description!("[offset_hour sign:mandatory padding:none][optional [:[offset_minute padding:none][optional [:[offset_second padding:none]]]]]");
+static OFFSET_FMT: &[FormatItem<'_>] = format_description!(
+ "[offset_hour sign:mandatory padding:none][optional [:[offset_minute padding:none][optional [:[offset_second padding:none]]]]]"
+);
impl FromStr for Timezone {
type Err = Error;
diff --git a/crates/atuin-client/src/sync.rs b/crates/atuin-client/src/sync.rs
index c2377baa..2b099ae4 100644
--- a/crates/atuin-client/src/sync.rs
+++ b/crates/atuin-client/src/sync.rs
@@ -109,13 +109,16 @@ async fn sync_download(
for i in remote_status.deleted {
// we will update the stored history to have this data
// pretty much everything can be nullified
- if let Some(h) = db.load(i.as_str()).await? {
- db.delete(h).await?;
- } else {
- info!(
- "could not delete history with id {}, not found locally",
- i.as_str()
- );
+ match db.load(i.as_str()).await? {
+ Some(h) => {
+ db.delete(h).await?;
+ }
+ _ => {
+ info!(
+ "could not delete history with id {}, not found locally",
+ i.as_str()
+ );
+ }
}
}
diff --git a/crates/atuin-client/src/theme.rs b/crates/atuin-client/src/theme.rs
index 9ebe6f9c..429f08ab 100644
--- a/crates/atuin-client/src/theme.rs
+++ b/crates/atuin-client/src/theme.rs
@@ -416,7 +416,7 @@ impl ThemeManager {
"set theme debug on for more info".to_string()
}
),
- )))
+ )));
}
};
let colors: HashMap<Meaning, String> = theme_config.colors;
@@ -697,7 +697,8 @@ mod theme_tests {
testing_logger::validate(|captured_logs| {
assert_eq!(captured_logs.len(), 1);
- assert_eq!(captured_logs[0].body,
+ assert_eq!(
+ captured_logs[0].body,
"Could not load theme nonsolarized: Empty theme directory override and could not find theme elsewhere"
);
assert_eq!(captured_logs[0].level, log::Level::Warn)