Skip to content

Commit f332603

Browse files
authored
Add support for uppercase filter in results command (#1136)
Extended the filtering logic to handle uppercase 'EXCLUDE_NOT_EXPLOITABLE' state in results command. Added a new integration test to validate JSON report generation with mixed-case filters for state, severity, and status.
1 parent 06641d9 commit f332603

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

internal/commands/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ const configFormatString = "%30v: %s"
225225
var extraFilter = map[string]map[string]string{
226226
"state": {
227227
"exclude_not_exploitable": "TO_VERIFY;PROPOSED_NOT_EXPLOITABLE;CONFIRMED;URGENT",
228+
"EXCLUDE_NOT_EXPLOITABLE": "TO_VERIFY;PROPOSED_NOT_EXPLOITABLE;CONFIRMED;URGENT",
228229
},
229230
"severity": {},
230231
"status": {},

test/integration/result_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,26 @@ func TestResultsGeneratingReportWithExcludeNotExploitableStateAndSeverityAndStat
551551
assert.Assert(t, outputBuffer != nil, "Scan must complete successfully")
552552
}
553553

554+
func TestResultsGeneratingReportWithExcludeNotExploitableUpperCaseStateAndSeverityAndStatus(t *testing.T) {
555+
scanID, _ := getRootScan(t)
556+
557+
outputBuffer := executeCmdNilAssertion(
558+
t, "Results show generating Json report with severity and state",
559+
"results", "show",
560+
flag(params.ScanIDFlag), scanID,
561+
flag(params.TargetFormatFlag), printer.FormatJSON,
562+
flag(params.TargetFlag), fileName,
563+
flag(params.FilterFlag), "state=EXCLUDE_NOT_EXPLOITABLE;TO_VERIFY,severity=High;Low,status=new;recurrent",
564+
)
565+
defer func() {
566+
os.Remove(fmt.Sprintf("%s.%s", fileName, printer.FormatJSON))
567+
log.Println("test file removed!")
568+
}()
569+
_, err := os.Stat(fmt.Sprintf("%s.%s", fileName, printer.FormatJSON))
570+
assert.NilError(t, err, "Report file should exist: "+fileName+printer.FormatJSON)
571+
assert.Assert(t, outputBuffer != nil, "Scan must complete successfully")
572+
}
573+
554574
func TestResultsShow_ScanIDWithSnoozedAndMutedAllVulnerabilities_NoVulnerabilitiesInScan(t *testing.T) {
555575
reportFilePath := fmt.Sprintf("%s%s.%s", resultsDirectory, fileName, printer.FormatJSON)
556576

0 commit comments

Comments
 (0)