Skip to content

#1628: Support for OS specific CVEs - #2370

Open
laert-ll wants to merge 1 commit into
devonfw:mainfrom
laert-ll:feature/1628-support-for-os-specific-cves
Open

#1628: Support for OS specific CVEs#2370
laert-ll wants to merge 1 commit into
devonfw:mainfrom
laert-ll:feature/1628-support-for-os-specific-cves

Conversation

@laert-ll

@laert-ll laert-ll commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

This PR fixes #1628

Implemented changes:

security.json CVE model extended so that a single CVE can express affected version ranges that only apply on specific operating systems.

  • Added an optional conditions map to the Cve model.
  • CveJsonDeserializer / CveJsonSerializer read and write conditions. It is only written when present, so existing security.json files remain unchanged.
  • Cve.isAffected(version, os) combines the global versions with the current OS's conditional ranges; Cve.merge(...) also merges the per-OS conditions.
  • Added CHANGELOG entry.

Testing instructions

Run mvn clean test

Manual (single machine):

  1. For a tool you can install, edit <IDE_ROOT>/urls/<tool>/<edition>/security.json (create if absent) and add a CVE whose global versions do NOT match the version you'll install, but whose conditions for your current OS (windows/linux/mac) do:
    { "issues": [ { "id": "CVE-TEST-OS", "severity": 9.0,
      "versions": ["(0,0.0.1)"], "conditions": { "linux": ["[<version>]"] } } ] }
  2. Set _VERSION= in ide.properties and run ide install CVE-TEST-OS is reported (matched only via the OS condition).
  3. Change the key to a different OS and re-run the CVE is no longer reported.

Checklist for this PR

Make sure everything is checked before merging this PR. For further info please also see
our DoD.

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat and not feature/921 fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summaries what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to In Progress and assigned to you or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labelled
    with internal
  • You have not changed any dependency in pom.xml files or otherwise if runtime dependencies changed, you have updated our LICENSE.asciidoc
  • You have formulated clear instructions on how to test your contribution under "Testing instructions"

@coveralls

coveralls commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 33406931848

Coverage increased (+0.02%) to 73.632%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 48 coverage regressions across 4 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

48 previously-covered lines in 4 files lost coverage.

File Lines Losing Coverage Coverage
com/devonfw/tools/ide/tool/ToolCommandlet.java 35 76.1%
com/devonfw/tools/ide/url/model/file/json/Cve.java 11 81.05%
com/devonfw/tools/ide/tool/ide/IdeToolCommandlet.java 1 87.42%
com/devonfw/tools/ide/url/model/file/json/CveJsonDeserializer.java 1 94.29%

Coverage Stats

Coverage Status
Relevant Lines: 18403
Covered Lines: 14163
Line Coverage: 76.96%
Relevant Branches: 8159
Covered Branches: 5395
Branch Coverage: 66.12%
Branches in Coverage %: Yes
Coverage Strength: 3.28 hits per line

💛 - Coveralls

@laert-ll laert-ll moved this from 🆕 New to 🏗 In progress in IDEasy board Aug 26, 2026
@laert-ll
laert-ll force-pushed the feature/1628-support-for-os-specific-cves branch from c5309e2 to e394226 Compare August 27, 2026 08:20
@laert-ll
laert-ll marked this pull request as ready for review August 27, 2026 08:22
@laert-ll laert-ll moved this from 🏗 In progress to Team Review in IDEasy board Aug 27, 2026
@laert-ll laert-ll added enhancement New feature or request security CVEs or other vulnerabilities labels Aug 27, 2026

@Ali-Shariati-Najafabadi Ali-Shariati-Najafabadi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pulled the branch and ran the full test suite locally plus checkstyle. Build is green and the core idea (isAffected/merge/JSON round-trip) works and is tested. Found one actual crash bug and a few smaller things worth looking at before merging, left inline.

jgen.writeStartObject();
for (Map.Entry<String, List<VersionRange>> condition : conditions.entrySet()) {
jgen.writeFieldName(condition.getKey());
writeArray(condition.getValue(), jgen);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an OS entry in conditions is explicitly null (e.g. "windows": null in security.json), it loads fine but blows up here with an NPE the moment the file gets re-saved/normalized, since writeArray iterates the list without a null check. Tested it locally, confirmed the crash. Worth guarding against in readConditions (either reject or default to an empty list) rather than passing the null through.


private Map<String, List<VersionRange>> readConditions(JsonParser p) throws IOException {

if (p.getCurrentToken() != JsonToken.START_OBJECT) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everywhere else in this deserializer (readArray, readValue) an unexpected token throws IllegalStateException. Here we just silently return null if conditions isn't an object. Feels inconsistent - a malformed conditions block would just get dropped without any error, which seems risky for security data.

assertThat(cve.isAffected(VersionIdentifier.of("2.0.6"), null)).isFalse();
}

@Test

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we get a test for merge() actually combining conditions from both sides? Right now mergeConditions() is only hit indirectly through the round-trip test, which never calls merge(). Given how fiddly the version-range merging already is, I'd want that path covered directly (overlapping ranges, one-sided keys, etc.).

if (contains(this.versions, version)) {
return true;
}
return (os != null) && contains(this.conditions.get(os.toString()), version);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: the OS key lookup is case-sensitive (os.toString() is always lowercase). A typo like "Windows" in a hand-written security.json would just silently never match, no warning. Not blocking, just easy to miss.

@@ -17,20 +20,62 @@
* @param severity the severity in the range from (0,10.0] where 10.0 is most critical.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice implementation of the conditions map from #1628. One thing worth a doc note: the issue mentioned arch-specific keys like windows_arm64 as a possible future extension - right now isAffected only checks os.toString() so those wouldn't actually be evaluated even though they'd parse fine. Probably fine to punt on for now, just flagging so nobody assumes it works.

@laert-ll
laert-ll force-pushed the feature/1628-support-for-os-specific-cves branch from 1fbec9a to 832df30 Compare August 31, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request security CVEs or other vulnerabilities

Projects

Status: Team Review

Development

Successfully merging this pull request may close these issues.

Support for OS specific CVEs

3 participants