1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00

whitesourceExecuteScan: configuration change: ignoreSourceFiles to fileSystemScan (#3446)

* Update scanPolling.go

Changing maxWaitTime from 15 to 30 to overcome WhiteSource results reflection in the backend issue.

* Update configHelper.go

* Reset configHelper changes to fix PR 3284

 Committer: raghunathd8

* ignoreSourceFiles to fileSystemScan

* Added ignoreSourceFiles param also

* minor adjustment

* minor adjustment again

* updated unit test

* tests fixed

* fmt-ed

Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
Co-authored-by: raghunathd8 <root@docker-evaluation.openstack.eu-nl-1.cloud.sap>
Co-authored-by: Sven Merk <33895725+nevskrem@users.noreply.github.com>
Co-authored-by: ffeldmann <f.feldmann@sap.com>
This commit is contained in:
Raghunath Deshpande 2022-07-13 14:32:53 +02:00 committed by GitHub
parent 81e7423ea6
commit 5cc1b8f418
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 4 deletions

View File

@ -106,8 +106,8 @@ func (c *ConfigOptions) addGeneralDefaults(config *ScanOptions, utils Utils, pro
if config.Verbose {
cOptions = append(cOptions, []ConfigOption{
{Name: "log.level", Value: "trace"},
{Name: "log.files.level", Value: "trace"},
{Name: "log.level", Value: "debug"},
{Name: "log.files.level", Value: "debug"},
}...)
}
@ -151,6 +151,7 @@ func (c *ConfigOptions) addBuildToolDefaults(config *ScanOptions, utils Utils) e
{Name: "docker.scanImages", Value: true, Force: true},
{Name: "docker.scanTarFiles", Value: true, Force: true},
{Name: "docker.includes", Value: ".*.tar", Force: true},
{Name: "fileSystemScan", Value: true},
{Name: "ignoreSourceFiles", Value: false},
{Name: "python.resolveGlobalPackages", Value: true, Force: false},
{Name: "resolveAllDependencies", Value: true, Force: false},
@ -161,9 +162,14 @@ func (c *ConfigOptions) addBuildToolDefaults(config *ScanOptions, utils Utils) e
{Name: "ignoreSourceFiles", Value: true, Force: true},
{Name: "includes", Value: "**/*.d **/*.di"},
},
"dub2": {
{Name: "fileSystemScan", Value: false, Force: true},
{Name: "includes", Value: "**/*.d **/*.di"},
},
//ToDo: rename to go?
//ToDo: switch to gomod as dependency manager
"golang": {
{Name: "fileSystemScan", Value: false, Force: true},
{Name: "ignoreSourceFiles", Value: true, Force: true},
{Name: "go.ignoreSourceFiles", Value: true, Force: true},
{Name: "go.collectDependenciesAtRuntime", Value: false},
@ -172,6 +178,7 @@ func (c *ConfigOptions) addBuildToolDefaults(config *ScanOptions, utils Utils) e
{Name: "includes", Value: "**/*.lock **/*.y*ml **/*.json **/*.tsv"},
},
"gradle": {
{Name: "fileSystemScan", Value: false, Force: true},
{Name: "ignoreSourceFiles", Value: true, Force: true},
{Name: "gradle.resolveDependencies", Value: true, Force: true},
{Name: "gradle.ignoreSourceFiles", Value: true, Force: true},
@ -184,6 +191,7 @@ func (c *ConfigOptions) addBuildToolDefaults(config *ScanOptions, utils Utils) e
{Name: "excludes", Value: "**/*sources.jar **/*javadoc.jar"},
},
"maven": {
{Name: "fileSystemScan", Value: false, Force: true},
{Name: "ignoreSourceFiles", Value: true, Force: true},
{Name: "updateEmptyProject", Value: true, Force: true},
{Name: "maven.resolveDependencies", Value: true, Force: true},
@ -198,6 +206,7 @@ func (c *ConfigOptions) addBuildToolDefaults(config *ScanOptions, utils Utils) e
{Name: "excludes", Value: "**/*sources.jar **/*javadoc.jar"},
},
"npm": {
{Name: "fileSystemScan", Value: false, Force: true},
{Name: "ignoreSourceFiles", Value: true, Force: true},
{Name: "npm.resolveDependencies", Value: true, Force: true},
{Name: "npm.ignoreSourceFiles", Value: true, Force: true},
@ -208,6 +217,7 @@ func (c *ConfigOptions) addBuildToolDefaults(config *ScanOptions, utils Utils) e
{Name: "npm.resolveLockFile", Value: true},
},
"pip": {
{Name: "fileSystemScan", Value: false, Force: true},
{Name: "ignoreSourceFiles", Value: true, Force: true},
{Name: "python.resolveDependencies", Value: true, Force: true},
{Name: "python.ignoreSourceFiles", Value: true, Force: true},
@ -223,6 +233,7 @@ func (c *ConfigOptions) addBuildToolDefaults(config *ScanOptions, utils Utils) e
{Name: "excludes", Value: "**/*sources.jar **/*javadoc.jar"},
},
"sbt": {
{Name: "fileSystemScan", Value: false, Force: true},
{Name: "ignoreSourceFiles", Value: true, Force: true},
{Name: "sbt.resolveDependencies", Value: true, Force: true},
{Name: "sbt.ignoreSourceFiles", Value: true, Force: true},
@ -232,6 +243,7 @@ func (c *ConfigOptions) addBuildToolDefaults(config *ScanOptions, utils Utils) e
{Name: "excludes", Value: "**/*sources.jar **/*javadoc.jar"},
},
"yarn": {
{Name: "fileSystemScan", Value: false, Force: true},
{Name: "ignoreSourceFiles", Value: true, Force: true},
{Name: "npm.resolveDependencies", Value: true, Force: true},
{Name: "npm.ignoreSourceFiles", Value: true, Force: true},

View File

@ -149,9 +149,9 @@ func TestAddGeneralDefaults(t *testing.T) {
}
testConfig.addGeneralDefaults(&whitesourceConfig, utilsMock, "")
assert.Equal(t, "log.level", testConfig[2].Name)
assert.Equal(t, "trace", testConfig[2].Value)
assert.Equal(t, "debug", testConfig[2].Value)
assert.Equal(t, "log.files.level", testConfig[3].Name)
assert.Equal(t, "trace", testConfig[3].Value)
assert.Equal(t, "debug", testConfig[3].Value)
})
t.Run("includes and excludes", func(t *testing.T) {
@ -184,6 +184,17 @@ func TestAddBuildToolDefaults(t *testing.T) {
assert.Equal(t, ConfigOptions{{Name: "ignoreSourceFiles", Value: true, Force: true}, {Name: "includes", Value: "**/*.d **/*.di"}}, testConfig)
})
t.Run("success case", func(t *testing.T) {
utilsMock := NewScanUtilsMock()
var testConfig ConfigOptions
whitesourceConfig := ScanOptions{
BuildTool: "dub2",
}
err := testConfig.addBuildToolDefaults(&whitesourceConfig, utilsMock)
assert.NoError(t, err)
assert.Equal(t, ConfigOptions{{Name: "fileSystemScan", Value: false, Force: true}, {Name: "includes", Value: "**/*.d **/*.di"}}, testConfig)
})
t.Run("error case", func(t *testing.T) {
utilsMock := NewScanUtilsMock()
var testConfig ConfigOptions