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
14 changes: 14 additions & 0 deletions crates/binary-cookies/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- markdownlint-disable MD024 -->

# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed

- Better error handle
21 changes: 12 additions & 9 deletions crates/binary-cookies/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ use winnow::error::ContextError;
#[derive(Snafu)]
#[snafu(visibility(pub))]
pub enum ParseError {
#[snafu(display("{render}, @:{location}"))]
#[snafu(display("{render}\n@:{location}"))]
WinnowCtx {
render: ContextError,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("Time broken: {local_result:?}, @:{location}"))]
#[snafu(display("Time broken: {local_result:?}\n@:{location}"))]
Time {
local_result: LocalResult<chrono::DateTime<chrono::Utc>>,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("{source}, @:{location}"))]
#[snafu(display("{source}\n@:{location}"))]
Bplist {
source: BplistErr,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("Read: {source}, @:{location}",))]
#[snafu(display("Read: {source}\n@:{location}",))]
Read {
source: std::io::Error,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("End of binarycookies, can't decode any more data, @:{location}"))]
#[snafu(display("End of binarycookies, can't decode any more data\n@:{location}"))]
ParsingCompleted {
#[snafu(implicit)]
location: Location,
Expand All @@ -50,24 +50,27 @@ impl ParseError {
#[derive(Snafu)]
#[snafu(visibility(pub))]
pub enum BplistErr {
#[snafu(display(r#"Not start with b"bplist00", @:{location}"#))]
#[snafu(display(
r#"Not start with b"bplist00"
@:{location}"#
))]
Magic {
#[snafu(implicit)]
location: Location,
},
#[snafu(display(r#"The object not dict, need update decoder, @:{location}"#))]
#[snafu(display("The object not dict, need update decoder\n@:{location}"))]
NotDict {
#[snafu(implicit)]
location: Location,
},
#[snafu(display(
r#"The dict key not `NSHTTPCookieAcceptPolicy`, need update decoder, @:{location}"#
"The dict key not `NSHTTPCookieAcceptPolicy`, need update decoder\n@:{location}"
))]
BadKey {
#[snafu(implicit)]
location: Location,
},
#[snafu(display(r#"The int not one byte, need update decoder, @:{location}"#))]
#[snafu(display("The int not one byte, need update decoder\n@:{location}"))]
OneByteInt {
#[snafu(implicit)]
location: Location,
Expand Down
6 changes: 6 additions & 0 deletions crates/chromium-crypto/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed

- Better error handle

## [0.2.0] - 2025-07-27

### Changed
Expand Down
36 changes: 18 additions & 18 deletions crates/chromium-crypto/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use snafu::{Location, Snafu};
#[snafu(visibility(pub))]
#[cfg(target_os = "linux")]
pub enum CryptoError {
#[snafu(display("{source}, @:{location}"))]
#[snafu(display("{source}\n@:{location}"))]
GetPass {
source: secret_service::Error,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("{source}, @:{location}"))]
#[snafu(display("{source}\n@:{location}"))]
Unpadding {
source: aes::cipher::block_padding::UnpadError,
#[snafu(implicit)]
Expand All @@ -24,19 +24,19 @@ pub enum CryptoError {
#[snafu(visibility(pub))]
#[cfg(target_os = "macos")]
pub enum CryptoError {
#[snafu(display("{source}, @:{location}"))]
#[snafu(display("{source}\n@:{location}"))]
Keyring {
source: keyring::Error,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("{source}, @:{location}"))]
#[snafu(display("{source}\n@:{location}"))]
Unpadding {
source: aes::cipher::block_padding::UnpadError,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("{source}, @:{location}"))]
#[snafu(display("{source}\n@:{location}"))]
Task {
source: tokio::task::JoinError,
#[snafu(implicit)]
Expand All @@ -49,76 +49,76 @@ pub enum CryptoError {
#[snafu(visibility(pub))]
#[cfg(target_os = "windows")]
pub enum CryptoError {
#[snafu(display("{source}, path: {}, @:{location}",path.display()))]
#[snafu(display("{source}, path: {}\n@:{location}",path.display()))]
Io {
source: std::io::Error,
path: std::path::PathBuf,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("{source}, @:{location}"))]
#[snafu(display("{source}\n@:{location}"))]
Serde {
source: serde_json::Error,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("{source}, @:{location}"))]
#[snafu(display("{source}\n@:{location}"))]
Base64 {
source: base64::DecodeError,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("{source}, @:{location}"))]
#[snafu(display("{source}\n@:{location}"))]
Task {
source: tokio::task::JoinError,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("{source}, @:{location}"))]
#[snafu(display("{source}\n@:{location}"))]
AesGcm {
source: aes_gcm::Error,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("{source}, @:{location}"))]
#[snafu(display("{source}\n@:{location}"))]
CryptUnprotectData {
source: windows::core::Error,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("CryptUnprotectData returned a null pointer, @:{location}"))]
#[snafu(display("CryptUnprotectData returned a null pointer\n@:{location}"))]
CryptUnprotectDataNull {
#[snafu(implicit)]
location: Location,
},
#[snafu(display("{source}, @:{location}"))]
#[snafu(display("{source}\n@:{location}"))]
ChaCha {
source: chacha20poly1305::Error,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("{render}, @:{location}"))]
#[snafu(display("{render}\n@:{location}"))]
Context {
render: winnow::error::ContextError,
#[snafu(implicit)]
location: Location,
},
#[snafu(display(r#"app_bound_encrypted_key not start with "APPB", @:{location}"#))]
#[snafu(display(r#"app_bound_encrypted_key not start with "APPB"\n@:{location}"#))]
Appb {
#[snafu(implicit)]
location: Location,
},
#[snafu(display("Get process path failed, @:{location}"))]
#[snafu(display("Get process path failed\n@:{location}"))]
ProcessPath {
#[snafu(implicit)]
location: Location,
},
#[snafu(display("Invalid status from `RtlAdjustPrivilege`, @:{location}"))]
#[snafu(display("Invalid status from `RtlAdjustPrivilege`\n@:{location}"))]
Privilege {
#[snafu(implicit)]
location: Location,
},
#[snafu(display("No such Process lsass.exe or winlogon.exe, @:{location}"))]
#[snafu(display("No such Process lsass.exe or winlogon.exe\n@:{location}"))]
NotFoundProcess {
#[snafu(implicit)]
location: Location,
Expand Down
2 changes: 1 addition & 1 deletion crates/chromium-crypto/src/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl Decrypter {
.map(|res| {
String::from_utf8(res.to_vec()).unwrap_or_else(|_e| {
#[cfg(feature = "tracing")]
tracing::info!("Decoding for chromium >= 130.x: {_e}");
tracing::trace!("Decoding for chromium >= 130.x: {_e}");
String::from_utf8_lossy(&res[32..]).to_string()
})
})
Expand Down
2 changes: 1 addition & 1 deletion crates/chromium-crypto/src/mac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Decrypter {
.map(|res| {
String::from_utf8(res.to_vec()).unwrap_or_else(|_e| {
#[cfg(feature = "tracing")]
tracing::info!("Decoding for chromium >= 130.x: {_e}");
tracing::trace!("Decoding for chromium >= 130.x: {_e}");
String::from_utf8_lossy(&res[32..]).to_string()
})
})
Expand Down
2 changes: 1 addition & 1 deletion crates/chromium-crypto/src/win/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl Decrypter {
.map(|v| {
String::from_utf8(v.clone()).unwrap_or_else(|_e| {
#[cfg(feature = "tracing")]
tracing::info!("Decoding for chromium >=130.x: {_e}");
tracing::trace!("Decoding for chromium >=130.x: {_e}");
String::from_utf8_lossy(&v[32..]).into_owned()
})
})
Expand Down
7 changes: 6 additions & 1 deletion crates/decrypt-cookies/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed

- Better error handle

## [0.8.0] - 2025-07-27

### Changed
Expand All @@ -18,7 +24,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- SafariGetter: add `cookies_by_host`.


## [0.7.0] - 2025-07-20

### Changed
Expand Down
24 changes: 18 additions & 6 deletions crates/decrypt-cookies/src/chromium/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,46 @@ use crate::{
#[derive(Snafu)]
#[snafu(visibility(pub))]
pub enum ChromiumBuilderError {
#[snafu(display("{source}, @:{location}"))]
#[snafu(display(r#"Not found {}
The browser is not installed or started with `--user-data-dir` arg
@:{location}"#, path.display()))]
NotFoundBase {
path: PathBuf,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("{source}\n@:{location}"))]
Decrypter {
source: chromium_crypto::error::CryptoError,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("{source}, @:{location}"))]
#[snafu(display("{source}\n@:{location}"))]
Db {
source: sea_orm::DbErr,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("{source}, path: {}, @:{location}",path.display()))]
#[snafu(display("{source}, path: {}\n@:{location}",path.display()))]
Io {
source: std::io::Error,
path: PathBuf,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("{source}, @:{location}"))]
#[snafu(display("{source}\n@:{location}"))]
Rawcopy {
source: anyhow::Error,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("{source}, @:{location}"))]
#[snafu(display("{source}\n@:{location}"))]
TokioJoin {
source: tokio::task::JoinError,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("Can not found home dir, @:{location}"))]
#[snafu(display("Can not found home dir\n@:{location}"))]
Home {
#[snafu(implicit)]
location: Location,
Expand Down Expand Up @@ -131,6 +139,10 @@ impl<B: ChromiumPath + Send + Sync> ChromiumBuilder<B> {
tracing::debug!(base = %base.display());
};

if !base.exists() {
return Err(NotFoundBaseSnafu { path: base }.build());
}

let temp_paths = Self::cache_data(base).await?;

#[cfg(target_os = "linux")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::path::Path;

use sea_orm::{
sea_query::IntoCondition, ColumnTrait, Database, DatabaseConnection, DbErr, EntityTrait,
QueryFilter,
sea_query::IntoCondition, ColumnTrait, DatabaseConnection, DbErr, EntityTrait, QueryFilter,
};

use super::cookie_entities::{
cookies::{self, Model},
prelude::*,
};
use crate::utils::connect_db;

type Result<T> = std::result::Result<T, DbErr>;

Expand All @@ -21,9 +21,7 @@ pub struct CookiesQuery {

impl CookiesQuery {
pub async fn new<P: AsRef<Path> + Send>(path: P) -> Result<Self> {
let db_url = format!("sqlite:{}?mode=ro", path.as_ref().to_string_lossy());

let db = Database::connect(db_url).await?;
let db = connect_db(path).await?;
Ok(Self { conn: db })
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ use std::path::Path;
use sea_orm::{
prelude::{DatabaseConnection, EntityTrait, QueryFilter},
sea_query::IntoCondition,
Database, DbErr,
DbErr,
};

use super::login_data_entities::{logins, prelude::Logins};
use crate::utils::connect_db;

type Result<T> = std::result::Result<T, DbErr>;

Expand All @@ -19,9 +20,7 @@ pub struct LoginDataQuery {

impl LoginDataQuery {
pub async fn new<P: AsRef<Path> + Send>(path: P) -> Result<Self> {
let db_url = format!("sqlite:{}?mode=ro", path.as_ref().to_string_lossy());

let db = Database::connect(db_url).await?;
let db = connect_db(path).await?;
Ok(Self { conn: db })
}

Expand Down
Loading
Loading