Skip to content

Commit

Permalink
Change: ci: add head -n 1 to be more explicit
Browse files Browse the repository at this point in the history
While the extra lines won't be used it is more explicit to reduce it to
a single line.

Co-authored-by: Christoph Krämer <[email protected]>
  • Loading branch information
nichtsfrei and Kraemii committed Feb 14, 2024
1 parent f7abe57 commit a785ad2
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 51 deletions.
Empty file removed .github/workflows/ddependabot.yml
Empty file.
2 changes: 1 addition & 1 deletion .github/workflows/init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
if: ( env.IS_VERSION_TAG == 'true' )
run: |
# find the latest version that is not ourself
export LATEST_VERSION=$(git tag -l | grep -v '${{ github.ref_name }}' | sort -r --version-sort)
export LATEST_VERSION=$(git tag -l | grep -v '${{ github.ref_name }}' | sort -r --version-sort | head -n 1)
# get major minor patch versions
IFS='.' read -r latest_major latest_minor latest_patch << EOF
$LATEST_VERSION
Expand Down
3 changes: 0 additions & 3 deletions rust/feed/src/update/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ pub struct Error {
pub kind: ErrorKind,
}


impl std::fmt::Display for ErrorKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Expand All @@ -56,8 +55,6 @@ impl std::fmt::Display for Error {

impl std::error::Error for Error {}



impl From<verify::Error> for Error {
fn from(value: verify::Error) -> Self {
let fin = match &value {
Expand Down
2 changes: 1 addition & 1 deletion rust/feed/src/update/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ where
impl<'a, S, L, V, K, R> Update<S, L, V, K>
where
S: Sync + Send + Dispatcher<K>,
K: AsRef<str> + Display + Default + From<String> + 'static,
K: AsRef<str> + Display + Default + From<String> + 'static,
L: Sync + Send + Loader + AsBufReader<File>,
V: Iterator<Item = Result<HashSumFileItem<'a, R>, verify::Error>>,
R: Read + 'a,
Expand Down
8 changes: 2 additions & 6 deletions rust/infisto/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,8 @@ impl IndexedByteStorage for CachedIndexFileStorer {
.append_all_index(key, &initial_index, &data[1..])?;
(self.cache.len() - 1, end_index)
}
std::io::ErrorKind::NotFound if data.is_empty() => {
(0, vec![])
}
_ => {
return Err(Error::FileOpen(ioe))
},
std::io::ErrorKind::NotFound if data.is_empty() => (0, vec![]),
_ => return Err(Error::FileOpen(ioe)),
},
Err(e) => return Err(e),
}
Expand Down
1 change: 0 additions & 1 deletion rust/infisto/src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ where
{
/// Serializes given data to Vec<u8>
pub fn serialize(t: T) -> Result<Self, base::Error> {

match rmp_serde::to_vec(&t) {
Ok(v) => Ok(Serialization::Serialized(v)),
Err(_) => Err(base::Error::Serialize),
Expand Down
10 changes: 6 additions & 4 deletions rust/json-storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{
sync::{Arc, Mutex},
};

use storage::{self, item::PerItemDispatcher, Kb, StorageError, NotusAdvisory};
use storage::{self, item::PerItemDispatcher, Kb, NotusAdvisory, StorageError};

/// Wraps write calls of json elements to be as list.
///
Expand Down Expand Up @@ -131,14 +131,14 @@ where

_: Box<Option<NotusAdvisory>>,
) -> Result<(), StorageError> {
Ok(())
Ok(())
}
}

impl<S, K> storage::Retriever<K> for ItemDispatcher<S>
where
S: Write,
K: 'static
K: 'static,
{
fn retrieve(
&self,
Expand All @@ -147,7 +147,9 @@ where
) -> Result<Box<dyn Iterator<Item = storage::Field>>, StorageError> {
Ok(match scope {
// currently not supported
storage::Retrieve::NVT(_) | storage::Retrieve::NotusAdvisory(_) => Box::new([].into_iter()),
storage::Retrieve::NVT(_) | storage::Retrieve::NotusAdvisory(_) => {
Box::new([].into_iter())
}
storage::Retrieve::KB(s) => Box::new({
let kbs = self.kbs.lock().map_err(StorageError::from)?;
let kbs = kbs.clone();
Expand Down
3 changes: 1 addition & 2 deletions rust/models/src/advisories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::collections::HashMap;

/// Represents an advisory json file for notus product.
#[cfg_attr(feature = "serde_support", derive(serde::Deserialize))]
#[derive(Debug, Clone,PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ProductsAdivisories {
/// Version of the advisory file
pub version: String,
Expand Down Expand Up @@ -173,7 +173,6 @@ impl From<VulnerabilityData> for Vulnerability {
None => "".to_string(),
},
};


let refs = HashMap::new();
Self {
Expand Down
1 change: 0 additions & 1 deletion rust/models/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ pub use status::*;
pub use target::*;
pub use vt::*;


#[cfg(test)]
mod tests {

Expand Down
1 change: 0 additions & 1 deletion rust/models/src/vt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ pub struct VT {
/// The list of parameters for the VT
pub parameters: Vec<Parameter>,
}

3 changes: 2 additions & 1 deletion rust/nasl-interpreter/tests/description.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ if(description)
assert_eq!(
storage
.retrieve(&key, storage::Retrieve::NVT(None))
.unwrap().collect::<Vec<_>>(),
.unwrap()
.collect::<Vec<_>>(),
vec![
NVT(Oid("0.0.0.0.0.0.0.0.0.1".to_owned())),
NVT(FileName(key)),
Expand Down
23 changes: 12 additions & 11 deletions rust/openvasd/src/controller/feed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,29 @@ where
let last_hash = ctx.db.feed_hash().await;
if signature_check {
if let Err(err) = feed::verify::check_signature(&path) {
tracing::warn!("Signature of {} is not corredct, skipping: {}", path.display(), err);

tracing::warn!(
"Signature of {} is not corredct, skipping: {}",
path.display(),
err
);
}
}

let hash = tokio::task::spawn_blocking(move || {
match FeedIdentifier::sumfile_hash(path) {
let hash =
tokio::task::spawn_blocking(move || match FeedIdentifier::sumfile_hash(path) {
Ok(h) => h,
Err(e) => {
tracing::warn!("Failed to compute sumfile hash: {e:?}");
"".to_string()
}
}
})
.await
.unwrap();
})
.await
.unwrap();
if last_hash.is_empty() || last_hash != hash {
match ctx.db.synchronize_feeds(hash).await{
Ok(_) => {},
match ctx.db.synchronize_feeds(hash).await {
Ok(_) => {}
Err(e) => tracing::warn!("Unable to sync feed: {e}"),
}

}
tokio::time::sleep(interval).await;
}
Expand Down
10 changes: 3 additions & 7 deletions rust/openvasd/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,10 @@ pub trait NVTStorer {
/// directories and update the meta information.
async fn synchronize_feeds(&self, hash: String) -> Result<(), Error>;


/// Retrieves just all oids.
async fn oids(&self) -> Result<Box<dyn Iterator<Item = String> + Send>, Error> {
let vts = self.vts().await?;
Ok(Box::new(vts.map(|x|x.oid)))
Ok(Box::new(vts.map(|x| x.oid)))
}

/// Retrieves NVTs.
Expand All @@ -123,11 +122,8 @@ pub trait NVTStorer {

/// Retrieves a NVT.
///
async fn vt_by_oid(
&self,
oid: &str,
) -> Result<Option<storage::item::Nvt>, Error> {
Ok(self.vts().await?.find(|x|x.oid == oid))
async fn vt_by_oid(&self, oid: &str) -> Result<Option<storage::item::Nvt>, Error> {
Ok(self.vts().await?.find(|x| x.oid == oid))
}

/// Returns the currently stored feed hash.
Expand Down
14 changes: 6 additions & 8 deletions rust/redis-storage/src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,6 @@ where
.map_err(|e| DbError::SystemError(format!("{e:?}")))?;
cache.delete_namespace()
}


}

impl<S, K> storage::item::ItemDispatcher<K> for CacheDispatcher<S, K>
Expand All @@ -686,7 +684,11 @@ where
kbs.push(kb);
Ok(())
}
fn dispatch_advisory(&self, key: &str, adv: Box<Option<NotusAdvisory>>) -> Result<(), StorageError> {
fn dispatch_advisory(
&self,
key: &str,
adv: Box<Option<NotusAdvisory>>,
) -> Result<(), StorageError> {
let mut cache = Arc::as_ref(&self.cache).lock()?;
cache.redis_add_advisory(key, *adv).map_err(|e| e.into())
}
Expand Down Expand Up @@ -763,11 +765,7 @@ mod tests {
.unwrap();
Ok(())
}
fn lindex(
&mut self,
_: &str,
_: isize,
) -> crate::dberror::RedisStorageResult<String> {
fn lindex(&mut self, _: &str, _: isize) -> crate::dberror::RedisStorageResult<String> {
Ok(String::new())
}

Expand Down
3 changes: 2 additions & 1 deletion rust/storage/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,8 @@ pub trait ItemDispatcher<K> {
Ok(())
}
/// Stores an advisory
fn dispatch_advisory(&self, _: &str, _: Box<Option<NotusAdvisory>>) -> Result<(), StorageError>;
fn dispatch_advisory(&self, _: &str, _: Box<Option<NotusAdvisory>>)
-> Result<(), StorageError>;
}

/// Collects the information while being in a description run and calls the dispatch method
Expand Down
3 changes: 0 additions & 3 deletions rust/storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,8 @@ pub enum Field {
KB(Kb),
/// Notus advisories, when None then the impl can assume finish
NotusAdvisory(Box<Option<NotusAdvisory>>),

}



impl From<NVTField> for Field {
fn from(value: NVTField) -> Self {
Self::NVT(value)
Expand Down

0 comments on commit a785ad2

Please sign in to comment.