csaf_walker/
lib.rs

1#![deny(clippy::unwrap_used)]
2
3//! Walking through CSAF documents
4//!
5//! ## Idea
6//!
7//! The basic idea is to provide a mechanism to walk over documents from differences sources
8//! ([`source::HttpSource`] or [`source::FileSource`]). Then
9//! chaining visitors in a layered fashion depending on your use case, extending the information
10//! known about a CSAF document. That doesn't mean to actually parse the document, but the ensure
11//! things like integrity, by digests and signatures.
12//!
13//! The stack allows one to customize the walking process, like skipping existing documents, or
14//! processing only changed documents.
15//!
16//! The last step, most likely, is to do something with a discovered document (like storing,
17//! uploading, evaluating). This is up to user to implement this. However, for some common use
18//! cases, the [`csaf_cli`](https://crates.io/crates/csaf-cli) crate might have some
19//! out-of-the-box tooling for the command line.
20//!
21//! ## Example
22//!
23//! A simple example for iterating over a source of CSAF documents:
24//!
25//! ```rust
26//! use anyhow::Result;
27//! use url::Url;
28//! use csaf_walker::metadata::MetadataRetriever;
29//! use csaf_walker::source::{DispatchSource, HttpSource};
30//! use csaf_walker::walker::Walker;
31//! use csaf_walker::retrieve::RetrievingVisitor;
32//! use csaf_walker::validation::{ValidatedAdvisory, ValidationError, ValidationVisitor};
33//! use walker_common::fetcher::Fetcher;
34//!
35//! async fn walk() -> Result<()> {
36//!   let fetcher = Fetcher::new(Default::default()).await?;
37//!   let metadata = MetadataRetriever::new("redhat.com");
38//!   let source = HttpSource::new(metadata, fetcher, Default::default());
39//!
40//!   Walker::new(source.clone())
41//!     .walk(RetrievingVisitor::new(
42//!         source.clone(),
43//!         ValidationVisitor::new(
44//!             move |advisory: Result<ValidatedAdvisory, ValidationError<_>>| async move {
45//!                 log::info!("Found advisory: {advisory:?}");
46//!                 Ok::<_, anyhow::Error>(())
47//!             },
48//!         )
49//!     ))
50//!     .await?;
51//!
52//!   Ok(())
53//! }
54//! ```
55
56pub mod discover;
57pub mod metadata;
58pub mod model;
59pub mod report;
60pub mod retrieve;
61pub mod rolie;
62pub mod source;
63pub mod validation;
64pub mod visitors;
65pub mod walker;
66
67#[cfg(feature = "csaf")]
68pub mod verification;
69
70/// re-export common
71pub use walker_common as common;