Skip to content

Commit 3b7e950

Browse files
committed
schema: Support more Ubuntu quirks
Ubuntu keep adding items to their ecosystem strings, resulting in the regex regularly failing and dropping all data. Instead, relax the regex to allow it to parse only the start of the line. Having most of the data is better than none. An example of this is "USN-7550-2.json". Additionally, Ubuntu OSVs now include an ubuntu specific severity. This otherwise matches the existing schema but is expected to contain a simple string rather than the CVSS score. An example of this is "UBUNTU-CVE-2025-9825.json".
1 parent 762f17d commit 3b7e950

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/schema.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ impl<'de> Deserialize<'de> for Ecosystem {
269269
"SwiftURL" => Ok(Ecosystem::SwiftURL),
270270
_ if value.starts_with("Ubuntu:") => {
271271
regex_switch!(value,
272-
r#"^Ubuntu(?::Pro)?(?::(?<fips>FIPS(?:-preview|-updates)?))?:(?<version>\d+\.\d+)(?::LTS)?(?::for:(?<specialized>.+))?$"# => {
272+
r#"^Ubuntu(?::Pro)?(?::(?<fips>FIPS(?:-preview|-updates)?))?:(?<version>\d+\.\d+)(?::LTS)?(?::for:(?<specialized>.+))?"# => {
273273
Ecosystem::Ubuntu {
274274
version: version.to_string(),
275275
metadata: (!specialized.is_empty()).then_some(specialized.to_string()),
@@ -473,6 +473,10 @@ pub enum SeverityType {
473473
#[serde(rename = "CVSS_V4")]
474474
CVSSv4,
475475

476+
/// A plain severity represented as a single word string defined by the Ubuntu security team.
477+
/// (e.g `"medium"`)
478+
Ubuntu,
479+
476480
/// The severity score was arrived at by using an unspecified
477481
/// scoring method.
478482
#[serde(rename = "UNSPECIFIED")]
@@ -786,6 +790,19 @@ mod tests {
786790
}
787791
);
788792

793+
let json_str = r#""Ubuntu:Pro:24.04:LTS:Realtime:Kernel""#;
794+
let ubuntu: Ecosystem = serde_json::from_str(json_str).unwrap();
795+
assert_eq!(
796+
ubuntu,
797+
Ecosystem::Ubuntu {
798+
version: "24.04".to_string(),
799+
pro: true,
800+
lts: true,
801+
fips: None,
802+
metadata: None,
803+
}
804+
);
805+
789806
let json_str = r#""Ubuntu:22.04:LTS:for:NVIDIA:BlueField""#;
790807
let ubuntu: Ecosystem = serde_json::from_str(json_str).unwrap();
791808
assert_eq!(

0 commit comments

Comments
 (0)