Compare commits
No commits in common. "79b8a3850339ec32d94b135eb6434a59e7c2f155" and "36cc52418cd6087272207b35ea727392fdfa6c44" have entirely different histories.
79b8a38503
...
36cc52418c
|
@ -184,7 +184,6 @@ fn list_cves(cli: &Cli) -> crate::Result<()> {
|
|||
|
||||
let reporter = _reporter()?;
|
||||
let avaliable = reporter.get_avaliable();
|
||||
let fixed = reporter.get_fixed();
|
||||
let severity = Severity::from_str(&cli.severity)?;
|
||||
let mut _cves = HashSet::new();
|
||||
cli.sources.iter().for_each(|id| {
|
||||
|
@ -193,32 +192,7 @@ fn list_cves(cli: &Cli) -> crate::Result<()> {
|
|||
|
||||
let mut cves = HashSet::new();
|
||||
let mut effected_rpms: HashMap<String, Vec<String>> = HashMap::new();
|
||||
let mut fixed_rpms: HashMap<String, Vec<String>> = HashMap::new();
|
||||
let mut msg = String::new();
|
||||
|
||||
// 已修复的 CVE
|
||||
// 列出修复的软件包
|
||||
for (cusa, rpms) in fixed {
|
||||
// 过滤
|
||||
if cusa.severity() < &severity {
|
||||
continue;
|
||||
}
|
||||
|
||||
cusa.cves().iter().for_each(|cve| {
|
||||
if let Some(_) = _cves.get(&cve.id) {
|
||||
let _ = cves.insert(cve.clone());
|
||||
if let Some(fixed) = fixed_rpms.get_mut(&cve.id) {
|
||||
for rpm in rpms {
|
||||
fixed.push(rpm.name().into());
|
||||
}
|
||||
} else {
|
||||
let fixed: Vec<String> = rpms.into_iter().map(|rpm| rpm.name().into()).collect();
|
||||
fixed_rpms.insert(cve.id.clone(), fixed);
|
||||
}
|
||||
//_cves.remove(&cve.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
let mut msg = String::from("有可用的安全更新...");
|
||||
|
||||
// 仅针对可用更新
|
||||
for (cusa, rpms) in avaliable {
|
||||
|
@ -235,8 +209,8 @@ fn list_cves(cli: &Cli) -> crate::Result<()> {
|
|||
effected.push(rpm.name().into());
|
||||
}
|
||||
} else {
|
||||
let effected: Vec<String> = rpms.into_iter().map(|rpm| rpm.name().into()).collect();
|
||||
effected_rpms.insert(cve.id.clone(), effected);
|
||||
let pkgs: Vec<String> = rpms.into_iter().map(|rpm| rpm.name().into()).collect();
|
||||
effected_rpms.insert(cve.id.clone(), pkgs);
|
||||
}
|
||||
//_cves.remove(&cve.id);
|
||||
}
|
||||
|
@ -245,18 +219,10 @@ fn list_cves(cli: &Cli) -> crate::Result<()> {
|
|||
|
||||
for cve in &cves {
|
||||
if cli.info {
|
||||
msg = format!("{msg}\n\n{cve:#?}\n");
|
||||
if let Some(_fixed) = fixed_rpms.get(&cve.id) {
|
||||
msg = format!("{msg}已修复的软件: {:?}\n", _fixed);
|
||||
}
|
||||
if let Some(_effected) = effected_rpms.get(&cve.id) {
|
||||
msg = format!("{msg}可用的更新: {:?}\n", _effected);
|
||||
}
|
||||
msg = format!("{msg}\n\n{cve:#?}\n受影响的软件包: {:?}\n", effected_rpms.get(&cve.id).unwrap());
|
||||
} else {
|
||||
msg = format!("{msg}\n{}", cve.id);
|
||||
}
|
||||
// 重置此 cve
|
||||
_cves.remove(&cve.id);
|
||||
}
|
||||
|
||||
if !_cves.is_empty() {
|
||||
|
|
|
@ -29,7 +29,6 @@ lazy_static! {
|
|||
}
|
||||
|
||||
pub fn cumain() -> Result<()> {
|
||||
ccutils::set_up_logging()?;
|
||||
let cli = cli::parse();
|
||||
// 初始化使用 rpm 默认配置
|
||||
rpm_rs::configure();
|
||||
|
|
Loading…
Reference in New Issue
Block a user