diff --git a/CHANGELOG.md b/CHANGELOG.md index cdbc2d4..2b07c8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- Demo: fictional Oracle Java SE rows for CVE-2026-114938 (Java4Shell) with a recorded NVD document (status Received, official Oracle CVSS 3.1 8.1, CNA affected versions, no invented CPE ranges or EPSS). The CVE is not in the demo KEV catalog. `from_nvd_cve` now reads NVD `affected` / `affectedData` when present; CPE `configurations` still win when both exist. - Dependencies: runtime, dev and build requirements in `pyproject.toml` are pinned to exact versions (`==`). CI installs from the hash-pinned `requirements-ci.txt` (`pip install --require-hashes`), then the project itself with `--no-deps`. Prompted by the malicious `agent-framework` 1.26.1/1.26.2 releases on PyPI ([MAL-2026-20101](https://osv.dev/vulnerability/MAL-2026-20101)); none of these projects depend on it. - `--columns NAMES` with `--format csv` on `scan` and `demo`: write only the named columns, in the given order. Unknown or repeated names exit 2 before any request. - Docs: `docs/windows-autopatch.md` maps findings to the Windows Autopatch approval model (automatic/manual approval, deferral, expedite, pause), with Microsoft sources. A test keeps its example in sync with the demo output. diff --git a/README.md b/README.md index 872283d..a12a8d2 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ python -m pip install -e . python -m patchorder demo ``` -`demo` reads bundled fixtures recorded on 2026-10-21 (Ivanti Connect Secure records on 2026-11-03) and does not use the network. Add `--format html` or `--format json`. `--output briefing.md` is the explicit way to write a file. With no `--output`, nothing is written. +`demo` reads bundled fixtures recorded on 2026-10-21 (Ivanti Connect Secure records on 2026-11-03, CVE-2026-114938 on 2026-11-18) and does not use the network. Add `--format html` or `--format json`. `--output briefing.md` is the explicit way to write a file. With no `--output`, nothing is written. ```bash python -m patchorder demo --format html --output briefing.html @@ -66,6 +66,28 @@ The demo has two fictional VPN gateway rows on Ivanti Connect Secure. The CVEs, Ivanti release strings such as `22.8R2.4` are split into CPE version `22.8` and update `r2.4`, the way NVD writes them. +The demo also has fictional Oracle Java SE rows for [CVE-2026-114938](https://nvd.nist.gov/vuln/detail/CVE-2026-114938) (also called Java4Shell). The id, CVSS, and affected versions are a recording of the official NVD document on 2026-11-18. At that time NVD status was `Received` and the record had no CPE `configurations`, so patchorder matches the Oracle CNA `affected` list: exact supported versions, not a reconstructed range. + +- `jdk-app`, Oracle Java SE 17.0.21.0.3, internet-facing: CVE-2026-114938 is affected (exact CNA version). +- `jdk-app-patched`, 17.0.21.1, internet-facing: not affected. Oracle's Java 17 security baseline for the November 2026 Critical Security Patch Update is `17.0.21.1+4`. +- `jdk-11`, 11.0.33.0.3, internal: not affected. The [OpenJDK advisory](https://openjdk.org/groups/vulnerability/advisories/2026-11-17) marks this CVE on the 17, 21, 25, and 27 lines, not 8 or 11. Oracle's CNA list also omits standard Java 8 and 11; it does list the Java 8 Enterprise Performance Pack build `8u511b33-perf`. + +Official CVSS 3.1 is 8.1 High (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H`), scored by Oracle and repeated in the OpenJDK advisory. The CVE was not in CISA KEV catalog version 2026.11.17, so the demo KEV fixture is unchanged. FIRST EPSS had no score for this id at recording time, so the finding has no EPSS points. + +Red Hat's bulletin describes OpenJDK 17.0.6 and later as affected on x86-64 CPUs with AVX-512 VBMI, and says standard OpenJDK 8 and 11 are not affected. That broader 17.0.6+ range is not in the NVD/CVE.org structured data yet, so the matcher does not invent it. A version such as 17.0.6 is therefore currently reported as outside the official exact list. + +Sources recorded or cited for this example: + +- [CVE.org record](https://www.cve.org/CVERecord?id=CVE-2026-114938) (CNA: Oracle) +- [NVD](https://nvd.nist.gov/vuln/detail/CVE-2026-114938) +- [Oracle Critical Security Patch Update, November 2026](https://www.oracle.com/security-alerts/cspunov2026.html) +- [OpenJDK Vulnerability Advisory: 2026/11/17](https://openjdk.org/groups/vulnerability/advisories/2026-11-17) +- [CISA alert, 17 November 2026](https://www.cisa.gov/news-events/alerts/2026/11/17/critical-java-vulnerability-requires-immediate-patching) +- [Red Hat security bulletin RHSB-2026-018](https://access.redhat.com/security/vulnerabilities/RHSB-2026-018) +- Oracle fixed builds: [17.0.21.1](https://www.oracle.com/java/technologies/javase/17-0-21-1-relnotes.html), [21.0.13.1](https://www.oracle.com/java/technologies/javase/21-0-13-1-relnotes.html), [25.0.5.1](https://www.oracle.com/java/technologies/javase/25-0-5-1-relnotes.html), [27.0.1.1](https://www.oracle.com/java/technologies/javase/27-0-1-1-relnotes.html), and [8u513-perf](https://www.oracle.com/java/technologies/javase/8u513-perf-relnotes.html) +- Amazon Corretto changelogs, which address this CVE in [17.0.21.1.2](https://github.com/corretto/corretto-17/blob/develop/CHANGELOG.md) and [27.0.1.1.4](https://github.com/corretto/corretto-27/blob/develop/CHANGELOG.md) +- CISA KEV catalog version 2026.11.17 (not listed), checked at + ### Start from a spreadsheet Most inventories already live in a CMDB export or a spreadsheet. Turn the CSV into inventory YAML, then lint it before the first scan: @@ -247,7 +269,7 @@ python -m pip install -e ".[dev]" python -m pytest ``` -Pytest blocks sockets. CI runs the same suite on Python 3.11, 3.12, and 3.13, then runs the offline demo with `--fail-on kev` (expected to exit 4) and `inventory check` on the example (`.github/workflows/ci.yml`). +The suite currently has 96 tests. Pytest blocks sockets. CI runs the same suite on Python 3.11, 3.12, and 3.13, then runs the offline demo with `--fail-on kev` (expected to exit 4) and `inventory check` on the example (`.github/workflows/ci.yml`). ## How to contribute @@ -285,4 +307,4 @@ Neu in 0.2: `inventory from-csv` macht aus einem CSV-Export ein Inventar, `inven Für Windows-Geräte, die über Windows Autopatch aktualisiert werden, erklärt [docs/windows-autopatch.md](docs/windows-autopatch.md) mit Microsoft-Quellen, wie ein Fund zum Freigabemodell passt: automatische Freigabe mit 0 bis 30 Tagen Verzögerung für monatliche Sicherheitsupdates, manuelle Freigabe als Standard für Vorschau- und Out-of-Band-Updates, Beschleunigen und Pausieren. -Neu: Jeder KEV-Fund nennt das `dueDate` aus dem CISA-Katalog und die Tage seit Ablauf. `--fail-on kev-overdue` schlägt nur bei abgelaufener Frist an. Die Punkte ändern sich dadurch nicht. Die Demo enthält zwei fiktive VPN-Gateways mit Ivanti Connect Secure und den echten KEV-Einträgen CVE-2026-104935 und CVE-2026-111357. +Neu: Jeder KEV-Fund nennt das `dueDate` aus dem CISA-Katalog und die Tage seit Ablauf. `--fail-on kev-overdue` schlägt nur bei abgelaufener Frist an. Die Punkte ändern sich dadurch nicht. Die Demo enthält zwei fiktive VPN-Gateways mit Ivanti Connect Secure und den echten KEV-Einträgen CVE-2026-104935 und CVE-2026-111357 sowie fiktive Oracle-Java-SE-Zeilen zu CVE-2026-114938 (Java4Shell; offizieller CVSS-3.1-Wert 8.1, nicht im KEV-Katalog 2026.11.17, Abgleich über die exakten CNA-Versionen, weil die NVD am 18.11.2026 noch keine CPE-Konfigurationen hatte). diff --git a/examples/inventory.lock.yaml b/examples/inventory.lock.yaml index 15c5908..2581a0e 100644 --- a/examples/inventory.lock.yaml +++ b/examples/inventory.lock.yaml @@ -66,3 +66,21 @@ entries: confidence: 1.0 origin: user note: Pinned for the fictional Harbor Workshop demo. + jdk-app: + cpe: cpe:2.3:a:oracle:jdk + pinned: true + confidence: 1.0 + origin: user + note: Pinned for the fictional Harbor Workshop demo. + jdk-app-patched: + cpe: cpe:2.3:a:oracle:jdk + pinned: true + confidence: 1.0 + origin: user + note: Pinned for the fictional Harbor Workshop demo. + jdk-11: + cpe: cpe:2.3:a:oracle:jdk + pinned: true + confidence: 1.0 + origin: user + note: Pinned for the fictional Harbor Workshop demo. diff --git a/examples/inventory.yaml b/examples/inventory.yaml index 0c381d7..6d012c4 100644 --- a/examples/inventory.yaml +++ b/examples/inventory.yaml @@ -86,3 +86,24 @@ assets: count: 1 owner: network exposure: internal + - id: jdk-app + product: Oracle Java SE + vendor: Oracle + version: "17.0.21.0.3" + count: 5 + owner: apps + exposure: internet + - id: jdk-app-patched + product: Oracle Java SE + vendor: Oracle + version: "17.0.21.1" + count: 2 + owner: apps + exposure: internet + - id: jdk-11 + product: Oracle Java SE + vendor: Oracle + version: "11.0.33.0.3" + count: 3 + owner: apps + exposure: internal diff --git a/src/patchorder/cli.py b/src/patchorder/cli.py index 5ebd3cc..9229cf6 100644 --- a/src/patchorder/cli.py +++ b/src/patchorder/cli.py @@ -175,7 +175,7 @@ def cmd_demo(args: argparse.Namespace) -> int: if args.llm_preview: report.llm_preview = preview_json(cve_texts(report.findings), os.environ.get("PATCHORDER_LLM_MODEL", "unset")) _emit(_render(report, args.format, columns), args.output) - print("patchorder demo: offline, fixtures recorded 2026-10-21 and 2026-11-03", file=sys.stderr) + print("patchorder demo: offline, fixtures recorded 2026-10-21, 2026-11-03 and 2026-11-18", file=sys.stderr) return _apply_gates(report, gates) diff --git a/src/patchorder/data/demo/MANIFEST.json b/src/patchorder/data/demo/MANIFEST.json index 29db4ea..4198395 100644 --- a/src/patchorder/data/demo/MANIFEST.json +++ b/src/patchorder/data/demo/MANIFEST.json @@ -1,6 +1,6 @@ { - "recorded": "2026-10-21; Ivanti Connect Secure records, KEV header and the two Ivanti EPSS rows 2026-11-03", - "note": "NVD and KEV bodies are reduced recordings: English description, CVSS base score, and the CPE matches the demo decides. They are not full upstream documents. The EPSS file and KEV catalog header are recorded responses. The CSAF files are fictional (Example CERT and a patchorder fixture), not copies of published advisories. The KEV vulnerabilities array contains 3 of the catalog's published entries (catalog 2026.10.30). The Ivanti Connect Secure rows in the inventory are fictional hosts; the CVE ids, KEV entries, NVD configurations and EPSS scores are real recordings.", + "recorded": "2026-10-21; Ivanti Connect Secure records, KEV header and the two Ivanti EPSS rows 2026-11-03; CVE-2026-114938 NVD record 2026-11-18", + "note": "NVD and KEV bodies are reduced recordings: English description, CVSS base score, and the CPE matches the demo decides. They are not full upstream documents. The EPSS file and KEV catalog header are recorded responses. The CSAF files are fictional (Example CERT and a patchorder fixture), not copies of published advisories. The KEV vulnerabilities array contains 3 of the catalog's published entries (catalog 2026.10.30). The Ivanti Connect Secure and Oracle Java SE rows in the inventory are fictional hosts. The CVE ids, KEV entries, NVD configurations and EPSS scores for the existing demo CVEs are real recordings. CVE-2026-114938 is a recording of the NVD 2.0 document as of 2026-11-18: vulnStatus Received, official Oracle CVSS 3.1 8.1, and the CNA affected version list. NVD published no CPE configurations and FIRST EPSS returned no score, so those fields are omitted rather than invented. The CVE is not in the recorded KEV catalog (and was not in CISA KEV catalog 2026.11.17).", "sources": { "nvd_cve": "https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=", "epss": "https://api.first.org/data/v1/epss", diff --git a/src/patchorder/data/demo/inventory.lock.yaml b/src/patchorder/data/demo/inventory.lock.yaml index 15c5908..2581a0e 100644 --- a/src/patchorder/data/demo/inventory.lock.yaml +++ b/src/patchorder/data/demo/inventory.lock.yaml @@ -66,3 +66,21 @@ entries: confidence: 1.0 origin: user note: Pinned for the fictional Harbor Workshop demo. + jdk-app: + cpe: cpe:2.3:a:oracle:jdk + pinned: true + confidence: 1.0 + origin: user + note: Pinned for the fictional Harbor Workshop demo. + jdk-app-patched: + cpe: cpe:2.3:a:oracle:jdk + pinned: true + confidence: 1.0 + origin: user + note: Pinned for the fictional Harbor Workshop demo. + jdk-11: + cpe: cpe:2.3:a:oracle:jdk + pinned: true + confidence: 1.0 + origin: user + note: Pinned for the fictional Harbor Workshop demo. diff --git a/src/patchorder/data/demo/inventory.yaml b/src/patchorder/data/demo/inventory.yaml index 0c381d7..6d012c4 100644 --- a/src/patchorder/data/demo/inventory.yaml +++ b/src/patchorder/data/demo/inventory.yaml @@ -86,3 +86,24 @@ assets: count: 1 owner: network exposure: internal + - id: jdk-app + product: Oracle Java SE + vendor: Oracle + version: "17.0.21.0.3" + count: 5 + owner: apps + exposure: internet + - id: jdk-app-patched + product: Oracle Java SE + vendor: Oracle + version: "17.0.21.1" + count: 2 + owner: apps + exposure: internet + - id: jdk-11 + product: Oracle Java SE + vendor: Oracle + version: "11.0.33.0.3" + count: 3 + owner: apps + exposure: internal diff --git a/src/patchorder/data/demo/nvd/CVE-2026-114938.json b/src/patchorder/data/demo/nvd/CVE-2026-114938.json new file mode 100644 index 0000000..4460d4e --- /dev/null +++ b/src/patchorder/data/demo/nvd/CVE-2026-114938.json @@ -0,0 +1,133 @@ +{ + "resultsPerPage": 1, + "startIndex": 0, + "totalResults": 1, + "format": "NVD_CVE", + "version": "2.0", + "vulnerabilities": [ + { + "cve": { + "id": "CVE-2026-114938", + "sourceIdentifier": "secalert_us@oracle.com", + "published": "2026-11-17T22:18:23.777", + "lastModified": "2026-11-18T05:19:00.783", + "vulnStatus": "Received", + "descriptions": [ + { + "lang": "en", + "value": "Vulnerability in the Oracle Java SE, Oracle GraalVM for JDK, Oracle GraalVM Enterprise Edition product of Oracle Java SE (component: Compiler). Supported versions that are affected are Oracle Java SE: 8u511b33-perf, 17.0.21.0.3, 21.0.13.0.3, 25.0.5.0.3, 27.0.1.0.3; Oracle GraalVM for JDK: 17.0.21.0.3 and 21.0.13.0.3; Oracle GraalVM Enterprise Edition: 21.3.20.0.3. Difficult to exploit vulnerability allows unauthenticated attacker with network access via multiple protocols to compromise Oracle Java SE, Oracle GraalVM for JDK, Oracle GraalVM Enterprise Edition. Successful attacks of this vulnerability can result in takeover of Oracle Java SE, Oracle GraalVM for JDK, Oracle GraalVM Enterprise Edition. Note: This vulnerability can only be exploited by supplying data to APIs in the specified Component without using Untrusted Java Web Start applications or Untrusted Java applets, such as through a web service. CVSS 3.1 Base Score 8.1 (Confidentiality, Integrity and Availability impacts). CVSS Vector: (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H)." + } + ], + "metrics": { + "cvssMetricV31": [ + { + "source": "secalert_us@oracle.com", + "type": "Secondary", + "cvssData": { + "version": "3.1", + "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H", + "baseScore": 8.1, + "baseSeverity": "HIGH" + } + } + ] + }, + "affected": [ + { + "source": "secalert_us@oracle.com", + "affectedData": [ + { + "vendor": "Oracle Corporation", + "product": "Oracle Java SE", + "versions": [ + { + "version": "8u511b33-perf", + "status": "affected" + }, + { + "version": "17.0.21.0.3", + "status": "affected" + }, + { + "version": "21.0.13.0.3", + "status": "affected" + }, + { + "version": "25.0.5.0.3", + "status": "affected" + }, + { + "version": "27.0.1.0.3", + "status": "affected" + } + ] + }, + { + "vendor": "Oracle Corporation", + "product": "Oracle GraalVM for JDK", + "versions": [ + { + "version": "17.0.21.0.3", + "status": "affected" + }, + { + "version": "21.0.13.0.3", + "status": "affected" + } + ] + }, + { + "vendor": "Oracle Corporation", + "product": "Oracle GraalVM Enterprise Edition", + "versions": [ + { + "version": "21.3.20.0.3", + "status": "affected" + } + ] + } + ] + } + ], + "references": [ + { + "url": "https://www.oracle.com/security-alerts/cspunov2026.html", + "source": "secalert_us@oracle.com" + }, + { + "url": "http://www.openwall.com/lists/oss-security/2026/11/17/31", + "source": "af854a3a-2127-422b-91ae-364da2661108" + }, + { + "url": "https://access.redhat.com/security/cve/cve-2026-114938", + "source": "af854a3a-2127-422b-91ae-364da2661108" + }, + { + "url": "https://calif.io/java4shell", + "source": "af854a3a-2127-422b-91ae-364da2661108" + }, + { + "url": "https://github.com/Azure/azure-functions-java-worker/issues/909", + "source": "af854a3a-2127-422b-91ae-364da2661108" + }, + { + "url": "https://github.com/chainguard-dev/cg-skills/pull/17", + "source": "af854a3a-2127-422b-91ae-364da2661108" + }, + { + "url": "https://github.com/corretto/corretto-27/blob/27.0.1.1.4/CHANGELOG.md", + "source": "af854a3a-2127-422b-91ae-364da2661108" + }, + { + "url": "https://news.ycombinator.com/item?id=50538240", + "source": "af854a3a-2127-422b-91ae-364da2661108" + }, + { + "url": "https://www.cisa.gov/news-events/alerts/2026/11/17/critical-java-vulnerability-requires-immediate-patching", + "source": "af854a3a-2127-422b-91ae-364da2661108" + } + ] + } + } + ] +} diff --git a/src/patchorder/engine.py b/src/patchorder/engine.py index b664c70..6407b4e 100644 --- a/src/patchorder/engine.py +++ b/src/patchorder/engine.py @@ -16,7 +16,7 @@ from patchorder.sources import CSAF_PROVIDER, LiveFetcher DEMO_ROOT = Path(__file__).resolve().parent / "data" / "demo" -RECORDED = "2026-10-21 (Ivanti Connect Secure records 2026-11-03)" +RECORDED = "2026-10-21 (Ivanti Connect Secure records 2026-11-03; CVE-2026-114938 2026-11-18)" def utc_now() -> str: @@ -46,7 +46,7 @@ def run_demo(as_of: str | None = None) -> Report: advisories = load_csaf_path(root / "csaf") sources = [ f"NVD CVE API 2.0: {len(records)} records bundled as fixtures recorded {RECORDED}, " - "reduced to the CPE matches this demo decides. Not a live query.", + "reduced to the version data this demo decides. Not a live query.", f"CISA KEV: catalog {kev.catalog_version}. {kev.note or str(len(kev.entries)) + ' entries loaded'}".strip(), "FIRST EPSS: bundled scores. Not a live query.", "Vulnerability-Lookup: not queried in demo mode. Live scans call cpesearch and then filter versions locally.", diff --git a/src/patchorder/records.py b/src/patchorder/records.py index 366745e..46f921d 100644 --- a/src/patchorder/records.py +++ b/src/patchorder/records.py @@ -67,6 +67,29 @@ def _refs(items: object) -> list[str]: return found +def _cve5_affected_from_nvd(cve: dict) -> list: + """Lift official CNA affected products out of an NVD 2.0 CVE object. + + NVD may publish that list as `affected` entries that already look like + CVE List 5 blocks, or as `{source, affectedData: [...]}` wrappers, before + any CPE `configurations` exist. The matcher still prefers configurations + when both are present. + """ + raw = cve.get("affected") + if not isinstance(raw, list): + return [] + blocks: list = [] + for item in raw: + if not isinstance(item, dict): + continue + data = item.get("affectedData") + if isinstance(data, list): + blocks.extend(entry for entry in data if isinstance(entry, dict)) + elif "vendor" in item or "product" in item or "versions" in item: + blocks.append(item) + return blocks + + def from_nvd_cve(cve: dict, source: str = "nvd") -> Record | None: if not isinstance(cve, dict) or not isinstance(cve.get("id"), str): return None @@ -81,7 +104,7 @@ def from_nvd_cve(cve: dict, source: str = "nvd") -> Record | None: cve_id=cve["id"], description=_description(cve.get("descriptions")), configurations=configurations, - cve5_affected=[], + cve5_affected=_cve5_affected_from_nvd(cve), cvss=score, severity=severity, vector=vector, diff --git a/tests/test_demo_and_cli.py b/tests/test_demo_and_cli.py index 3a28228..5e4e764 100644 --- a/tests/test_demo_and_cli.py +++ b/tests/test_demo_and_cli.py @@ -34,13 +34,27 @@ def test_demo_briefing_answers_the_question(): assert "bastion-fixed" not in by_asset assert "server-name-only" not in by_asset assert "custom-connector" not in by_asset - assert report.new_cve_ids == ["CVE-2023-44487", "CVE-2024-38063", "CVE-2026-104935", "CVE-2026-111357"] + assert "jdk-app-patched" not in by_asset + assert "jdk-11" not in by_asset + assert by_asset["jdk-app"][0].cve_id == "CVE-2026-114938" + assert by_asset["jdk-app"][0].cvss == 8.1 + assert by_asset["jdk-app"][0].kev is False + assert by_asset["jdk-app"][0].epss is None + assert report.new_cve_ids == [ + "CVE-2023-44487", + "CVE-2024-38063", + "CVE-2026-104935", + "CVE-2026-111357", + "CVE-2026-114938", + ] kinds = {(note.asset_id, note.kind) for note in report.notes} assert ("edge-current", "not_affected") in kinds assert ("file-servers-patched", "not_affected") in kinds assert ("bastion-fixed", "not_affected") in kinds assert ("server-name-only", "not_decided") in kinds assert ("custom-connector", "unresolved") in kinds + assert ("jdk-app-patched", "not_affected") in kinds + assert ("jdk-11", "not_affected") in kinds # Score lines are the formula, not a hidden weight. blob = " ".join(part.text for part in by_asset["edge-proxy"][0].parts) assert "CISA KEV" in blob diff --git a/tests/test_java4shell.py b/tests/test_java4shell.py new file mode 100644 index 0000000..b8d5824 --- /dev/null +++ b/tests/test_java4shell.py @@ -0,0 +1,195 @@ +"""CVE-2026-114938 (Java4Shell) uses official NVD/CNA data only. + +NVD had no CPE configurations when the demo fixture was recorded +(vulnStatus Received, 2026-11-18). The matcher therefore uses the exact +supported versions in the Oracle CNA affected list, and must not invent a +broader range. +""" + +from __future__ import annotations + +import json +from pathlib import Path + +from patchorder.matching import evaluate +from patchorder.records import from_cve5, from_nvd_cve + +ROOT = Path(__file__).resolve().parents[1] +FIXTURE = ROOT / "src" / "patchorder" / "data" / "demo" / "nvd" / "CVE-2026-114938.json" +CPE = "cpe:2.3:a:oracle:jdk" + + +def _demo_record(): + payload = json.loads(FIXTURE.read_text(encoding="utf-8")) + record = from_nvd_cve(payload["vulnerabilities"][0]["cve"]) + assert record is not None + return record + + +def test_nvd_fixture_is_the_official_record_without_invented_configurations(): + payload = json.loads(FIXTURE.read_text(encoding="utf-8")) + cve = payload["vulnerabilities"][0]["cve"] + assert cve["id"] == "CVE-2026-114938" + assert cve["vulnStatus"] == "Received" + assert cve["sourceIdentifier"] == "secalert_us@oracle.com" + assert "configurations" not in cve + record = _demo_record() + assert record.configurations == [] + assert record.cvss == 8.1 + assert record.severity == "HIGH" + assert record.vector == "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H" + products = {item["product"] for item in record.cve5_affected} + assert products == { + "Oracle Java SE", + "Oracle GraalVM for JDK", + "Oracle GraalVM Enterprise Edition", + } + java_se = next(item for item in record.cve5_affected if item["product"] == "Oracle Java SE") + assert [entry["version"] for entry in java_se["versions"]] == [ + "8u511b33-perf", + "17.0.21.0.3", + "21.0.13.0.3", + "25.0.5.0.3", + "27.0.1.0.3", + ] + + +def test_official_supported_versions_match_exactly(): + record = _demo_record() + java = ("Oracle", "Oracle Java SE") + for version in ("8u511b33-perf", "17.0.21.0.3", "21.0.13.0.3", "25.0.5.0.3", "27.0.1.0.3"): + hit = evaluate(record, CPE, version, *java) + assert hit.verdict == "affected", version + assert hit.basis == "cve5" + assert hit.fixed_hint is None + graal = evaluate(record, "cpe:2.3:a:oracle:graalvm_for_jdk", "17.0.21.0.3", "Oracle", "Oracle GraalVM for JDK") + assert graal.verdict == "affected" + graal_ee = evaluate( + record, + "cpe:2.3:a:oracle:graalvm", + "21.3.20.0.3", + "Oracle", + "Oracle GraalVM Enterprise Edition", + ) + assert graal_ee.verdict == "affected" + + +def test_fixed_and_unlisted_java_versions_are_outside_the_cna_list(): + record = _demo_record() + java = ("Oracle", "Oracle Java SE") + # Official Oracle fixed builds for this CSPU are not in the affected list. + for version in ("17.0.21.1", "21.0.13.1", "25.0.5.1", "27.0.1.1", "8u513-perf"): + miss = evaluate(record, CPE, version, *java) + assert miss.verdict == "not_affected", version + assert miss.product_mentioned is True + # Standard Java 8 / 11 are not in this CVE's CNA list or the OpenJDK matrix. + assert evaluate(record, CPE, "8u511b33", *java).verdict == "not_affected" + assert evaluate(record, CPE, "11.0.33.0.3", *java).verdict == "not_affected" + # Red Hat describes 17.0.6 and later as affected, but that range is not in + # the official structured record, so the matcher must not invent it. + earlier = evaluate(record, CPE, "17.0.6", *java) + assert earlier.verdict == "not_affected" + assert earlier.reason.startswith("17.0.6 is outside the CVE affected ranges") + + +def test_other_products_are_not_mentioned(): + record = _demo_record() + miss = evaluate(record, "cpe:2.3:a:f5:nginx", "1.25.2", "F5", "nginx") + assert miss.verdict == "not_affected" + assert miss.product_mentioned is False + + +def test_nvd_affecteddata_wrapper_is_read_and_configurations_still_win(): + record = from_nvd_cve( + { + "id": "CVE-2026-0001", + "vulnStatus": "Received", + "descriptions": [{"lang": "en", "value": "Example."}], + "metrics": { + "cvssMetricV31": [ + { + "cvssData": { + "version": "3.1", + "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H", + "baseScore": 8.1, + "baseSeverity": "HIGH", + } + } + ] + }, + "affected": [ + { + "source": "secalert_us@oracle.com", + "affectedData": [ + { + "vendor": "Example Corp", + "product": "Example Server", + "versions": [{"version": "1.0.0", "status": "affected"}], + } + ], + } + ], + } + ) + assert record is not None + assert record.configurations == [] + assert record.cve5_affected[0]["product"] == "Example Server" + hit = evaluate(record, "cpe:2.3:a:example:server", "1.0.0", "Example Corp", "Example Server") + assert hit.verdict == "affected" + assert hit.basis == "cve5" + + record.configurations = [ + { + "nodes": [ + { + "operator": "OR", + "negate": False, + "cpeMatch": [ + { + "vulnerable": True, + "criteria": "cpe:2.3:a:example:server:*:*:*:*:*:*:*:*", + "versionEndExcluding": "1.0.0", + } + ], + } + ] + } + ] + # 1.0.0 is in the CNA list but outside the NVD range; configurations win. + overridden = evaluate(record, "cpe:2.3:a:example:server", "1.0.0", "Example Corp", "Example Server") + assert overridden.verdict == "not_affected" + assert overridden.basis == "nvd" + + +def test_cve_org_document_agrees_with_the_nvd_affected_list(): + # Same official versions, different envelope (CVE List 5 / CVE.org). + document = { + "cveMetadata": {"cveId": "CVE-2026-114938", "state": "PUBLISHED"}, + "containers": { + "cna": { + "affected": [ + { + "vendor": "Oracle Corporation", + "product": "Oracle Java SE", + "versions": [{"version": "17.0.21.0.3", "status": "affected"}], + } + ], + "metrics": [ + { + "cvssV3_1": { + "version": "3.1", + "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H", + "baseScore": 8.1, + "baseSeverity": "HIGH", + } + } + ], + "descriptions": [{"lang": "en", "value": "Compiler vulnerability."}], + } + }, + } + record = from_cve5(document) + assert record is not None + assert record.cvss == 8.1 + assert evaluate(record, CPE, "17.0.21.0.3", "Oracle", "Oracle Java SE").verdict == "affected" + assert evaluate(record, CPE, "17.0.21.1", "Oracle", "Oracle Java SE").verdict == "not_affected" diff --git a/tests/test_v02_gate_csv_inventory.py b/tests/test_v02_gate_csv_inventory.py index 6e65406..5eb9262 100644 --- a/tests/test_v02_gate_csv_inventory.py +++ b/tests/test_v02_gate_csv_inventory.py @@ -31,7 +31,7 @@ def test_gates_on_demo(): assert evaluate_gates(report, [parse_gate("kev")])[0].startswith("--fail-on kev: 4 finding(s) (edge-proxy:CVE-2023-44487, vpn-gateway-lab:CVE-2026-111357") assert evaluate_gates(report, [parse_gate("priority:95")]) == [] assert len(evaluate_gates(report, [parse_gate("priority:40"), parse_gate("internet")])) == 2 - assert "6 finding(s)" in evaluate_gates(report, [parse_gate("new")])[0] + assert "7 finding(s)" in evaluate_gates(report, [parse_gate("new")])[0] with pytest.raises(PatchorderError): evaluate_gates(replace(report, new_cve_ids=None), [parse_gate("new")])