aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/advisory/ignored_security_advisory.rs
blob: 140c00b070d7df7fe31016d32f8ad7424e9bd91e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! ref: composer/src/Composer/Advisory/IgnoredSecurityAdvisory.php

use crate::advisory::SecurityAdvisory;
use chrono::{DateTime, Utc};
use indexmap::IndexMap;
use shirabe_php_shim::PhpMixed;
use shirabe_semver::constraint::AnyConstraint;

#[derive(Debug, serde::Serialize)]
#[serde(rename_all = "camelCase")]
pub struct IgnoredSecurityAdvisory {
    #[serde(flatten)]
    inner: SecurityAdvisory,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ignore_reason: Option<String>,
}

impl IgnoredSecurityAdvisory {
    pub fn new(
        package_name: String,
        advisory_id: String,
        affected_versions: AnyConstraint,
        title: String,
        sources: Vec<IndexMap<String, String>>,
        reported_at: DateTime<Utc>,
        cve: Option<String>,
        link: Option<String>,
        ignore_reason: Option<String>,
        severity: Option<String>,
    ) -> Self {
        let inner = SecurityAdvisory::new(
            package_name,
            advisory_id,
            affected_versions,
            title,
            sources,
            reported_at,
            cve,
            link,
            severity,
        );
        Self {
            inner,
            ignore_reason,
        }
    }
}