Skip to content

Commit

Permalink
Add: store the oid under the redis key 'filename' (greenbone#1428)
Browse files Browse the repository at this point in the history
During the scheduler init, a function still needs the key and the content for autoloading script preferences

Jira: SC-846
  • Loading branch information
jjnicola authored May 22, 2023
1 parent 293b436 commit 631b66f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion rust/redis-storage/src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ pub trait RedisAddNvt: RedisWrapper {
//self.kb.lpush(&key_name, prefs)?;
}

// Stores the OID under the filename key. This key is currently used
// for the dependency autoload, where the filename is used to fetch the OID
let key_name = format!("filename:{filename}");
self.lpush(&key_name, &oid)?;
Ok(())
}
}
Expand Down Expand Up @@ -520,6 +524,7 @@ mod tests {
])),
NVT(RequiredKeys(vec!["WMI/Apache/RootPath".to_owned()])),
NVT(Oid("0.0.0.0.0.0.0.0.0.1".to_owned())),
NVT(FileName("test.nasl".to_owned())),
NVT(Preference(NvtPreference {
id: Some(2),
class: PreferenceType::Password,
Expand Down Expand Up @@ -563,13 +568,21 @@ mod tests {
enable_pw
);
}
"filename:test.nasl" => {
let values = values.first().unwrap().clone();
let oid = String::from_utf8(values);
assert_eq!(
Ok("0.0.0.0.0.0.0.0.0.1".to_owned()),
oid
);
}
_ => panic!("{key} should not occur"),
}
}
Err(TryRecvError::Empty) => break,
Err(e) => panic!("{e:?}"),
}
}
assert_eq!(results, 3);
assert_eq!(results, 4);
}
}

0 comments on commit 631b66f

Please sign in to comment.