1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
mod audit;
use self::audit::AuditCommand;
use crate::config::AuditConfig;
use abscissa_core::{config::Override, Command, Configurable, FrameworkError, Options, Runnable};
use std::path::PathBuf;
pub const CONFIG_FILE: &str = "audit.toml";
#[derive(Command, Debug, Options, Runnable)]
pub enum CargoAuditCommand {
#[options(help = "Audit Cargo.lock files for vulnerable crates")]
Audit(AuditCommand),
}
impl Configurable<AuditConfig> for CargoAuditCommand {
fn config_path(&self) -> Option<PathBuf> {
let filename = home::cargo_home()
.ok()
.map(|cargo_home| cargo_home.join(CONFIG_FILE))?;
if filename.exists() {
Some(filename)
} else {
None
}
}
fn process_config(&self, config: AuditConfig) -> Result<AuditConfig, FrameworkError> {
match self {
CargoAuditCommand::Audit(cmd) => cmd.override_config(config),
}
}
}