mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-23 15:37:50 -08:00
feat: add --distro flag to manually specify OS distribution for vulnerability scanning (#8070)
Signed-off-by: knqyf263 <knqyf263@gmail.com> Co-authored-by: DmitriyLewen <dmitriy.lewen@smartforce.io>
This commit is contained in:
@@ -36,6 +36,7 @@ type csArgs struct {
|
||||
ListAllPackages bool
|
||||
Target string
|
||||
secretConfig string
|
||||
Distro string
|
||||
}
|
||||
|
||||
func TestClientServer(t *testing.T) {
|
||||
@@ -52,6 +53,18 @@ func TestClientServer(t *testing.T) {
|
||||
},
|
||||
golden: "testdata/alpine-39.json.golden",
|
||||
},
|
||||
{
|
||||
name: "alpine 3.9 as alpine 3.10",
|
||||
args: csArgs{
|
||||
Input: "testdata/fixtures/images/alpine-39.tar.gz",
|
||||
Distro: "alpine/3.10",
|
||||
},
|
||||
override: func(t *testing.T, want, got *types.Report) {
|
||||
want.Metadata.OS.Name = "3.10"
|
||||
want.Results[0].Target = "testdata/fixtures/images/alpine-39.tar.gz (alpine 3.10)"
|
||||
},
|
||||
golden: "testdata/alpine-39.json.golden",
|
||||
},
|
||||
{
|
||||
name: "alpine 3.9 with high and critical severity",
|
||||
args: csArgs{
|
||||
@@ -684,6 +697,10 @@ func setupClient(t *testing.T, c csArgs, addr string, cacheDir string) []string
|
||||
osArgs = append(osArgs, c.Target)
|
||||
}
|
||||
|
||||
if c.Distro != "" {
|
||||
osArgs = append(osArgs, "--distro", c.Distro)
|
||||
}
|
||||
|
||||
return osArgs
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user