pub struct MetadataRetriever {
pub base_url: String,
}Expand description
A metadata source implementing the CSAF metadata discovery process.
Fields§
§base_url: StringImplementations§
Source§impl MetadataRetriever
impl MetadataRetriever
pub fn new(base_url: impl Into<String>) -> Self
Sourcepub async fn get_metadata_url_from_security_text(
fetcher: &Fetcher,
host_url: String,
) -> Result<Option<Url>, Error>
pub async fn get_metadata_url_from_security_text( fetcher: &Fetcher, host_url: String, ) -> Result<Option<Url>, Error>
Fetch a security.txt and extract all CSAF entries.
In order for a CSAF entry to be considered, it needs to have a scheme of https and parse
as a URL.
Sourcepub async fn approach_full_url(
&self,
fetcher: &Fetcher,
) -> Result<Option<ProviderMetadata>, Error>
pub async fn approach_full_url( &self, fetcher: &Fetcher, ) -> Result<Option<ProviderMetadata>, Error>
Treat the source as a URL and try to retrieve it
If the source is not a URL, we consider it “not found”. If the URL parses but cannot be found, that’s an error.
Sourcepub async fn approach_well_known(
&self,
fetcher: &Fetcher,
) -> Result<Option<ProviderMetadata>, Error>
pub async fn approach_well_known( &self, fetcher: &Fetcher, ) -> Result<Option<ProviderMetadata>, Error>
Retrieve provider metadata through the full well-known URL.
If retrieving the constructed URL returns a 404, we succeed with Ok(None).
Sourcepub async fn approach_dns(
&self,
fetcher: &Fetcher,
) -> Result<Option<ProviderMetadata>, Error>
pub async fn approach_dns( &self, fetcher: &Fetcher, ) -> Result<Option<ProviderMetadata>, Error>
Retrieve provider metadata through the DNS path of provided URL.
As it is hard to detect a “host not found” error, compared to any other connection error, we do a DNS pre-flight check. If the hostname resolves into an IP address, we assume the following HTTP request should not fail due to a “host not found” error.
Sourcepub async fn approach_security_txt(
&self,
fetcher: &Fetcher,
path: &str,
) -> Result<Option<ProviderMetadata>, Error>
pub async fn approach_security_txt( &self, fetcher: &Fetcher, path: &str, ) -> Result<Option<ProviderMetadata>, Error>
Retrieving provider metadata via the security text from the provided URL.
This takes the source as domain, and the provided path to compose a URL. If the security.txt
cannot be found or doesn’t contain a valid CSAF entry, it will return Ok(None).
Trait Implementations§
Source§impl Clone for MetadataRetriever
impl Clone for MetadataRetriever
Source§fn clone(&self) -> MetadataRetriever
fn clone(&self) -> MetadataRetriever
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MetadataRetriever
impl Debug for MetadataRetriever
Source§impl MetadataSource for MetadataRetriever
impl MetadataSource for MetadataRetriever
fn load_metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
fetcher: &'life1 Fetcher,
) -> Pin<Box<dyn Future<Output = Result<ProviderMetadata, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl Freeze for MetadataRetriever
impl RefUnwindSafe for MetadataRetriever
impl Send for MetadataRetriever
impl Sync for MetadataRetriever
impl Unpin for MetadataRetriever
impl UnsafeUnpin for MetadataRetriever
impl UnwindSafe for MetadataRetriever
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more