Skip to content

Commit

Permalink
rumble: fix legacy csv query and csv output to match what the chart j…
Browse files Browse the repository at this point in the history
…s expects (#1831)

Drop unused fields `scanner_version` and `scanner_db_version`, append
the tag to the end of the `image` name as expected by the javascript
generating the chart, and exclude images with `latest-dev` tags since
those are never used in image comparisons (cuts `data.csv` down from
~8MB to 4MB 📉 )

Signed-off-by: Colin Douglas <colin@chainguard.dev>
  • Loading branch information
cmdpdx authored Oct 1, 2024
1 parent 628b067 commit b509392
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
4 changes: 1 addition & 3 deletions tools/rumble/cmd/legacy_csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,8 @@ func (c *rumbleBase) generateCsv() error {
if !strings.Contains(image, "cgr.dev") || strings.Contains(image, "cgr.dev/chainguard/") {
csvRow := []string{
strconv.Itoa(i + 1),
r.(*cgbigquery.LegacyScan).Image,
fmt.Sprintf("%s:%s", r.(*cgbigquery.LegacyScan).Image, r.(*cgbigquery.LegacyScan).Tags),
r.(*cgbigquery.LegacyScan).Scanner,
r.(*cgbigquery.LegacyScan).Scanner_version,
r.(*cgbigquery.LegacyScan).Scanner_db_version,
r.(*cgbigquery.LegacyScan).Time,
strconv.FormatInt(r.(*cgbigquery.LegacyScan).Low_cve_cnt, 10),
strconv.FormatInt(r.(*cgbigquery.LegacyScan).Med_cve_cnt, 10),
Expand Down
25 changes: 12 additions & 13 deletions tools/rumble/pkg/bigquery/bigquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,18 @@ type BqClient struct {
}

type LegacyScan struct {
Row int64
Image string
Scanner string
Scanner_version string
Scanner_db_version string
Time string
Low_cve_cnt int64
Med_cve_cnt int64
High_cve_cnt int64
Crit_cve_cnt int64
Unknown_cve_cnt int64
Tot_cve_cnt int64
Digest string
Row int64
Image string
Tags string
Scanner string
Time string
Low_cve_cnt int64
Med_cve_cnt int64
High_cve_cnt int64
Crit_cve_cnt int64
Unknown_cve_cnt int64
Tot_cve_cnt int64
Digest string
}

type ImageScan struct {
Expand Down
10 changes: 5 additions & 5 deletions tools/rumble/pkg/bigquery/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const (
vulnsTable = "`cloudevents_grype_scan_results.rumble_vulns`"
summaryTable = "`cloudevents_grype_scan_results.rumble_summary`"

LegacyCsvHeader = `f0_,image,scanner,scanner_version,scanner_db_version,time,low_cve_cnt,med_cve_cnt,high_cve_cnt,crit_cve_cnt,unknown_cve_cnt,tot_cve_cnt,digest`
LegacyCsvHeader = `f0_,image,scanner,time,low_cve_cnt,med_cve_cnt,high_cve_cnt,crit_cve_cnt,unknown_cve_cnt,tot_cve_cnt,digest`
ImageScanCsvHeader = `image,package,vulnerability,version,type,s`

AllVulnsQuery = `
SELECT DISTINCT vulnerability
FROM ` + vulnsTable

AffectedImagesQuery = `
SELECT summ.image, summ.time as time,
SELECT scan.image, scan.time as time,
FROM ` + vulnsTable + ` AS vulns
INNER JOIN ` + summaryTable + ` AS scan
ON scan.id = vulns.scan_id
Expand All @@ -30,9 +30,8 @@ ORDER BY scan.image, scan.time
SELECT
ROW_NUMBER() OVER (ORDER BY time),
image,
tags,
scanner,
scanner_version,
scanner_db_version,
FORMAT_DATETIME("%Y-%m-%d %H:%M:%S", DATE(time)) as time,
low_cve_count as low_cve_cnt,
med_cve_count as med_cve_cnt,
Expand All @@ -41,7 +40,8 @@ SELECT
unknown_cve_count as unknown_cve_cnt,
low_cve_count + med_cve_count + high_cve_count + crit_cve_count + unknown_cve_count AS tot_cve_cnt,
digest
FROM ` + summaryTable
FROM ` + summaryTable + `
WHERE tags NOT LIKE '%latest-dev%'`

ImageComparisonCsvQuery = `
WITH ruuuumble AS (
Expand Down

0 comments on commit b509392

Please sign in to comment.