mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-30 05:59:39 +02:00
feat(detectExecuteScan) enabling possibility to scan MTA projects (#4300)
* feat(detectExecuteScan) enabling possibility to scan MTA projects
This commit is contained in:
parent
d76246d781
commit
e55c2f857c
@ -301,6 +301,15 @@ func addDetectArgs(args []string, config detectExecuteScanOptions, utils detectU
|
|||||||
// instead of all properties being part of a single string
|
// instead of all properties being part of a single string
|
||||||
config.ScanProperties = piperutils.SplitAndTrim(config.ScanProperties, " ")
|
config.ScanProperties = piperutils.SplitAndTrim(config.ScanProperties, " ")
|
||||||
|
|
||||||
|
if config.BuildTool == "mta" {
|
||||||
|
args = append(args, "--detect.detector.search.depth=100")
|
||||||
|
args = append(args, "--detect.detector.search.continue=true")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(config.ExcludedDirectories) != 0 {
|
||||||
|
args = append(args, fmt.Sprintf("--detect.excluded.directories=%s", strings.Join(config.ExcludedDirectories, ",")))
|
||||||
|
}
|
||||||
|
|
||||||
if config.ScanOnChanges {
|
if config.ScanOnChanges {
|
||||||
args = append(args, "--report")
|
args = append(args, "--report")
|
||||||
config.Unmap = false
|
config.Unmap = false
|
||||||
|
@ -55,6 +55,8 @@ type detectExecuteScanOptions struct {
|
|||||||
Assignees []string `json:"assignees,omitempty"`
|
Assignees []string `json:"assignees,omitempty"`
|
||||||
CustomTLSCertificateLinks []string `json:"customTlsCertificateLinks,omitempty"`
|
CustomTLSCertificateLinks []string `json:"customTlsCertificateLinks,omitempty"`
|
||||||
FailOnSevereVulnerabilities bool `json:"failOnSevereVulnerabilities,omitempty"`
|
FailOnSevereVulnerabilities bool `json:"failOnSevereVulnerabilities,omitempty"`
|
||||||
|
BuildTool string `json:"buildTool,omitempty"`
|
||||||
|
ExcludedDirectories []string `json:"excludedDirectories,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type detectExecuteScanInflux struct {
|
type detectExecuteScanInflux struct {
|
||||||
@ -285,6 +287,8 @@ func addDetectExecuteScanFlags(cmd *cobra.Command, stepConfig *detectExecuteScan
|
|||||||
cmd.Flags().StringSliceVar(&stepConfig.Assignees, "assignees", []string{``}, "Defines the assignees for the Github Issue created/updated with the results of the scan as a list of login names.")
|
cmd.Flags().StringSliceVar(&stepConfig.Assignees, "assignees", []string{``}, "Defines the assignees for the Github Issue created/updated with the results of the scan as a list of login names.")
|
||||||
cmd.Flags().StringSliceVar(&stepConfig.CustomTLSCertificateLinks, "customTlsCertificateLinks", []string{}, "List of download links to custom TLS certificates. This is required to ensure trusted connections to instances with repositories (like nexus) when publish flag is set to true.")
|
cmd.Flags().StringSliceVar(&stepConfig.CustomTLSCertificateLinks, "customTlsCertificateLinks", []string{}, "List of download links to custom TLS certificates. This is required to ensure trusted connections to instances with repositories (like nexus) when publish flag is set to true.")
|
||||||
cmd.Flags().BoolVar(&stepConfig.FailOnSevereVulnerabilities, "failOnSevereVulnerabilities", true, "Whether to fail the step on severe vulnerabilties or not")
|
cmd.Flags().BoolVar(&stepConfig.FailOnSevereVulnerabilities, "failOnSevereVulnerabilities", true, "Whether to fail the step on severe vulnerabilties or not")
|
||||||
|
cmd.Flags().StringVar(&stepConfig.BuildTool, "buildTool", os.Getenv("PIPER_buildTool"), "Defines the tool which is used for building the artifact.")
|
||||||
|
cmd.Flags().StringSliceVar(&stepConfig.ExcludedDirectories, "excludedDirectories", []string{}, "List of directories which should be excluded from the scan.")
|
||||||
|
|
||||||
cmd.MarkFlagRequired("token")
|
cmd.MarkFlagRequired("token")
|
||||||
cmd.MarkFlagRequired("projectName")
|
cmd.MarkFlagRequired("projectName")
|
||||||
@ -649,6 +653,29 @@ func detectExecuteScanMetadata() config.StepData {
|
|||||||
Aliases: []config.Alias{},
|
Aliases: []config.Alias{},
|
||||||
Default: true,
|
Default: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "buildTool",
|
||||||
|
ResourceRef: []config.ResourceReference{
|
||||||
|
{
|
||||||
|
Name: "commonPipelineEnvironment",
|
||||||
|
Param: "buildTool",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Scope: []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"},
|
||||||
|
Type: "string",
|
||||||
|
Mandatory: false,
|
||||||
|
Aliases: []config.Alias{},
|
||||||
|
Default: os.Getenv("PIPER_buildTool"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "excludedDirectories",
|
||||||
|
ResourceRef: []config.ResourceReference{},
|
||||||
|
Scope: []string{"PARAMETERS", "STAGES", "STEPS"},
|
||||||
|
Type: "[]string",
|
||||||
|
Mandatory: false,
|
||||||
|
Aliases: []config.Alias{{Name: "detect/excludedDirectories"}},
|
||||||
|
Default: []string{},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Containers: []config.Container{
|
Containers: []config.Container{
|
||||||
|
@ -355,18 +355,23 @@ func TestAddDetectArgs(t *testing.T) {
|
|||||||
{
|
{
|
||||||
args: []string{"--testProp1=1"},
|
args: []string{"--testProp1=1"},
|
||||||
options: detectExecuteScanOptions{
|
options: detectExecuteScanOptions{
|
||||||
ScanProperties: []string{"--scan1=1", "--scan2=2"},
|
BuildTool: "mta",
|
||||||
ServerURL: "https://server.url",
|
ExcludedDirectories: []string{"dir1", "dir2"},
|
||||||
Token: "apiToken",
|
ScanProperties: []string{"--scan1=1", "--scan2=2"},
|
||||||
ProjectName: "testName",
|
ServerURL: "https://server.url",
|
||||||
Version: "1.0",
|
Token: "apiToken",
|
||||||
VersioningModel: "major-minor",
|
ProjectName: "testName",
|
||||||
CodeLocation: "",
|
Version: "1.0",
|
||||||
Scanners: []string{"signature"},
|
VersioningModel: "major-minor",
|
||||||
ScanPaths: []string{"path1", "path2"},
|
CodeLocation: "",
|
||||||
|
Scanners: []string{"signature"},
|
||||||
|
ScanPaths: []string{"path1", "path2"},
|
||||||
},
|
},
|
||||||
expected: []string{
|
expected: []string{
|
||||||
"--testProp1=1",
|
"--testProp1=1",
|
||||||
|
"--detect.detector.search.depth=100",
|
||||||
|
"--detect.detector.search.continue=true",
|
||||||
|
"--detect.excluded.directories=dir1,dir2",
|
||||||
"--scan1=1",
|
"--scan1=1",
|
||||||
"--scan2=2",
|
"--scan2=2",
|
||||||
"--blackduck.url=https://server.url",
|
"--blackduck.url=https://server.url",
|
||||||
|
@ -406,6 +406,27 @@ spec:
|
|||||||
scope:
|
scope:
|
||||||
- PARAMETERS
|
- PARAMETERS
|
||||||
default: true
|
default: true
|
||||||
|
- name: buildTool
|
||||||
|
type: string
|
||||||
|
description: "Defines the tool which is used for building the artifact."
|
||||||
|
scope:
|
||||||
|
- GENERAL
|
||||||
|
- PARAMETERS
|
||||||
|
- STAGES
|
||||||
|
- STEPS
|
||||||
|
resourceRef:
|
||||||
|
- name: commonPipelineEnvironment
|
||||||
|
param: buildTool
|
||||||
|
- name: excludedDirectories
|
||||||
|
description:
|
||||||
|
"List of directories which should be excluded from the scan."
|
||||||
|
aliases:
|
||||||
|
- name: detect/excludedDirectories
|
||||||
|
type: "[]string"
|
||||||
|
scope:
|
||||||
|
- PARAMETERS
|
||||||
|
- STAGES
|
||||||
|
- STEPS
|
||||||
outputs:
|
outputs:
|
||||||
resources:
|
resources:
|
||||||
- name: influx
|
- name: influx
|
||||||
|
Loading…
x
Reference in New Issue
Block a user