Skip to content

Commit e4c58d9

Browse files
authored
tools: Update redhat csaf2osv conversion to support upstream field + tests (#345)
CVE upstream has moved from `related` to `upstream` to support #312 schema change. The `GO` vuln alias (for the CVE entry) has been left in related, so as not to affect the computation on the OSV.dev hierarchy display side. Tests updated to the latest schema version as well. Signed-off-by: Jess Lowe <[email protected]>
1 parent 648255a commit e4c58d9

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

tools/redhat/redhat_osv/osv.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from redhat_osv.csaf import Remediation, CSAF
99

1010
# Update this if verified against a later version
11-
SCHEMA_VERSION = "1.6.7"
11+
SCHEMA_VERSION = "1.7.0"
1212
# This assumes the datetime being formatted is in UTC
1313
DATE_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
1414
# Go package advisory reference prefix
@@ -130,6 +130,7 @@ def __init__(self, csaf_data: CSAF, modified: str, published: str = ""):
130130
# This attribute is declared after id to make the resulting JSON human-readable. It can only
131131
# be populated after reading the csaf vulnerabilities and references sections.
132132
self.related: list[str] = []
133+
self.upstream: list[str] = []
133134

134135
if published:
135136
self.published = published
@@ -159,7 +160,7 @@ def __init__(self, csaf_data: CSAF, modified: str, published: str = ""):
159160
unique_packages: dict[str: tuple[str: str]] = {}
160161

161162
for vulnerability in csaf_data.vulnerabilities:
162-
self.related.append(vulnerability.cve_id)
163+
self.upstream.append(vulnerability.cve_id)
163164
for remediation in vulnerability.remediations:
164165
# Safety check for when we start processing non-rpm content
165166
if not remediation.purl.startswith("pkg:rpm/"):

tools/redhat/testdata/OSV/RHSA-2024_4546.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
{
2-
"schema_version": "1.6.7",
2+
"schema_version": "1.7.0",
33
"id": "RHSA-2024:4546",
44
"related": [
5-
"CVE-2023-45288",
65
"GO-2024-2687"
76
],
7+
"upstream": [
8+
"CVE-2023-45288"
9+
],
810
"published": "2024-09-02T14:30:00Z",
911
"modified": "2024-09-02T14:30:00Z",
1012
"summary": "Red Hat Security Advisory: git-lfs security update",

tools/redhat/testdata/OSV/RHSA-2024_6220.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
2-
"schema_version": "1.6.7",
2+
"schema_version": "1.7.0",
33
"id": "RHSA-2024:6220",
4-
"related": [
4+
"related": [],
5+
"upstream": [
56
"CVE-2024-6345"
67
],
78
"published": "2024-09-02T14:30:00Z",

0 commit comments

Comments
 (0)