Skip to content

Commit

Permalink
fix: fix the walker upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ctron committed Oct 5, 2023
1 parent 39fd823 commit c9bf5a2
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions vexination/walker/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use std::{net::SocketAddr, sync::Arc, time::Duration};

use csaf_walker::discover::DiscoveredAdvisory;
use csaf_walker::retrieve::RetrievedAdvisory;
use csaf_walker::{
retrieve::RetrievingVisitor,
source::{FileSource, HttpSource},
validation::{ValidatedAdvisory, ValidationError, ValidationVisitor},
walker::Walker,
};
use reqwest::StatusCode;
use reqwest::{header, StatusCode};
use serde::Deserialize;
use tokio::sync::{Mutex, RwLock};
use trustification_auth::client::TokenInjector;
Expand All @@ -32,12 +34,20 @@ pub async fn run(
let client = client.clone();
async move {
match advisory {
Ok(ValidatedAdvisory { retrieved }) => {
let data = retrieved.data;
Ok(ValidatedAdvisory {
retrieved:
RetrievedAdvisory {
data,
discovered: DiscoveredAdvisory { url, .. },
..
},
}) => {
let name = url.path_segments().and_then(|s| s.last()).unwrap_or_else(|| url.path());
match serde_json::from_slice::<csaf::Csaf>(&data) {
Ok(doc) => match client
.post(sink)
.json(&doc)
.header(header::CONTENT_TYPE, "application/json")
.body(data.clone())
.inject_token(&provider)
.await
.unwrap()
Expand All @@ -52,19 +62,19 @@ pub async fn run(
);
}
Ok(r) => {
log::warn!("(Skipped) Error storing VEX: {}", r.status());
log::warn!("(Skipped) {name}: Error storing VEX: {}", r.status());
}
Err(e) => {
log::warn!("(Skipped) Error storing VEX: {e:?}");
log::warn!("(Skipped) {name}: Error storing VEX: {e:?}");
}
},
Err(e) => {
log::warn!("(Ignored) Error parsing advisory to retrieve ID: {e:?}");
log::warn!("(Ignored) {name}: Error parsing advisory to retrieve ID: {e:?}");
}
}
}
Err(e) => {
log::warn!("Ignoring advisory: {:?}", e);
log::warn!("Ignoring advisory {}: {:?}", e.url(), e);
}
}
Ok::<_, anyhow::Error>(())
Expand Down

0 comments on commit c9bf5a2

Please sign in to comment.