Skip to content

Commit aae53da

Browse files
fix(cli): filter results from a vulnerability scan (#1367)
* fix(cli): filter results from a vulnerability scan Unfortunately, we applied some filters to the `show-assessment` command but we forgot to apply them to our `scan` command. Signed-off-by: Salim Afiune Maya <afiune@lacework.net> * test: fix TestContainerVulnerabilityCommandsEndToEnd Signed-off-by: Darren Murray <darren.murray@lacework.net> * test: fix TestContainerVulnerabilityCommandsEndToEnd Signed-off-by: Darren Murray <darren.murray@lacework.net> --------- Signed-off-by: Salim Afiune Maya <afiune@lacework.net> Signed-off-by: Darren Murray <darren.murray@lacework.net> Co-authored-by: Darren Murray <darren.murray@lacework.net>
1 parent 8771265 commit aae53da

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

cli/cmd/vuln_container_scan.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ func pollScanStatus(requestID string, args []string) error {
272272
)
273273
}
274274

275+
cli.Log.Infow("raw assessment", "data_points", len(assessment.Data))
276+
filterContainerAssessmentByVulnerable(&assessment)
277+
cli.Log.Infow("filtered assessment (status = vulnerable)", "data_points", len(assessment.Data))
278+
275279
if err := outputContainerVulnerabilityAssessment(assessment); err != nil {
276280
return err
277281
}

integration/container_vulnerability_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func TestContainerVulnerabilityCommandsEndToEnd(t *testing.T) {
276276
)
277277
t.Run(fmt.Sprintf("run scan for %s/%s", registry, dirtyRepository), func(t *testing.T) {
278278
out, err, exitcode = LaceworkCLIWithTOMLConfig(
279-
"vulnerability", "container", "scan", registry, dirtyRepository, "latest", "--poll")
279+
"vulnerability", "container", "scan", registry, dirtyRepository, "latest", "--poll", "--details")
280280
assert.Empty(t,
281281
err.String(),
282282
"STDERR should be empty")
@@ -307,6 +307,9 @@ func TestContainerVulnerabilityCommandsEndToEnd(t *testing.T) {
307307
"Info",
308308
}
309309

310+
assert.NotContains(t, out.String(), "GOOD",
311+
"STDOUT should not have vulnerabilities with status 'GOOD'")
312+
310313
t.Run("inspecting summary scan output/table", func(t *testing.T) {
311314
assert.Contains(t, scanOutput,
312315
"A new vulnerability scan has been requested. (request_id:",
@@ -315,9 +318,6 @@ func TestContainerVulnerabilityCommandsEndToEnd(t *testing.T) {
315318
assert.Contains(t, scanOutput, str,
316319
"STDOUT table does not contain the '"+str+"' output")
317320
}
318-
assert.Contains(t, scanOutput,
319-
"Try adding '--details' to increase details shown about the vulnerability assessment.",
320-
"STDOUT breadcrumbs changed, please update")
321321
})
322322

323323
// extract the image id

0 commit comments

Comments
 (0)