Struct csaf_walker::metadata::MetadataRetriever
source · 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 more