-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rumble: refactor to use vuln scan results from
prod-enforce
(#1823)
## Type of change Late breaking 24i issue. ### What should this PR do? Vuln scanning has moved from `prod-images` to `prod-enforce`. The CVE comparison pages on edu.chainguard.dev have been broken for a while since the scanners have been turned down from `prod-images`. This PR updates the location of the datasets used, as well as refactors to take into consideration some of the changes to the data. ### Why are we making this change? Fix CVE comparisons between external and Chainguard equivalent images. ### What are the acceptance criteria? * CVE data is pulled from the correct bigquery source (`prod-enforce`), and we have data for both external and Chainguard images for each requested. ### How should this PR be tested? This change chan be run locally without uploading the results to test the datasources are being queried and correlated properly: ``` go run main.go vulns --project=prod-enforce-fabc --db=cloudevents_grype_scan_results go run main.go image-csv --project=prod-enforce-fabc --db=cloudevents_grype_scan_results --rumble-json-path=../../data/rumble.json go run main.go legacy-csv --project=prod-enforce-fabc --db=cloudevents_grype_scan_results ``` Signed-off-by: Colin Douglas <[email protected]>
- Loading branch information
Showing
10 changed files
with
174 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,57 @@ | ||
/* | ||
Copyright 2024 Chainguard, Inc. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package cmd | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
cgbigquery "github.com/chainguard-dev/edu/tools/rumble/pkg/bigquery" | ||
cloudstorage "github.com/chainguard-dev/edu/tools/rumble/pkg/cloudstorage" | ||
) | ||
|
||
type rumbleBase struct { | ||
ctx context.Context | ||
bqClient cgbigquery.BqClient | ||
storageClient cloudstorage.GcsClient | ||
opts *options | ||
} | ||
|
||
type options struct { | ||
dbProject string | ||
storageProject string | ||
db string | ||
storageBucket string | ||
upload bool | ||
} | ||
|
||
func (c *rumbleBase) setupClients() (func(), error) { | ||
var err error | ||
|
||
c.bqClient, err = cgbigquery.NewBqClient(c.opts.dbProject, c.opts.db) | ||
if err != nil { | ||
log.Fatalf("error initializing bq client: %v", err) | ||
} | ||
|
||
// Only instantiate gcs client if we're uploading | ||
if c.opts.upload { | ||
c.storageClient, err = cloudstorage.NewGcsClient(c.ctx, c.opts.storageBucket) | ||
if err != nil { | ||
log.Fatalf("error initializing gcs client: %v", err) | ||
} | ||
} | ||
|
||
return func() { | ||
if err := c.bqClient.Client.Close(); err != nil { | ||
log.Println(err) | ||
} | ||
if c.storageClient.Client != nil { | ||
if err := c.storageClient.Client.Close(); err != nil { | ||
log.Println(err) | ||
} | ||
} | ||
}, nil | ||
} |
Oops, something went wrong.