Skip to content

Commit

Permalink
rhel: deprecate updater in favor of VEX updater
Browse files Browse the repository at this point in the history
We can extract vulnerability information about containers from the
VEX data. This negates the need to look for it in the cvemap.xml file.
This change modifies the VEX updater to allow for ingesting
vulnerabilities in a way that can be matched my the RHCC matcher.

Signed-off-by: crozzy <[email protected]>
  • Loading branch information
crozzy committed Dec 16, 2024
1 parent f49fb5d commit 4701605
Show file tree
Hide file tree
Showing 23 changed files with 3,862 additions and 914 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- The rhel-vex updater will now be responsible for RHCC advisories so we have
-- to delete the existing RHCC vulnerabilities.
DELETE FROM update_operation WHERE updater = 'rhel-container-updater';
DELETE FROM vuln where updater = 'rhel-container-updater';
4 changes: 4 additions & 0 deletions datastore/postgres/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,8 @@ var MatcherMigrations = []migrate.Migration{
ID: 13,
Up: runFile("matcher/13-delete-rhel-oval.sql"),
},
{
ID: 14,
Up: runFile("matcher/14-delete-rhcc-vulns.sql"),
},
}
51 changes: 51 additions & 0 deletions pkg/rhctag/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,54 @@ func TestOrdering(t *testing.T) {
t.Run(tc.Name, tc.Run)
}
}

type renderTestcase struct {
name string
versionIn string
min bool
expectedVersionString string
}

func (tc renderTestcase) Run(t *testing.T) {
v, err := Parse(tc.versionIn)
if err != nil {
t.Fatal(err)
}
ccVer := v.Version(tc.min)
rv := &ccVer
if rv.String() != tc.expectedVersionString {
t.Errorf("unexpected version %s but expected %s", rv.String(), tc.expectedVersionString)
}
}

func TestRendering(t *testing.T) {
testcases := []renderTestcase{
{
name: "no_min",
min: false,
versionIn: "1.9.0-9",
expectedVersionString: "1!9.2147483647",
},
{
name: "with_min",
min: true,
versionIn: "1.9.0-9",
expectedVersionString: "1!9",
},
{
name: "with_v",
min: true,
versionIn: "v3.4.0-2",
expectedVersionString: "3!4",
},
{
name: "check_minor",
min: true,
versionIn: "v3.5.7-8",
expectedVersionString: "3!5",
},
}
for _, tc := range testcases {
t.Run(tc.name, tc.Run)
}
}
4 changes: 2 additions & 2 deletions rhel/rhcc/coalescer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestCoalescer(t *testing.T) {
// Mark them as if they came from this package's package scanner
p.RepositoryHint = `rhcc`
}
repo := []*claircore.Repository{&goldRepo}
repo := []*claircore.Repository{&GoldRepo}
layerArtifacts := []*indexer.LayerArtifacts{
{
Hash: test.RandomSHA256Digest(t),
Expand Down Expand Up @@ -67,7 +67,7 @@ func TestCoalescer(t *testing.T) {
}
for _, id := range e.RepositoryIDs {
r := ir.Repositories[id]
if got, want := r.Name, goldRepo.Name; got != want {
if got, want := r.Name, GoldRepo.Name; got != want {
t.Errorf("got: %q, want: %q", got, want)
}
}
Expand Down
51 changes: 0 additions & 51 deletions rhel/rhcc/fetcher_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion rhel/rhcc/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (*matcher) Name() string { return "rhel-container-matcher" }
// Filter implements [driver.Matcher].
func (*matcher) Filter(r *claircore.IndexRecord) bool {
return r.Repository != nil &&
r.Repository.Name == goldRepo.Name
r.Repository.Name == GoldRepo.Name
}

// Query implements [driver.Matcher].
Expand Down
Loading

0 comments on commit 4701605

Please sign in to comment.