1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-10-30 23:57:50 +02:00

feat(whitesourcescan): add param workDir to whitesourcescan (#2791)

* Add dir to whitesource scan

* Add default for "dir" option

* Change param name to workDir

* Change param name WorkDir to ScanPath

Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
This commit is contained in:
pkrasnousov
2021-05-03 11:53:16 +03:00
committed by GitHub
parent a91f1f7597
commit e9464b2594
5 changed files with 23 additions and 2 deletions

View File

@@ -412,6 +412,7 @@ func wsScanOptions(config *ScanOptions) *ws.ScanOptions {
JreDownloadURL: config.JreDownloadURL,
AgentURL: config.AgentURL,
ServiceURL: config.ServiceURL,
ScanPath: config.ScanPath,
Verbose: GeneralConfig.Verbose,
}
}

View File

@@ -28,6 +28,7 @@ type whitesourceExecuteScanOptions struct {
CreateProductFromPipeline bool `json:"createProductFromPipeline,omitempty"`
CustomScanVersion string `json:"customScanVersion,omitempty"`
CvssSeverityLimit string `json:"cvssSeverityLimit,omitempty"`
ScanPath string `json:"scanPath,omitempty"`
EmailAddressesOfInitialProductAdmins []string `json:"emailAddressesOfInitialProductAdmins,omitempty"`
Excludes []string `json:"excludes,omitempty"`
Includes []string `json:"includes,omitempty"`
@@ -217,6 +218,7 @@ func addWhitesourceExecuteScanFlags(cmd *cobra.Command, stepConfig *whitesourceE
cmd.Flags().BoolVar(&stepConfig.CreateProductFromPipeline, "createProductFromPipeline", true, "Whether to create the related WhiteSource product on the fly based on the supplied pipeline configuration.")
cmd.Flags().StringVar(&stepConfig.CustomScanVersion, "customScanVersion", os.Getenv("PIPER_customScanVersion"), "Custom version of the WhiteSource project used as source.")
cmd.Flags().StringVar(&stepConfig.CvssSeverityLimit, "cvssSeverityLimit", `-1`, "Limit of tolerable CVSS v3 score upon assessment and in consequence fails the build.")
cmd.Flags().StringVar(&stepConfig.ScanPath, "scanPath", `.`, "Directory where to start WhiteSource scan.")
cmd.Flags().StringSliceVar(&stepConfig.EmailAddressesOfInitialProductAdmins, "emailAddressesOfInitialProductAdmins", []string{}, "The list of email addresses to assign as product admins for newly created WhiteSource products.")
cmd.Flags().StringSliceVar(&stepConfig.Excludes, "excludes", []string{}, "List of file path patterns to exclude in the scan.")
cmd.Flags().StringSliceVar(&stepConfig.Includes, "includes", []string{}, "List of file path patterns to include in the scan.")
@@ -368,6 +370,14 @@ func whitesourceExecuteScanMetadata() config.StepData {
Mandatory: false,
Aliases: []config.Alias{},
},
{
Name: "scanPath",
ResourceRef: []config.ResourceReference{},
Scope: []string{"PARAMETERS", "STAGES", "STEPS"},
Type: "string",
Mandatory: false,
Aliases: []config.Alias{},
},
{
Name: "emailAddressesOfInitialProductAdmins",
ResourceRef: []config.ResourceReference{},

View File

@@ -42,5 +42,7 @@ type ScanOptions struct {
AgentURL string
ServiceURL string
ScanPath string
Verbose bool
}

View File

@@ -22,7 +22,7 @@ const projectRegEx = `Project name: ([^,]*), URL: (.*)`
// ExecuteUAScan executes a scan with the Whitesource Unified Agent.
func (s *Scan) ExecuteUAScan(config *ScanOptions, utils Utils) error {
if config.BuildTool != "mta" {
return s.ExecuteUAScanInPath(config, utils, ".")
return s.ExecuteUAScanInPath(config, utils, config.ScanPath)
}
log.Entry().Infof("Executing WhiteSource UA scan for MTA project")
@@ -30,7 +30,7 @@ func (s *Scan) ExecuteUAScan(config *ScanOptions, utils Utils) error {
if pomExists {
mavenConfig := *config
mavenConfig.BuildTool = "maven"
if err := s.ExecuteUAScanInPath(&mavenConfig, utils, "."); err != nil {
if err := s.ExecuteUAScanInPath(&mavenConfig, utils, config.ScanPath); err != nil {
return errors.Wrap(err, "failed to run scan for maven modules of mta")
}
} else {

View File

@@ -136,6 +136,14 @@ spec:
- STAGES
- STEPS
default: "-1"
- name: scanPath
type: string
description: "Directory where to start WhiteSource scan."
scope:
- PARAMETERS
- STAGES
- STEPS
default: "."
- name: emailAddressesOfInitialProductAdmins
type: "[]string"
description: "The list of email addresses to assign as product admins for newly created WhiteSource products."