Skip to content

Commit

Permalink
Change: add a dummy item in the redis storage for backward compatibil…
Browse files Browse the repository at this point in the history
…ity (#1514)

* Change: add a dummy item in the redis storage for backward compatibility

Since openvas uses positional items and expects the plugin oid in the second position, add a dummy item under filename key

* fix test
  • Loading branch information
jjnicola authored Oct 19, 2023
1 parent ba08540 commit 34d380a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions rust/redis-storage/src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,14 @@ pub trait RedisAddNvt: RedisWrapper {
}

// 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
// for the dependency autoload, where the filename is used to fetch the OID.
//
// TODO: since openvas get the oid by position and it is stored in the second position,
// for backward compatibility a dummy item (it is the plugin's upload timestamp)
// under the filename key is added.
// Once openvas is no longer used, the dummy item can be removed.
let key_name = format!("filename:{filename}");
self.lpush(&key_name, &oid)?;
self.rpush(&key_name, &["1", &oid])?;
Ok(())
}
}
Expand Down Expand Up @@ -578,9 +583,12 @@ mod tests {
);
}
"filename:test.nasl" => {
let values = values.first().unwrap().clone();
let oid = String::from_utf8(values);
assert_eq!(values.len(), 2);
let mut vals = values.clone();
let oid = String::from_utf8(vals.pop().unwrap());
assert_eq!(Ok("0.0.0.0.0.0.0.0.0.1".to_owned()), oid);
let dummy = vals.pop().unwrap();
assert_eq!(Ok("1".to_owned()), String::from_utf8(dummy));
}
_ => panic!("{key} should not occur"),
}
Expand Down

0 comments on commit 34d380a

Please sign in to comment.