pub fn from_rustsec(
        advisory: Advisory,
        mod_times: &GitModificationTimes,
        path: GitPath<'_>,
    ) -> Self {
        let metadata = advisory.metadata;

        // Assemble the URLs to put into 'references' field
        let mut reference_urls: Vec<Url> = Vec::new();
        // link to the package on crates.io
        let package_url = "https://crates.io/crates/".to_owned() + metadata.package.as_str();
        reference_urls.push(Url::parse(&package_url).unwrap());
        // link to human-readable RustSec advisory
        let advisory_url = format!(
            "https://rustsec.org/advisories/{}.html",
            metadata.id.as_str()
        );
        reference_urls.push(Url::parse(&advisory_url).unwrap());
        // primary URL for the issue specified in the advisory
        if let Some(url) = metadata.url {
            reference_urls.push(url);
        }
        // other references
        reference_urls.extend(metadata.references.into_iter());

        OsvAdvisory {
            id: metadata.id,
            modified: git2_time_to_rfc3339(mod_times.for_path(path)),
            published: rustsec_date_to_rfc3339(&metadata.date),
            affected: vec![OsvAffected {
                package: (&metadata.package).into(),
                ranges: vec![timeline_for_advisory(&advisory.versions)],
                ecosystem_specific: OsvEcosystemSpecific {
                    affects: advisory.affected.unwrap_or_default().into(),
                },
                database_specific: OsvDatabaseSpecific {
                    categories: metadata.categories,
                    cvss: metadata.cvss,
                    informational: metadata.informational,
                },
            }],
            withdrawn: metadata.withdrawn.map(|d| rustsec_date_to_rfc3339(&d)),
            aliases: metadata.aliases,
            related: metadata.related,
            summary: metadata.title,
            details: metadata.description,
            references: osv_references(reference_urls),
        }
    }
/// Converts a single RustSec advisory to OSV format.
/// `path` is the path to the advisory file. It must be relative to the git repository root.
Converts a single RustSec advisory to OSV format.
`path` is the path to the advisory file. It must be relative to the git repository root.
Converts a single RustSec advisory to OSV format . ` path ` is the path to the advisory file . It must be relative to the git repository root .
pub fn from_rustsec(
        advisory: Advisory,
        mod_times: &GitModificationTimes,
        path: GitPath<'_>,
    ) -> Self {
        let metadata = advisory.metadata;
        // Assemble the URLs to put into 'references' field
        let mut reference_urls: Vec<Url> = Vec::new();
        // link to the package on crates.io
        let package_url = "https://crates.io/crates/".to_owned() + metadata.package.as_str();
        reference_urls.push(Url::parse(&package_url).unwrap());
        // link to human-readable RustSec advisory
        let advisory_url = format!(
            "https://rustsec.org/advisories/{}.html",
            metadata.id.as_str()
        );
        reference_urls.push(Url::parse(&advisory_url).unwrap());
        // primary URL for the issue specified in the advisory
        if let Some(url) = metadata.url {
            reference_urls.push(url);
        }
        // other references
        reference_urls.extend(metadata.references.into_iter());
        OsvAdvisory {
            id: metadata.id,
            modified: git2_time_to_rfc3339(mod_times.for_path(path)),
            published: rustsec_date_to_rfc3339(&metadata.date),
            affected: vec![OsvAffected {
                package: (&metadata.package).into(),
                ranges: vec![timeline_for_advisory(&advisory.versions)],
                ecosystem_specific: OsvEcosystemSpecific {
                    affects: advisory.affected.unwrap_or_default().into(),
                },
                database_specific: OsvDatabaseSpecific {
                    categories: metadata.categories,
                    cvss: metadata.cvss,
                    informational: metadata.informational,
                },
            }],
            withdrawn: metadata.withdrawn.map(|d| rustsec_date_to_rfc3339(&d)),
            aliases: metadata.aliases,
            related: metadata.related,
            summary: metadata.title,
            details: metadata.description,
            references: osv_references(reference_urls),
        }
    }
pub fn from_rustsec ( advisory : Advisory , mod_times : & GitModificationTimes , path : GitPath < ' _ > , ) -> Self { let metadata = advisory . metadata ; // Assemble the URLs to put into 'references' field let mut reference_urls : Vec < Url > = Vec :: new ( ) ; // link to the package on crates.io let package_url = " " . to_owned ( ) + metadata . package . as_str ( ) ; reference_urls . push ( Url :: parse ( & package_url ) . unwrap ( ) ) ; // link to human-readable RustSec advisory let advisory_url = format ! ( " " metadata id as_str ( ) ) ; reference_urls . push ( Url :: parse ( & advisory_url ) . unwrap ( ) ) ; // primary URL for the issue specified in the advisory if let Some ( url ) = metadata . url { reference_urls . push ( url ) ; } // other references reference_urls . extend ( metadata . references . into_iter ( ) ) ; OsvAdvisory { id : metadata . id , modified : git2_time_to_rfc3339 ( mod_times . for_path ( path ) ) , published : rustsec_date_to_rfc3339 ( & metadata . date ) , affected : vec ! [ OsvAffected { package ( metadata package ) into ( ) ranges vec [ timeline_for_advisory ( advisory versions ) ] ecosystem_specific OsvEcosystemSpecific { affects advisory affected unwrap_or_default ( ) into ( ) } database_specific OsvDatabaseSpecific { categories metadata categories cvss metadata cvss informational metadata informational } } ] , withdrawn : metadata . withdrawn . map ( | d | rustsec_date_to_rfc3339 ( & d ) ) , aliases : metadata . aliases , related : metadata . related , summary : metadata . title , details : metadata . description , references : osv_references ( reference_urls ) , } }
Converts a single RustSec advisory to OSV format.
Converts a single RustSec advisory to OSV format .
advisory
Advisory
mod_times
&GitModificationTimes
path
GitPath<'_>
advisory
Advisory
mod_times
&GitModificationTimes
path
GitPath<'_>