Skip to content

Commit

Permalink
feat(oval/suse): skip comparing TDC package and non-TDC package (#2025)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaineK00n authored Sep 24, 2024
1 parent e776be1 commit 1a54673
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 3 deletions.
12 changes: 9 additions & 3 deletions oval/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,15 @@ func isOvalDefAffected(def ovalmodels.Definition, req request, family, release s
continue
}

// https://github.com/aquasecurity/trivy/blob/08cc14bd2171afdc1973c6d614dd0d1fb82b7623/pkg/detector/ospkg/oracle/oracle.go#L72-L77
if family == constant.Oracle && extractOracleKsplice(ovalPack.Version) != extractOracleKsplice(req.versionRelease) {
continue
switch family {
case constant.Oracle: // https://github.com/aquasecurity/trivy/blob/08cc14bd2171afdc1973c6d614dd0d1fb82b7623/pkg/detector/ospkg/oracle/oracle.go#L72-L77
if extractOracleKsplice(ovalPack.Version) != extractOracleKsplice(req.versionRelease) {
continue
}
case constant.SUSEEnterpriseServer:
if strings.Contains(ovalPack.Version, ".TDC.") != strings.Contains(req.versionRelease, ".TDC.") {
continue
}
}

// There is a modular package and a non-modular package with the same name. (e.g. fedora 35 community-mysql)
Expand Down
82 changes: 82 additions & 0 deletions oval/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2364,6 +2364,88 @@ func TestIsOvalDefAffected(t *testing.T) {
fixState: "Affected",
fixedIn: "",
},
{
in: in{
family: constant.SUSEEnterpriseServer,
release: "12.3",
def: ovalmodels.Definition{
AffectedPacks: []ovalmodels.Package{
{
Name: "kernel-default",
Version: "0:4.4.140-96.98",
},
},
},
req: request{
packName: "kernel-default",
versionRelease: "0:4.4.140-96.97",
arch: "x86_64",
},
},
affected: true,
fixedIn: "0:4.4.140-96.98",
},
{
in: in{
family: constant.SUSEEnterpriseServer,
release: "12.3",
def: ovalmodels.Definition{
AffectedPacks: []ovalmodels.Package{
{
Name: "kernel-default",
Version: "0:4.4.140-96.97.TDC.1",
},
},
},
req: request{
packName: "kernel-default",
versionRelease: "0:4.4.140-96.97",
arch: "x86_64",
},
},
affected: false,
},
{
in: in{
family: constant.SUSEEnterpriseServer,
release: "12.3",
def: ovalmodels.Definition{
AffectedPacks: []ovalmodels.Package{
{
Name: "kernel-default",
Version: "0:4.4.180-94.156.1",
},
},
},
req: request{
packName: "kernel-default",
versionRelease: "0:4.4.140-96.126.TDC.1",
arch: "x86_64",
},
},
affected: false,
},
{
in: in{
family: constant.SUSEEnterpriseServer,
release: "12.3",
def: ovalmodels.Definition{
AffectedPacks: []ovalmodels.Package{
{
Name: "kernel-default",
Version: "0:4.4.140-96.97.TDC.2",
},
},
},
req: request{
packName: "kernel-default",
versionRelease: "0:4.4.140-96.97.TDC.1",
arch: "x86_64",
},
},
affected: true,
fixedIn: "0:4.4.140-96.97.TDC.2",
},
}

for i, tt := range tests {
Expand Down

0 comments on commit 1a54673

Please sign in to comment.