//! Poll the registries and triage what was just published. //! //! cargo run -p hound-watch --example triage-live -- [how-many] fn main() -> anyhow::Result<()> { let limit: usize = std::env::args() .nth(1) .and_then(|a| a.parse().ok()) .unwrap_or(40); let mut cursor = hound_watch::Cursor::default(); let releases = hound_watch::poll(&mut cursor)?; let npm: Vec<_> = releases.iter().filter(|r| r.ecosystem == "npm").collect(); println!("polled {} npm releases; triaging {}", npm.len(), limit.min(npm.len())); let mut checked = 0; let mut with_scripts = 0; let mut findings = 0; for r in npm.iter().take(limit) { let meta = match hound_watch::npm_metadata(&r.name) { Ok(m) => m, Err(_) => continue, // unpublished between the poll and now, or rate limited }; checked += 1; if !meta.install_scripts.is_empty() { with_scripts += 1; } for f in hound_watch::triage(&meta) { findings += 1; println!("\n [{}] {} — {}", f.severity.as_str(), f.subject, f.explanation); for (hook, cmd) in &meta.install_scripts { println!(" {hook}: {}", &cmd[..cmd.len().min(90)]); } } } println!("\nchecked {checked}, {with_scripts} run install scripts, {findings} finding(s)"); Ok(()) }