From 860d1a78bfa53dcdb0c5b13a9afd91d50295d95f Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar Date: Fri, 9 Oct 2026 19:28:49 +0000 Subject: [PATCH] fix(eol): end-of-life findings are high, soon is medium, and non-LTS Yocto releases warn two months ahead (#562) --- .../src/pipeline/build_lifecycle.rs | 24 ++++++++++-- .../src/pipeline/dotnet/config.rs | 4 +- .../src/pipeline/yocto_pins/release.rs | 31 ++++++++++----- compliance-core/src/models/mod.rs | 3 +- compliance-core/src/models/yocto.rs | 38 ++++++++++++++----- docs/guide/yocto.md | 2 +- 6 files changed, 76 insertions(+), 26 deletions(-) diff --git a/compliance-agent/src/pipeline/build_lifecycle.rs b/compliance-agent/src/pipeline/build_lifecycle.rs index db5dcef..3c18109 100644 --- a/compliance-agent/src/pipeline/build_lifecycle.rs +++ b/compliance-agent/src/pipeline/build_lifecycle.rs @@ -189,7 +189,7 @@ fn check_adt_project(root: &Path, dir: &Path) -> Vec { ), remediation: "Raise the target and minimum API level to a supported Android \ release (after migrating the build to Gradle) and test on it.", - severity: Severity::Medium, + severity: Severity::High, cwe: "CWE-1104", path, line: Some(line), @@ -270,7 +270,7 @@ fn check_xcode_project(root: &Path, file: &Path) -> Vec { remediation: "Migrate the code to Swift 5 or later (Xcode migrates Swift 4 \ code; older code through an Xcode release that still reads it) \ and set SWIFT_VERSION accordingly.", - severity: Severity::Medium, + severity: Severity::High, cwe: "CWE-1104", path, line: Some(line), @@ -415,7 +415,7 @@ fn check_unity_project(root: &Path, project: &Path) -> Vec { relative(root, project) ), remediation: "Upgrade the project to a supported Unity LTS release.", - severity: Severity::Medium, + severity: Severity::High, cwe: "CWE-1104", path, line: Some(1), @@ -466,8 +466,24 @@ mod tests { Tree(dir) } + /// The hits as `rule path:line`; every end-of-support hit is high, like + /// every other end-of-life finding, except the minimum OS an app still + /// installs on, which stays low until that severity is decided. fn hits(t: &Tree) -> Vec { - check_tree(&t.0) + let found = check_tree(&t.0); + for hit in found + .iter() + .filter(|h| h.rule_id.ends_with("-end-of-support")) + { + let expected = match hit.rule_id { + "ios-deployment-target-end-of-support" | "android-min-sdk-end-of-support" => { + Severity::Low + } + _ => Severity::High, + }; + assert_eq!(hit.severity, expected, "{}", hit.rule_id); + } + found .into_iter() .map(|h| format!("{} {}:{}", h.rule_id, h.path, h.line.unwrap_or(0))) .collect() diff --git a/compliance-agent/src/pipeline/dotnet/config.rs b/compliance-agent/src/pipeline/dotnet/config.rs index 847031e..369419d 100644 --- a/compliance-agent/src/pipeline/dotnet/config.rs +++ b/compliance-agent/src/pipeline/dotnet/config.rs @@ -494,7 +494,7 @@ fn check_frameworks(root: &Path, today: chrono::NaiveDate) -> Vec { ), remediation: "Retarget the project to a supported version (.NET Framework \ 4.8/4.8.1, or a supported .NET release) and test it there.", - severity: Severity::Medium, + severity: Severity::High, cwe: "CWE-1104", path: project.path.clone(), line: Some(tf.line), @@ -677,6 +677,8 @@ mod tests { ["dotnet-framework-end-of-support Legacy/Legacy.csproj:3"] ); assert_eq!(hits[0].cwe, "CWE-1104"); + // End of life is high, like every other end-of-life finding. + assert_eq!(hits[0].severity, Severity::High); assert!( hits[0].title.contains(".NET Framework 4.5"), "{}", diff --git a/compliance-agent/src/pipeline/yocto_pins/release.rs b/compliance-agent/src/pipeline/yocto_pins/release.rs index f9a5fe6..4316521 100644 --- a/compliance-agent/src/pipeline/yocto_pins/release.rs +++ b/compliance-agent/src/pipeline/yocto_pins/release.rs @@ -1,9 +1,10 @@ //! The Yocto release a layer tree builds, its support period, and a finding //! when that period is over or ends soon. -use chrono::{Months, NaiveDate}; +use chrono::NaiveDate; use compliance_core::models::{ - display_codename, Finding, LayerPin, ReleaseBasis, ScanType, Severity, Support, YoctoRelease, + display_codename, soon_window, Finding, LayerPin, ReleaseBasis, ScanType, Severity, Support, + YoctoRelease, }; use crate::pipeline::dedup; @@ -13,17 +14,14 @@ use crate::pipeline::recipe_lint::Layer; pub const SCANNER: &str = "yocto-release"; /// The rule of a release past its end of life. pub const RULE_EOL: &str = "yocto-release-eol"; -/// The rule of a release whose end of life is within six months. +/// The rule of a release whose end of life is near: within six months for an +/// LTS release, two for any other ([`soon_window`]). pub const RULE_EOL_SOON: &str = "yocto-release-eol-soon"; /// Where the support periods come from. pub const SOURCE_URL: &str = "https://wiki.yoctoproject.org/wiki/Releases"; /// When [`RELEASES`] was checked against its sources. pub const CHECKED_ON: &str = "2026-10-09"; -/// How far ahead an end of life counts as soon (as [`YoctoRelease::support`] -/// counts it): the current LTS is one supported for longer. -const SOON: Months = Months::new(6); - /// One Yocto Project release. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct ReleaseInfo { @@ -235,9 +233,9 @@ pub(crate) fn derive(pins: &[LayerPin], layers: &[Layer]) -> Option Option<&'static ReleaseInfo> { - let horizon = today.checked_add_months(SOON)?; + let horizon = today.checked_add_months(soon_window(true))?; RELEASES .iter() .filter(|r| r.lts && r.released <= today && r.end_of_life > horizon) @@ -260,7 +258,7 @@ fn basis_text(basis: &ReleaseBasis, file: &str) -> String { } /// The support-status finding of `repo_id` for `release` on `today`; -/// `None` while it is supported for more than six months. +/// `None` while its end of life is not yet soon ([`soon_window`]). pub(crate) fn finding(repo_id: &str, release: &YoctoRelease, today: NaiveDate) -> Option { let (rule, severity, title, status) = match release.support(today) { Support::Supported => return None, @@ -521,6 +519,19 @@ mod tests { assert_ne!(other.fingerprint, f.fingerprint); } + #[test] + fn a_release_without_lts_warns_two_months_ahead() { + // Whinlatter (5.3) ends on 2026-06-15. + let whinlatter = release_of("whinlatter"); + assert!(finding("t1", &whinlatter, date(2026, 4, 14)).is_none()); + let soon = finding("t1", &whinlatter, date(2026, 4, 15)).expect("finding"); + assert_eq!(soon.rule_id.as_deref(), Some(RULE_EOL_SOON)); + assert_eq!(soon.severity, Severity::Medium); + let ended = finding("t1", &whinlatter, date(2026, 6, 16)).expect("finding"); + assert_eq!(ended.rule_id.as_deref(), Some(RULE_EOL)); + assert_eq!(ended.severity, Severity::High); + } + #[test] fn the_rules_are_bound_in_the_control_map() { let map = control_map::ControlMap::cra().expect("map"); diff --git a/compliance-core/src/models/mod.rs b/compliance-core/src/models/mod.rs index 0811b85..4b85fd7 100644 --- a/compliance-core/src/models/mod.rs +++ b/compliance-core/src/models/mod.rs @@ -80,5 +80,6 @@ pub use werkbank::{ LeasedJob, }; pub use yocto::{ - display_codename, LayerPin, LayerPins, PinSource, ReleaseBasis, Support, YoctoRelease, + display_codename, soon_window, LayerPin, LayerPins, PinSource, ReleaseBasis, Support, + YoctoRelease, }; diff --git a/compliance-core/src/models/yocto.rs b/compliance-core/src/models/yocto.rs index 53c12b2..1065235 100644 --- a/compliance-core/src/models/yocto.rs +++ b/compliance-core/src/models/yocto.rs @@ -84,15 +84,24 @@ pub fn display_codename(codename: &str) -> String { .unwrap_or_default() } -/// How far ahead an end of life counts as soon. -const SOON: Months = Months::new(6); +/// How far ahead the end of life of a release counts as soon: six months for +/// a long term support release, two for any other. A non-LTS release is +/// supported for about seven months, so a six-month window would warn from +/// its first weeks. +pub const fn soon_window(lts: bool) -> Months { + if lts { + Months::new(6) + } else { + Months::new(2) + } +} /// Where a release's support stands on a day. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Support { - /// Supported for more than six months. + /// Supported for longer than its [`soon_window`]. Supported, - /// Its support ends within six months. + /// Its support ends within its [`soon_window`]. EndsSoon, /// Its support has ended (after its last day). Ended, @@ -104,7 +113,7 @@ impl YoctoRelease { if self.end_of_life < today { Support::Ended } else if today - .checked_add_months(SOON) + .checked_add_months(soon_window(self.lts)) .is_none_or(|horizon| self.end_of_life <= horizon) { Support::EndsSoon @@ -135,11 +144,11 @@ pub struct LayerPins { mod tests { use super::*; - fn release(end_of_life: NaiveDate) -> YoctoRelease { + fn release(end_of_life: NaiveDate, lts: bool) -> YoctoRelease { YoctoRelease { codename: "scarthgap".into(), version: "5.0".into(), - lts: true, + lts, end_of_life, basis: ReleaseBasis::CoreLayer, file: "conf/layer.conf".into(), @@ -153,9 +162,9 @@ mod tests { } #[test] - fn support_ends_soon_within_six_months_and_ends_after_its_last_day() { + fn lts_support_ends_soon_within_six_months_and_ends_after_its_last_day() { let date = |y, m, d| NaiveDate::from_ymd_opt(y, m, d).expect("date"); - let scarthgap = release(date(2028, 4, 30)); + let scarthgap = release(date(2028, 4, 30), true); assert_eq!(scarthgap.support(date(2026, 10, 9)), Support::Supported); assert_eq!(scarthgap.support(date(2027, 10, 29)), Support::Supported); assert_eq!(scarthgap.support(date(2027, 10, 30)), Support::EndsSoon); @@ -163,6 +172,17 @@ mod tests { assert_eq!(scarthgap.support(date(2028, 5, 1)), Support::Ended); } + #[test] + fn other_releases_end_soon_within_two_months() { + let date = |y, m, d| NaiveDate::from_ymd_opt(y, m, d).expect("date"); + // Whinlatter (5.3): released 2025-12-15, supported until 2026-06-15. + let whinlatter = release(date(2026, 6, 15), false); + assert_eq!(whinlatter.support(date(2025, 12, 20)), Support::Supported); + assert_eq!(whinlatter.support(date(2026, 4, 14)), Support::Supported); + assert_eq!(whinlatter.support(date(2026, 4, 15)), Support::EndsSoon); + assert_eq!(whinlatter.support(date(2026, 6, 16)), Support::Ended); + } + #[test] fn layer_pins_round_trip_through_bson() { let pins = LayerPins { diff --git a/docs/guide/yocto.md b/docs/guide/yocto.md index 70911d6..5d4111f 100644 --- a/docs/guide/yocto.md +++ b/docs/guide/yocto.md @@ -143,7 +143,7 @@ table below, there is no finding and the run lists **Yocto-Release | Rule (`yocto-release`) | When | Severity | CRA | Control | | --- | --- | --- | --- | --- | | `yocto-release-eol` | the release's end of life has passed | high | Annex I Part I (2)(c) security updates, Part II (2) remediation without delay | CRA-AI-22 | -| `yocto-release-eol-soon` | its end of life is within six months | medium | the same | CRA-AI-22 | +| `yocto-release-eol-soon` | its end of life is within six months (an LTS release) or two months (any other: a non-LTS release is supported for about seven months, so a longer window would warn from its first weeks) | medium | the same | CRA-AI-22 | The finding names the release, its end of life, where it was read from (the kas file, manifest or `layer.conf`) and the source of the date, and recommends