VulnerabilityManager

Struct VulnerabilityManager 

Source
pub struct VulnerabilityManager { /* private fields */ }
Expand description

Main vulnerability manager for syncing and querying advisories.

Implementations§

Source§

impl VulnerabilityManager

Source

pub async fn new(config: Config) -> Result<Self>

Create a new manager from a Config.

This is a convenience method. For more control, use VulnerabilityManagerBuilder.

Source

pub fn builder() -> VulnerabilityManagerBuilder

Create a builder for custom configuration.

Source

pub fn store(&self) -> &Arc<dyn AdvisoryStore + Send + Sync>

Get a reference to the underlying store.

Source

pub async fn health_check(&self) -> Result<HealthStatus>

Check the health of the store connection.

Source

pub async fn sync_all(&self) -> Result<()>

Sync advisories from all configured sources.

Source

pub async fn reset_sync(&self, source: &str) -> Result<()>

Reset the sync timestamp for a specific source.

This forces a full re-sync on the next sync_all() call.

Source

pub async fn reset_all_syncs(&self) -> Result<()>

Reset all sync timestamps, forcing a full re-sync of all sources.

Source

pub async fn sync_enrichment(&self) -> Result<()>

Sync enrichment data (KEV and EPSS).

Source

pub async fn query( &self, ecosystem: &str, package: &str, ) -> Result<Vec<Advisory>>

Query advisories for a specific package.

Source

pub async fn query_enriched( &self, ecosystem: &str, package: &str, ) -> Result<Vec<Advisory>>

Query advisories with enrichment data.

Source

pub async fn query_batch( &self, packages: &[PackageKey], ) -> Result<HashMap<PackageKey, Vec<Advisory>>>

Query multiple packages in a batch (concurrent).

All queries run in parallel for maximum throughput.

Source

pub async fn matches( &self, ecosystem: &str, package: &str, version: &str, ) -> Result<Vec<Advisory>>

Check if a specific package version is affected by any vulnerabilities.

Source

pub async fn matches_with_options( &self, ecosystem: &str, package: &str, version: &str, options: &MatchOptions, ) -> Result<Vec<Advisory>>

Check if a package version is affected, with filtering options.

Source

pub async fn fetch_epss_scores( &self, cve_ids: &[&str], ) -> Result<HashMap<String, f64>>

Fetch live EPSS scores for CVEs (not from cache).

Source

pub async fn is_kev(&self, cve_id: &str) -> Result<bool>

Check if a CVE is in the CISA KEV catalog.

Source

pub async fn query_ossindex(&self, purls: &[String]) -> Result<Vec<Advisory>>

Query OSS Index for vulnerabilities affecting the given PURLs.

This method provides automatic caching:

  • First checks the cache for each PURL
  • Only queries OSS Index for cache misses
  • Caches results for future queries
§Arguments
  • purls - Package URLs to query (e.g., “pkg:npm/lodash@4.17.20”)
§Returns

Vector of advisories for all vulnerabilities found.

§Errors

Returns an error if OSS Index is not configured or if the query fails.

§Example
use vulnera_advisors::{VulnerabilityManager, Purl};

let manager = VulnerabilityManager::builder()
    .redis_url("redis://localhost:6379")
    .with_ossindex(None)
    .build()?;

let purls = vec![
    Purl::new("npm", "lodash").with_version("4.17.20").to_string(),
];

let advisories = manager.query_ossindex(&purls).await?;
Source

pub async fn query_batch_with_ossindex( &self, packages: &[PackageKey], ) -> Result<HashMap<PackageKey, Vec<Advisory>>>

Query OSS Index for vulnerabilities with fallback to stored advisories.

This method first queries OSS Index, then falls back to the local store if the OSS Index query fails or returns no results.

§Arguments
  • packages - List of packages to query (ecosystem, name, optional version)
§Returns

Map of package keys to their advisories.

Source

pub async fn invalidate_ossindex_cache(&self, purls: &[String]) -> Result<()>

Invalidate cached OSS Index results for specific PURLs.

Use this to force a fresh query on the next call.

Source

pub async fn invalidate_all_ossindex_cache(&self) -> Result<()>

Invalidate all cached OSS Index results.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more