完成:列出所有已发布但未修复的安全公告
Signed-off-by: Jia Chao <jiachao2130@126.com>
This commit is contained in:
parent
853be957ee
commit
3b9396c500
|
@ -3,6 +3,10 @@ name = "cuvat-rs"
|
|||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[[bin]]
|
||||
name = "cuvat"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.0", features = ["derive"] }
|
||||
serde = { version = "1", features = ["serde_derive"] }
|
||||
|
|
|
@ -65,7 +65,10 @@ fn repoter(cli: &Cli) -> crate::Result<()> {
|
|||
fn summary(cli: &Cli) -> crate::Result<()> {
|
||||
let avaliable = get_avaliable()?;
|
||||
let severity = Severity::from_str(&cli.severity)?;
|
||||
let mut total = 0;
|
||||
let mut res = vec![0; 5];
|
||||
let mut lists = vec![vec![]; 5];
|
||||
let mut msg = String::new();
|
||||
|
||||
for (cusa, rpms) in &avaliable {
|
||||
// 过滤
|
||||
|
@ -74,20 +77,36 @@ fn summary(cli: &Cli) -> crate::Result<()> {
|
|||
}
|
||||
|
||||
let pos: usize = cusa.severity().into();
|
||||
total += 1;
|
||||
res[pos] += 1;
|
||||
lists[pos].push(cusa);
|
||||
}
|
||||
let msg = format!(
|
||||
"
|
||||
漏洞扫描结果如下:
|
||||
致命漏洞: {:3} 个
|
||||
高危漏洞: {:3} 个
|
||||
中危漏洞: {:3} 个
|
||||
低危漏洞: {:3} 个
|
||||
|
||||
// 如果需要列出详细的 sa
|
||||
if cli.list {
|
||||
msg = format!("当前系统未修复的公告列表(共 {total} 个):\n");
|
||||
for sas in &lists {
|
||||
for sa in sas {
|
||||
msg = format!("{msg}\n{:>4}{}: {:?}", "", sa.id(), sa.severity());
|
||||
}
|
||||
}
|
||||
//msg = format!("{msg}\n\n");
|
||||
} else {
|
||||
msg = format!(
|
||||
"{msg}
|
||||
本次安全检查共扫描出 {} 个漏洞:
|
||||
|
||||
致命漏洞:{:>3} 个
|
||||
高危漏洞:{:>3} 个
|
||||
中危漏洞:{:>3} 个
|
||||
低危漏洞:{:>3} 个
|
||||
",
|
||||
res[4], res[3], res[2], res[1]
|
||||
);
|
||||
total, res[4], res[3], res[2], res[1]
|
||||
);
|
||||
}
|
||||
|
||||
println!("{}", msg);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user