Skip to content

Commit 4be5260

Browse files
authored
feat: parse description for redhat csaf advisory (#682)
1 parent a0049d7 commit 4be5260

6 files changed

Lines changed: 202 additions & 135 deletions

File tree

pkg/vulnsrc/redhat-csaf/csaf.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ type PutInput struct {
6060
// no RHSA (CVE-only rows) or when the feed omits Remediation.Date. Intended for
6161
// Store implementations that want to expose an advisory publish date.
6262
ReleaseDate time.Time
63+
// Description is the vulnerability description from CSAF notes[category=description].
64+
Description string
6365
}
6466

6567
// defaultStore is the OSS default implementation of Store.
@@ -205,6 +207,7 @@ func (vs VulnSrc) update(tx *bolt.Tx, dir string) error {
205207
Advisory: advisory,
206208
CPEList: cpeList,
207209
ReleaseDate: vs.parser.ReleaseDate(bkt.VulnerabilityID),
210+
Description: vs.parser.Description(bkt.VulnerabilityID),
208211
}
209212
if err := vs.store.Put(vs.dbc, tx, input); err != nil {
210213
return eb.Wrapf(err, "failed to put advisory")

pkg/vulnsrc/redhat-csaf/csaf_test.go

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,12 @@ func TestVulnSrc_Update_WithCustomStore(t *testing.T) {
316316
// Verify the custom store was called with Put
317317
assert.NotEmpty(t, store.putInputs, "custom Store.Put should have been called")
318318

319+
mustTime := func(s string) time.Time {
320+
ts, err := time.Parse(time.RFC3339, s)
321+
require.NoError(t, err)
322+
return ts
323+
}
324+
319325
// Verify the extra CPE was merged
320326
// The merged list should contain both CSAF CPEs and the extra one
321327
for _, input := range store.putInputs {
@@ -324,17 +330,26 @@ func TestVulnSrc_Update_WithCustomStore(t *testing.T) {
324330

325331
vid := string(input.Bucket.VulnerabilityID)
326332
switch vid {
327-
case "RHSA-2024:9941", "RHSA-2024:9999":
328-
want, err := time.Parse(time.RFC3339, "2024-11-19T04:46:55Z")
329-
require.NoError(t, err)
330-
assert.True(t, input.ReleaseDate.Equal(want), "ReleaseDate for %s", vid)
333+
case "RHSA-2024:9941":
334+
assert.True(t, input.ReleaseDate.Equal(mustTime("2024-11-19T04:46:55Z")), "ReleaseDate for %s", vid)
335+
assert.Equal(t, "A vulnerability was found in PAM. The secret information is stored in memory, where the attacker can trigger the victim program to execute.", input.Description)
336+
case "RHSA-2024:9999":
337+
assert.True(t, input.ReleaseDate.Equal(mustTime("2024-11-19T04:46:55Z")), "ReleaseDate for %s", vid)
338+
assert.Equal(t, "Description from CVE-2024-11111 (stored for RHSA-2024:9999)", input.Description)
331339
case "RHSA-2025:0001":
332-
want, err := time.Parse(time.RFC3339, "2025-01-01T00:00:00Z")
333-
require.NoError(t, err)
334-
assert.True(t, input.ReleaseDate.Equal(want), "ReleaseDate for %s", vid)
340+
assert.True(t, input.ReleaseDate.Equal(mustTime("2025-01-01T00:00:00Z")), "ReleaseDate for %s", vid)
341+
assert.Equal(t, "Test vulnerability for new rpmmod qualifier format", input.Description)
342+
case "CVE-2024-11111":
343+
// Unpatched rows use the CVE as bucket ID; there is no RHSA remediation date.
344+
assert.True(t, input.ReleaseDate.IsZero(), "ReleaseDate for %q", vid)
345+
assert.Equal(t, "Description from CVE-2024-11111 (stored for RHSA-2024:9999)", input.Description)
346+
case "CVE-2024-22222":
347+
assert.True(t, input.ReleaseDate.IsZero(), "ReleaseDate for %q", vid)
348+
assert.Equal(t, "Description from CVE-2024-22222 (not stored for RHSA-2024:9999)", input.Description)
335349
default:
336350
// Unpatched rows use the CVE as bucket ID; there is no RHSA remediation date.
337351
assert.True(t, input.ReleaseDate.IsZero(), "ReleaseDate for %q", vid)
352+
assert.Empty(t, input.Description, "Description for %q", vid)
338353
}
339354
}
340355

0 commit comments

Comments
 (0)