Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rocky): support modular package #1624

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions pkg/detector/ospkg/rocky/rocky.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,7 @@ func (s *Scanner) Detect(osVer string, pkgs []ftypes.Package) ([]types.DetectedV
log.Logger.Debugf("Rocky Linux: the number of packages: %d", len(pkgs))

var vulns []types.DetectedVulnerability
var skipPkgs []string
for _, pkg := range pkgs {
if pkg.Modularitylabel != "" {
skipPkgs = append(skipPkgs, pkg.Name)
continue
}
pkgName := addModularNamespace(pkg.Name, pkg.Modularitylabel)
advisories, err := s.vs.Get(osVer, pkgName)
if err != nil {
Expand All @@ -96,9 +91,6 @@ func (s *Scanner) Detect(osVer string, pkgs []ftypes.Package) ([]types.DetectedV
}
}
}
if len(skipPkgs) > 0 {
log.Logger.Infof("Skipped detection of these packages: %q because modular packages cannot be detected correctly due to a bug in Rocky Linux Errata. See also: https://forums.rockylinux.org/t/some-errata-missing-in-comparison-with-rhel-and-almalinux/3843", skipPkgs)
}

return vulns, nil
}
Expand Down
14 changes: 11 additions & 3 deletions pkg/detector/ospkg/rocky/rocky_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package rocky_test

import (
dbTypes "github.com/aquasecurity/trivy-db/pkg/types"
"testing"
"time"

Expand All @@ -11,6 +10,7 @@ import (

ftypes "github.com/aquasecurity/fanal/types"
"github.com/aquasecurity/trivy-db/pkg/db"
dbTypes "github.com/aquasecurity/trivy-db/pkg/types"
"github.com/aquasecurity/trivy/pkg/dbtest"
"github.com/aquasecurity/trivy/pkg/detector/ospkg/rocky"
"github.com/aquasecurity/trivy/pkg/types"
Expand Down Expand Up @@ -65,7 +65,7 @@ func TestScanner_Detect(t *testing.T) {
},
},
{
name: "skip modular package",
name: "modular package",
fixtures: []string{"testdata/fixtures/modular.yaml", "testdata/fixtures/data-source.yaml"},
args: args{
osVer: "8.5",
Expand All @@ -86,7 +86,15 @@ func TestScanner_Detect(t *testing.T) {
},
},
},
want: nil,
want: []types.DetectedVulnerability{
{
PkgName: "nginx",
VulnerabilityID: "CVE-2021-23017",
InstalledVersion: "1:1.16.1-2.module+el8.4.0+543+efbf198b.0",
FixedVersion: "1:1.16.1-2.module+el8.4.0+543+efbf198b.1",
Layer: ftypes.Layer{},
},
},
},
{
name: "Get returns an error",
Expand Down