Skip to content

Commit 8339e12

Browse files
authored
Merge pull request #54 from gcmurphy/fix/1.6.7
Restores some ecosystems and the publish field
2 parents 54b0d5d + ddda882 commit 8339e12

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ url = { version = "2.3.1", optional = true }
2424

2525
[dev-dependencies]
2626
comfy-table = "7.1.1"
27-
cargo-audit = "0.21.0"
28-
cargo-fuzz = "0.12.0"
2927
cargo-release = "0.25.10"
3028
textwrap = { version = "0.16.1", features = ["default", "terminal_size"] }
3129
tokio-test = "0.4.3"

src/schema.rs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub enum Ecosystem {
3636
Android,
3737
Bioconductor,
3838
Bitnami,
39+
Chainguard,
3940
ConanCenter,
4041
CRAN,
4142
CratesIO,
@@ -49,17 +50,21 @@ pub enum Ecosystem {
4950
Hex,
5051
JavaScript,
5152
Linux,
53+
Mageia(String),
5254
Maven(String),
5355
Npm,
5456
NuGet,
57+
OpenSUSE(Option<String>),
5558
OssFuzz,
5659
Packagist,
5760
PhotonOS(Option<String>),
5861
Pub,
5962
PyPI,
6063
Python,
64+
RedHat(Option<String>),
6165
RockyLinux(Option<String>),
6266
RubyGems,
67+
SUSE(Option<String>),
6368
SwiftURL,
6469
Ubuntu {
6570
version: String,
@@ -86,6 +91,7 @@ impl Serialize for Ecosystem {
8691
Ecosystem::Android => serializer.serialize_str("Android"),
8792
Ecosystem::Bioconductor => serializer.serialize_str("Bioconductor"),
8893
Ecosystem::Bitnami => serializer.serialize_str("Bitnami"),
94+
Ecosystem::Chainguard => serializer.serialize_str("Chainguard"),
8995
Ecosystem::ConanCenter => serializer.serialize_str("ConanCenter"),
9096
Ecosystem::CRAN => serializer.serialize_str("CRAN"),
9197
Ecosystem::CratesIO => serializer.serialize_str("crates.io"),
@@ -102,6 +108,7 @@ impl Serialize for Ecosystem {
102108
Ecosystem::Hex => serializer.serialize_str("Hex"),
103109
Ecosystem::JavaScript => serializer.serialize_str("JavaScript"),
104110
Ecosystem::Linux => serializer.serialize_str("Linux"),
111+
Ecosystem::Mageia(release) => serializer.serialize_str(&format!("Mageia:{}", release)),
105112
Ecosystem::Maven(repository) => {
106113
let mvn: String = match repository.as_str() {
107114
"https://repo.maven.apache.org/maven2" => "Maven".to_string(),
@@ -111,6 +118,10 @@ impl Serialize for Ecosystem {
111118
}
112119
Ecosystem::Npm => serializer.serialize_str("npm"),
113120
Ecosystem::NuGet => serializer.serialize_str("NuGet"),
121+
Ecosystem::OpenSUSE(None) => serializer.serialize_str("OpenSUSE"),
122+
Ecosystem::OpenSUSE(Some(release)) => {
123+
serializer.serialize_str(&format!("OpenSUSE:{}", release))
124+
}
114125
Ecosystem::OssFuzz => serializer.serialize_str("OSS-Fuzz"),
115126
Ecosystem::Packagist => serializer.serialize_str("Packagist"),
116127
Ecosystem::PhotonOS(None) => serializer.serialize_str("Photon OS"),
@@ -120,11 +131,19 @@ impl Serialize for Ecosystem {
120131
Ecosystem::Pub => serializer.serialize_str("Pub"),
121132
Ecosystem::PyPI => serializer.serialize_str("PyPI"),
122133
Ecosystem::Python => serializer.serialize_str("Python"),
134+
Ecosystem::RedHat(None) => serializer.serialize_str("Red Hat"),
135+
Ecosystem::RedHat(Some(release)) => {
136+
serializer.serialize_str(&format!("Red Hat:{}", release))
137+
}
123138
Ecosystem::RockyLinux(None) => serializer.serialize_str("Rocky Linux"),
124139
Ecosystem::RockyLinux(Some(release)) => {
125140
serializer.serialize_str(&format!("Rocky Linux:{}", release))
126141
}
127142
Ecosystem::RubyGems => serializer.serialize_str("RubyGems"),
143+
Ecosystem::SUSE(None) => serializer.serialize_str("SUSE"),
144+
Ecosystem::SUSE(Some(release)) => {
145+
serializer.serialize_str(&format!("SUSE:{}", release))
146+
}
128147
Ecosystem::SwiftURL => serializer.serialize_str("SwiftURL"),
129148
Ecosystem::Ubuntu {
130149
version: v,
@@ -181,6 +200,7 @@ impl<'de> Deserialize<'de> for Ecosystem {
181200
"Android" => Ok(Ecosystem::Android),
182201
"Bioconductor" => Ok(Ecosystem::Bioconductor),
183202
"Bitnami" => Ok(Ecosystem::Bitnami),
203+
"Chainguard" => Ok(Ecosystem::Chainguard),
184204
"ConanCenter" => Ok(Ecosystem::ConanCenter),
185205
"CRAN" => Ok(Ecosystem::CRAN),
186206
"crates.io" => Ok(Ecosystem::CratesIO),
@@ -197,6 +217,12 @@ impl<'de> Deserialize<'de> for Ecosystem {
197217
"Hex" => Ok(Ecosystem::Hex),
198218
"JavaScript" => Ok(Ecosystem::JavaScript),
199219
"Linux" => Ok(Ecosystem::Linux),
220+
_ if value.starts_with("Mageia:") => Ok(Ecosystem::Mageia(
221+
value
222+
.strip_prefix("Mageia:")
223+
.map(|v| v.to_string())
224+
.unwrap(),
225+
)),
200226
"Maven" | "Maven:" => Ok(Ecosystem::Maven(
201227
"https://repo.maven.apache.org/maven2".to_string(),
202228
)),
@@ -205,6 +231,10 @@ impl<'de> Deserialize<'de> for Ecosystem {
205231
)),
206232
"npm" => Ok(Ecosystem::Npm),
207233
"NuGet" => Ok(Ecosystem::NuGet),
234+
"OpenSUSE" => Ok(Ecosystem::OpenSUSE(None)),
235+
_ if value.starts_with("OpenSUSE:") => Ok(Ecosystem::OpenSUSE(
236+
value.strip_prefix("OpenSUSE:").map(|v| v.to_string()),
237+
)),
208238
"OSS-Fuzz" => Ok(Ecosystem::OssFuzz),
209239
"Packagist" => Ok(Ecosystem::Packagist),
210240
"Photon OS" | "Photon OS:" => Ok(Ecosystem::PhotonOS(None)),
@@ -214,11 +244,19 @@ impl<'de> Deserialize<'de> for Ecosystem {
214244
"Pub" => Ok(Ecosystem::Pub),
215245
"PyPI" => Ok(Ecosystem::PyPI),
216246
"Python" => Ok(Ecosystem::Python),
247+
"Red Hat" => Ok(Ecosystem::RedHat(None)),
248+
_ if value.starts_with("Red Hat:") => Ok(Ecosystem::RedHat(
249+
value.strip_prefix("Red Hat:").map(|v| v.to_string()),
250+
)),
217251
"Rocky Linux" | "Rocky Linux:" => Ok(Ecosystem::RockyLinux(None)),
218252
_ if value.starts_with("Rocky Linux:") => Ok(Ecosystem::RockyLinux(
219253
value.strip_prefix("Rocky Linux:").map(|v| v.to_string()),
220254
)),
221255
"RubyGems" => Ok(Ecosystem::RubyGems),
256+
"SUSE" => Ok(Ecosystem::SUSE(None)),
257+
_ if value.starts_with("SUSE:") => Ok(Ecosystem::SUSE(
258+
value.strip_prefix("SUSE:").map(|v| v.to_string()),
259+
)),
222260
"SwiftURL" => Ok(Ecosystem::SwiftURL),
223261
_ if value.starts_with("Ubuntu:Pro:") => {
224262
value.strip_prefix("Ubuntu:Pro:").map_or(
@@ -547,7 +585,7 @@ pub struct Vulnerability {
547585

548586
/// The published field gives the time the entry should be considered to have been published,
549587
/// as an RFC3339-formatted time stamp in UTC (ending in “Z”).
550-
pub published: DateTime<Utc>,
588+
pub published: Option<DateTime<Utc>>,
551589

552590
/// The modified field gives the time the entry was last modified, as an RFC3339-formatted
553591
/// timestamptime stamp in UTC (ending in “Z”).
@@ -621,7 +659,7 @@ mod tests {
621659
let vuln = Vulnerability {
622660
schema_version: Some("1.3.0".to_string()),
623661
id: "OSV-2020-484".to_string(),
624-
published: chrono::Utc::now(),
662+
published: Some(chrono::Utc::now()),
625663
modified: chrono::Utc::now(),
626664
withdrawn: None,
627665
aliases: None,

0 commit comments

Comments
 (0)