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