Skip to content

Commit 633dd3d

Browse files
committed
Add option to only include specific targets in conversion
1 parent 6ea4636 commit 633dd3d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

utils/results/conversion/convertor.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package conversion
22

33
import (
4+
"slices"
5+
46
"github.com/CycloneDX/cyclonedx-go"
57
"github.com/jfrog/jfrog-cli-security/utils"
68
"github.com/jfrog/jfrog-cli-security/utils/formats"
@@ -43,6 +45,8 @@ type ResultConvertParams struct {
4345
Pretty bool
4446
// The JFrog platform URL to be used in the results (Sarif only - GitHub integration)
4547
PlatformUrl string
48+
// A list of target names to include in the output, if empty all targets will be included
49+
IncludeTargets []string
4650
}
4751

4852
func NewCommandResultsConvertor(params ResultConvertParams) *CommandResultsConvertor {
@@ -108,6 +112,10 @@ func parseCommandResults[T interface{}](params ResultConvertParams, parser Resul
108112
return
109113
}
110114
for _, targetScansResults := range cmdResults.Targets {
115+
if len(params.IncludeTargets) > 0 && !slices.Contains(params.IncludeTargets, targetScansResults.Target) {
116+
// Skip this target as it's not in the include list
117+
continue
118+
}
111119
if err = parser.ParseNewTargetResults(targetScansResults.ScanTarget, targetScansResults.Errors...); err != nil {
112120
return
113121
}

0 commit comments

Comments
 (0)