This commit is contained in:
Will Greenberg
2025-03-27 11:19:50 -07:00
parent 57b0455363
commit 057c9acb40
4 changed files with 43 additions and 7 deletions
+8 -4
View File
@@ -32,7 +32,11 @@ struct Args {
verbose: bool,
}
async fn analyze_file(harness: &mut Harness, qmdl_path: &str, show_skipped: bool) {
async fn analyze_file(enable_dummy_analyzer: bool, qmdl_path: &str, show_skipped: bool) {
let mut harness = Harness::new_with_all_analyzers();
if enable_dummy_analyzer {
harness.add_analyzer(Box::new(dummy_analyzer::TestAnalyzer { count: 0 }));
}
let qmdl_file = &mut File::open(&qmdl_path).await.expect("failed to open file");
let file_size = qmdl_file
.metadata()
@@ -135,12 +139,12 @@ async fn main() {
.with_level(level)
.init()
.unwrap();
info!("Analyzers:");
let mut harness = Harness::new_with_all_analyzers();
if args.enable_dummy_analyzer {
harness.add_analyzer(Box::new(dummy_analyzer::TestAnalyzer { count: 0 }));
}
info!("Analyzers:");
for analyzer in harness.get_metadata().analyzers {
info!(" - {}: {}", analyzer.name, analyzer.description);
}
@@ -156,7 +160,7 @@ async fn main() {
if name_str.ends_with(".qmdl") {
let path = entry.path();
let path_str = path.to_str().unwrap();
analyze_file(&mut harness, path_str, args.show_skipped).await;
analyze_file(args.enable_dummy_analyzer, path_str, args.show_skipped).await;
if args.pcapify {
pcapify(&path).await;
}
@@ -164,7 +168,7 @@ async fn main() {
}
} else {
let path = args.qmdl_path.to_str().unwrap();
analyze_file(&mut harness, path, args.show_skipped).await;
analyze_file(args.enable_dummy_analyzer, path, args.show_skipped).await;
if args.pcapify {
pcapify(&args.qmdl_path).await;
}
+32
View File
@@ -1,3 +1,4 @@
use log::info;
use chrono::{DateTime, Local};
use rayhunter::util::RuntimeMetadata;
use serde::{Deserialize, Serialize};
@@ -114,6 +115,37 @@ impl RecordingStore {
})
}
// Given a path to a directory of QMDL files, attempt to create a new
// manifest (and analysis files) from scratch. Useful if the existing
// manifest is corrupt or out of date. This will always re-run all
// analyzers over all of the given QMDLs.
pub async fn restore_from_dir<P>(path: P) -> Result<Self, RecordingStoreError>
where
P: AsRef<Path>,
{
info!("restoring RecordingStore from dir {:?}", path.as_ref());
let mut dir = fs::read_dir(path).await
.map_err(RecordingStoreError::OpenDirError)?;
loop {
let dir_entry = match dir.next_entry().await {
Ok(Some(entry)) => entry,
Ok(None) => break,
Err(err) => return Err(RecordingStoreError::OpenDirError(err)),
};
let qmdl_path = dir_entry.path();
if qmdl_path.ends_with("qmdl") {
info!("ignoring non-QMDL file {:?}", qmdl_path);
continue;
}
let mut manifest_entry = ManifestEntry::new();
manifest_entry.name = qmdl_path.file_stem()
.unwrap()
.to_string_lossy()
.into_owned();
}
todo!();
}
// Creates a new RecordingStore at the given path. This involves creating a dir
// and writing an empty manifest.
pub async fn create<P>(path: P) -> Result<Self, RecordingStoreError>
+2 -2
View File
@@ -13,10 +13,10 @@ type AnalysisStatusJson = {
finished: string[];
};
export type AnalysisResult {
export type AnalysisResult = {
name: string,
status: AnalysisStatus,
}
};
export class AnalysisManager {
public analysis_status: Map<string, AnalysisStatus> = new Map();
+1 -1
View File
@@ -60,7 +60,7 @@ impl Analyzer for ImsiRequestedAnalyzer {
event_type: EventType::QualitativeWarning {
severity: Severity::High,
},
message: "NAS IMSI identity request detected".to_owned(),
message: format!("NAS IMSI identity request detected (packet {})", self.packet_num),
});
}
}