RpmInfo 增加 sa 字段

Signed-off-by: Jia Chao <jiac13@chinaunicom.cn>
This commit is contained in:
Jia Chao 2024-06-18 16:16:11 +08:00
parent 39ee661dc7
commit b8a1b7c5c3
2 changed files with 11 additions and 0 deletions

View File

@ -163,6 +163,7 @@ impl UpdateInfo {
}
rpminfo.set("file", xmlreader.next_characters());
rpminfo.set("sa", self.id.clone());
self.pkglist.push(rpminfo);
}
Err(e) => {
@ -189,6 +190,8 @@ pub struct RpmInfo {
arch: String,
file: String,
sa: String,
}
impl RpmInfo {
@ -200,6 +203,7 @@ impl RpmInfo {
release: String::new(),
arch: String::new(),
file: String::new(),
sa: String::new(),
}
}
@ -212,6 +216,7 @@ impl RpmInfo {
"release" => self.release = value,
"arch" => self.arch = value,
"file" => self.file = value,
"sa" => self.sa = value,
_ => error!("Unknow field: {key}"),
}
}
@ -244,6 +249,10 @@ impl RpmInfo {
&self.file
}
pub fn sa(&self) -> &str {
&self.sa
}
pub fn evr(&self) -> String {
if self.epoch().is_some() {
format!("{}:{}-{}", self.epoch, self.version, self.release)

View File

@ -12,6 +12,7 @@ fn it_works() {
let severity = cvrf_xmlparser::Severity::Important;
let release = "openEuler";
let cves = 10;
let sa = "openEuler-SA-2022-1587";
let updateinfo = &db.db[0];
assert_eq!(updateinfo.id, id);
@ -19,6 +20,7 @@ fn it_works() {
assert_eq!(updateinfo.severity, severity);
assert_eq!(updateinfo.release, release);
assert_eq!(updateinfo.cves.len(), cves);
assert_eq!(updateinfo.pkglist[0].sa(), sa);
assert!(true);
}