32 lines
1.0 KiB
Rust
32 lines
1.0 KiB
Rust
//! Stream and analyze every supported document under a path.
|
|
|
|
use std::{env, error::Error, path::PathBuf};
|
|
|
|
use john_slop::{AnalysisContext, Config, Detector, read_inputs};
|
|
|
|
fn main() -> Result<(), Box<dyn Error>> {
|
|
let path = env::args_os()
|
|
.nth(1)
|
|
.map_or_else(|| PathBuf::from("examples/fixtures"), PathBuf::from);
|
|
let config = Config::embedded();
|
|
let detector = Detector::new(&config)?;
|
|
|
|
for document in read_inputs(&config, &path)? {
|
|
match document {
|
|
Ok(document) => {
|
|
let context = AnalysisContext::for_source(&document.source);
|
|
let analysis = detector.analyze_with(&document.content, &context);
|
|
println!(
|
|
"{}: evidence_score={}, findings={}",
|
|
document.source,
|
|
analysis.evidence_score.score(),
|
|
analysis.findings.len()
|
|
);
|
|
}
|
|
Err(error) => eprintln!("input error: {error}"),
|
|
}
|
|
}
|
|
|
|
Ok(())
|
|
}
|