Skip to content

Commit

Permalink
Add: function get_prefs() to get the a vector of string representing …
Browse files Browse the repository at this point in the history
…the script preferences, as they have to be stored in the redis cache
  • Loading branch information
jjnicola committed Nov 23, 2022
1 parent 3a98b57 commit 93a70b1
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions rust/nvtcache/src/nvt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ impl NvtPref {
default,
})
}
/// Return the id of the NvtPref
pub fn get_id(&mut self) -> String {
return self.pref_id.to_string();
}
/// Return the type of the NvtPref
pub fn get_type(&mut self) -> String {
return self.pref_type.clone();
}
/// Return the name of the NvtPref
pub fn get_name(&mut self) -> String {
return self.name.clone();
}
/// Return the default value of the NvtPref
pub fn get_default(&mut self) -> String {
return self.default.clone();
}
}

impl NvtRef {
Expand Down Expand Up @@ -560,4 +576,23 @@ impl Nvt {
}
return Ok((cve.to_string(), bid.to_string(), xrefs.to_string()));
}

pub fn get_prefs(&mut self) -> Result<Vec<String>> {
let mut prefs: Vec<String> = Vec::new();

for pref in self.prefs.iter_mut() {
let pref_str = [
pref.get_id(),
pref.get_name(),
pref.get_id(),
pref.get_default(),
]
.join(":")
.to_string();

prefs.push(pref_str);
}

return Ok(prefs);
}
}

0 comments on commit 93a70b1

Please sign in to comment.