CI / Format and clippy (push) Successful in 1m57s
CI / Dependency audit (push) Successful in 13s
CI / Check desktop app (Linux) (push) Successful in 3m54s
CI / Tests (Linux) (push) Failing after 7m25s
Release / Create release (push) Successful in 6s
Release / CLI (linux-aarch64) (push) Successful in 1m48s
Release / CLI (linux-x86_64) (push) Successful in 2m39s
Release / Desktop app (linux-aarch64) (push) Successful in 10m9s
Release / Desktop app (linux-x86_64) (push) Successful in 12m20s
Release / Desktop app (windows) (push) Successful in 7m32s
Release / Build latest.json (push) Successful in 5s
Completes the English-only standardization for code, comments, scripts and CI templates (UI/CLI-facing strings stay bilingual pt-BR/en, untouched). Covers the remaining crates/, apps/gui/ui/ and apps/gui/src-tauri/ comments, .gitea/ workflow and template comments, .githooks/ hooks, and the scripts/ source comments for the files already renamed in a prior commit (check.sh, generate-logo.py, install-hooks.sh). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VAyr8d7HuAdUGB6aA5xmDD
96 lines
2.9 KiB
Rust
96 lines
2.9 KiB
Rust
//! AFF4: Evimetry reference images (`github.com/aff4/ReferenceImages`) and write/read roundtrip.
|
|
|
|
use guara_core::aff4::{write_aff4, Aff4Options, Aff4Source};
|
|
use guara_core::source::{open_path, read_vec, MemSource, Source};
|
|
use std::path::PathBuf;
|
|
|
|
fn dir() -> PathBuf {
|
|
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../target/testdata/aff4")
|
|
}
|
|
|
|
#[test]
|
|
fn reads_reference_images_and_stored_hash_matches() {
|
|
let mut seen = 0;
|
|
for name in [
|
|
"Base-Linear.aff4",
|
|
"Base-Allocated.aff4",
|
|
"Base-Linear-AllHashes.aff4",
|
|
] {
|
|
let p = dir().join(name);
|
|
if !p.exists() {
|
|
eprintln!("SKIP {name}");
|
|
continue;
|
|
}
|
|
let a = Aff4Source::open(&p).unwrap_or_else(|e| panic!("{name}: {e}"));
|
|
assert_eq!(a.size(), 268_435_456, "{name}");
|
|
assert_eq!(
|
|
a.verify_stream_md5().unwrap(),
|
|
Some(true),
|
|
"{name}: hash do fluxo"
|
|
);
|
|
// sector 0 is readable through the generic `source::open` entrypoint
|
|
let s = open_path(&p).unwrap();
|
|
let head = read_vec(s.as_ref(), 0, 4096).unwrap();
|
|
assert_eq!(head.len(), 4096);
|
|
// reading unmapped gaps in a sparse AFF4 map returns zeros
|
|
let far = read_vec(s.as_ref(), 200 << 20, 512).unwrap();
|
|
assert_eq!(far.len(), 512);
|
|
eprintln!(
|
|
"{name}: {} {:?}",
|
|
a.info.get("Examinador").cloned().unwrap_or_default(),
|
|
guara_core::partition::detect_fs_in(&read_vec(s.as_ref(), 0, 4096).unwrap())
|
|
.map(|x| x.0)
|
|
);
|
|
seen += 1;
|
|
}
|
|
if seen == 0 {
|
|
eprintln!("SKIP: execute scripts/fetch-testdata.sh");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn roundtrip_with_snappy_blocks_and_odd_size() {
|
|
let mut x = 77u64;
|
|
let mut data: Vec<u8> = (0..5_000_001u32)
|
|
.map(|i| {
|
|
x ^= x << 13;
|
|
x ^= x >> 7;
|
|
x ^= x << 17;
|
|
if i % 100_000 < 60_000 {
|
|
0
|
|
} else {
|
|
(x >> 24) as u8
|
|
}
|
|
})
|
|
.collect();
|
|
data.truncate(5_000_001);
|
|
let dir = tempfile::tempdir().unwrap();
|
|
let p = dir.path().join("t.aff4");
|
|
let opts = Aff4Options {
|
|
case_name: "caso".into(),
|
|
examiner: "Lucas".into(),
|
|
notes: "teste".into(),
|
|
..Default::default()
|
|
};
|
|
let rep = write_aff4(
|
|
&MemSource(data.clone()),
|
|
&p,
|
|
&opts,
|
|
&|| false,
|
|
&mut |_, _| {},
|
|
)
|
|
.unwrap();
|
|
let a = Aff4Source::open(&p).unwrap();
|
|
assert_eq!(a.size(), data.len() as u64);
|
|
assert_eq!(
|
|
a.info.get("md5").map(String::as_str),
|
|
Some(rep.md5.as_str())
|
|
);
|
|
assert_eq!(a.info.get("Examinador").map(String::as_str), Some("Lucas"));
|
|
assert_eq!(a.verify_stream_md5().unwrap(), Some(true));
|
|
let got = read_vec(&a, 0, data.len()).unwrap();
|
|
assert!(got == data);
|
|
let part = read_vec(&a, 123_456, 70_000).unwrap();
|
|
assert_eq!(part, &data[123_456..193_456]);
|
|
}
|