AdvisorySource

Trait AdvisorySource 

Source
pub trait AdvisorySource: Send + Sync {
    // Required methods
    fn fetch<'life0, 'async_trait>(
        &'life0 self,
        since: Option<DateTime<Utc>>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Advisory>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn name(&self) -> &str;
}
Expand description

Trait for vulnerability advisory data sources.

Implement this trait to add support for a new vulnerability database.

§Example

use vulnera_advisors::sources::AdvisorySource;
use vulnera_advisors::models::Advisory;
use async_trait::async_trait;

struct MySource;

#[async_trait]
impl AdvisorySource for MySource {
    async fn fetch(&self, since: Option<DateTime<Utc>>) -> Result<Vec<Advisory>> {
        // Fetch advisories from your source
        Ok(vec![])
    }

    fn name(&self) -> &str {
        "MySource"
    }
}

Required Methods§

Source

fn fetch<'life0, 'async_trait>( &'life0 self, since: Option<DateTime<Utc>>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Advisory>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch advisories, optionally since a given timestamp.

If since is provided, implementations should attempt to return only advisories modified after that timestamp (incremental sync). If since is None, implementations should return all advisories (full sync).

Source

fn name(&self) -> &str

Get the name of this source (used for logging and metadata).

Implementors§