mod cache;
pub mod eol;
pub mod kev;
pub mod osv;
pub mod staleness;
mod stats;
mod traits;
pub mod vex;
pub use cache::{CacheKey, FileCache};
pub use eol::{EolClientConfig, EolEnricher, EolEnrichmentStats};
pub use kev::{KevCatalog, KevClient, KevClientConfig, KevEnrichmentStats};
pub use osv::{OsvEnricher, OsvEnricherConfig};
pub use staleness::{RegistryConfig, StalenessEnricher, StalenessEnrichmentStats};
pub use stats::{EnrichmentError, EnrichmentStats};
pub use traits::{NoOpEnricher, VulnerabilityEnricher};
pub use vex::{VexEnricher, VexEnrichmentStats};
use std::path::PathBuf;
use std::time::Duration;
#[derive(Debug, Clone)]
pub struct EnricherConfig {
pub enable_osv: bool,
pub enable_kev: bool,
pub enable_staleness: bool,
pub enable_eol: bool,
pub cache_dir: PathBuf,
pub cache_ttl: Duration,
pub bypass_cache: bool,
pub timeout: Duration,
pub stale_threshold_days: u32,
}
impl Default for EnricherConfig {
fn default() -> Self {
Self {
enable_osv: true,
enable_kev: true,
enable_staleness: false, enable_eol: false, cache_dir: default_cache_dir(),
cache_ttl: Duration::from_secs(24 * 3600), bypass_cache: false,
timeout: Duration::from_secs(30),
stale_threshold_days: 365,
}
}
}
fn default_cache_dir() -> PathBuf {
dirs::cache_dir()
.unwrap_or_else(|| PathBuf::from(".cache"))
.join("sbom-tools")
.join("osv")
}
mod dirs {
use std::path::PathBuf;
pub fn cache_dir() -> Option<PathBuf> {
#[cfg(target_os = "macos")]
{
std::env::var("HOME")
.ok()
.map(|h| PathBuf::from(h).join("Library").join("Caches"))
}
#[cfg(target_os = "linux")]
{
std::env::var("XDG_CACHE_HOME")
.ok()
.map(PathBuf::from)
.or_else(|| {
std::env::var("HOME")
.ok()
.map(|h| PathBuf::from(h).join(".cache"))
})
}
#[cfg(target_os = "windows")]
{
std::env::var("LOCALAPPDATA").ok().map(PathBuf::from)
}
#[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))]
{
std::env::var("HOME")
.ok()
.map(|h| PathBuf::from(h).join(".cache"))
}
}
}