Skip to content

feat(photon): add OVAL definitions parser#408

Draft
DmitriyLewen wants to merge 10 commits intoaquasecurity:mainfrom
DmitriyLewen:feat/photon-oval
Draft

feat(photon): add OVAL definitions parser#408
DmitriyLewen wants to merge 10 commits intoaquasecurity:mainfrom
DmitriyLewen:feat/photon-oval

Conversation

@DmitriyLewen
Copy link
Contributor

Summary

  • Add photon/oval package that fetches and parses Photon OS OVAL definitions from packages.broadcom.com/photon/photon_oval_definitions/
  • Register new photon-oval target in main.go
  • Covers Photon OS versions 1–5 (com.vmware.phsa-photon{1..5}.xml.gz)

Context

Photon changed its cve_metadata schema (see vmware/photon#1638):

  • photon_versions.json was removed
  • Per-release cve_data_photon*.json files were removed
  • cve_score is no longer available in the new format

OVAL is now the canonical machine-readable source for Photon Security Advisories (PHSA).

Data changes vs old cve_metadata format

Field Old JSON OVAL
cve_id ✅ (from <cve> elements in advisory)
pkg / res_ver ✅ (parsed from criterion comment)
cve_score ✅ float ❌ not in OVAL — replaced by severity text
aff_ver text ❌ only "is earlier than X"
severity ✅ Important / Critical / Moderate / Low
issued / updated dates
description

The implementation follows the Oracle OVAL pattern: criterion comments are self-contained ("telegraf is earlier than 0:1.25.2-1.ph3"), so <tests>, <objects>, <states> sections are not stored.

Each definition is stored as photon/oval/{osVersion}/{PHSA-ID}.json (e.g. photon/oval/3.0/PHSA-2026-00001.json).

Test plan

  • go test ./photon/oval/ passes
  • Positive parse: Photon 3 OVAL XML with single/multi-CVE advisories
  • Error cases: 404, invalid gzip, broken XML, read-only filesystem
  • Unit tests for PhsaIDFromTitle and OsVersionFromCriteria

Add photon/oval package that fetches and parses Photon OS OVAL
definitions from packages.broadcom.com/photon/photon_oval_definitions/.

Photon changed its cve_metadata schema (see vmware/photon#1638) — the
photon_versions.json and per-release cve_data_photon*.json files were
removed and cve_score is no longer available. OVAL is now the canonical
machine-readable source for Photon Security Advisories (PHSA).

The OVAL feed covers Photon OS versions 1–5, uses gzip compression, and
follows the same structure as other OVAL-based sources in this repo.
Each definition is saved as photon/oval/{osVersion}/{PHSA-ID}.json.
@DmitriyLewen DmitriyLewen marked this pull request as draft March 4, 2026 09:41
DmitriyLewen added a commit to DmitriyLewen/trivy-db that referenced this pull request Mar 4, 2026
Implements pkg/vulnsrc/photon-oval — a new vulnerability source that
consumes photon-oval/{version}/{PHSA-ID}.json files produced by
vuln-list-update (see aquasecurity/vuln-list-update#408).

- Walk photon-oval/**/*.json; extract OS version from path segment
- Parse affected packages from OVAL Criteria tree by matching
  "{pkg} is earlier than 0:{ver}" criterion comments
- Store per-CVE advisory details, vulnerability details, and IDs
  in BoltDB using the existing Photon bucket
- Map OVAL severity (Critical/Important/Moderate/Low) to db.Severity
- Register PhotonOVAL source in vulnsrc.All and vulnerability.AllSourceIDs
…f sequence counter

Replace PhsaIDFromTitle with PhsaIDFromRef: extract the real advisory number
from the source="PHSA" reference (e.g. PHSA:00001:5.0:20 → PHSA-5.0-20)
instead of using the per-package OVAL sequence counter from the title.
Add issued year extracted from <issued date="..."/> to the advisory ID,
matching the official wiki format (e.g. PHSA-2023-5.0-20).
DmitriyLewen added a commit to DmitriyLewen/trivy-db that referenced this pull request Mar 5, 2026
…update format

Rename PHSA-YYYY-NNNN.json → PHSA-YYYY-{osVer}-{advisory_number}.json
to match the naming scheme produced by vuln-list-update
(see aquasecurity/vuln-list-update#408).
DmitriyLewen added a commit to DmitriyLewen/trivy-db that referenced this pull request Mar 5, 2026
…dorID

The PHSA advisory ID (e.g. "PHSA-2023-5.0-20") is derived from the JSON
filename, which is constructed by vuln-list-update when converting OVAL XML
to JSON (see aquasecurity/vuln-list-update#408). Store it in Advisory.VendorIDs
so that Trivy can surface the original advisory reference.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant