You've already forked sap-jenkins-library
mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-11-06 09:09:19 +02:00
fix(codeqlExecuteScan): Fix for GlobalSettingsFile url checks (#4708)
This commit is contained in:
@@ -427,8 +427,9 @@ func getMavenSettings(config *codeqlExecuteScanOptions) string {
|
|||||||
params = " --settings=" + config.ProjectSettingsFile
|
params = " --settings=" + config.ProjectSettingsFile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(config.GlobalSettingsFile) > 0 {
|
if len(config.GlobalSettingsFile) > 0 {
|
||||||
if strings.Contains(config.ProjectSettingsFile, "http") {
|
if strings.Contains(config.GlobalSettingsFile, "http") {
|
||||||
log.Entry().Warn("codeqlExecuteScan's globalSettingsFile param still does not support http(s) urls. Please use a local file path")
|
log.Entry().Warn("codeqlExecuteScan's globalSettingsFile param still does not support http(s) urls. Please use a local file path")
|
||||||
} else {
|
} else {
|
||||||
params = params + " --global-settings=" + config.GlobalSettingsFile
|
params = params + " --global-settings=" + config.GlobalSettingsFile
|
||||||
|
|||||||
@@ -338,17 +338,29 @@ func TestGetMavenSettings(t *testing.T) {
|
|||||||
assert.Equal(t, " --settings=test.xml --global-settings=global.xml", params)
|
assert.Equal(t, " --settings=test.xml --global-settings=global.xml", params)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Skip incase of https url", func(t *testing.T) {
|
t.Run("Skip incase of ProjectSettingsFile https url", func(t *testing.T) {
|
||||||
config := codeqlExecuteScanOptions{BuildTool: "maven", BuildCommand: "mvn clean install", ProjectSettingsFile: "https://jenkins-sap-test.com/test.xml"}
|
config := codeqlExecuteScanOptions{BuildTool: "maven", BuildCommand: "mvn clean install", ProjectSettingsFile: "https://jenkins-sap-test.com/test.xml"}
|
||||||
params := getMavenSettings(&config)
|
params := getMavenSettings(&config)
|
||||||
assert.Equal(t, "", params)
|
assert.Equal(t, "", params)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Skip incase of http url", func(t *testing.T) {
|
t.Run("Skip incase of ProjectSettingsFile http url", func(t *testing.T) {
|
||||||
config := codeqlExecuteScanOptions{BuildTool: "maven", BuildCommand: "mvn clean install", ProjectSettingsFile: "http://jenkins-sap-test.com/test.xml"}
|
config := codeqlExecuteScanOptions{BuildTool: "maven", BuildCommand: "mvn clean install", ProjectSettingsFile: "http://jenkins-sap-test.com/test.xml"}
|
||||||
params := getMavenSettings(&config)
|
params := getMavenSettings(&config)
|
||||||
assert.Equal(t, "", params)
|
assert.Equal(t, "", params)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("Skip incase of GlobalSettingsFile https url", func(t *testing.T) {
|
||||||
|
config := codeqlExecuteScanOptions{BuildTool: "maven", BuildCommand: "mvn clean install", GlobalSettingsFile: "https://jenkins-sap-test.com/test.xml"}
|
||||||
|
params := getMavenSettings(&config)
|
||||||
|
assert.Equal(t, "", params)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Skip incase of GlobalSettingsFile http url", func(t *testing.T) {
|
||||||
|
config := codeqlExecuteScanOptions{BuildTool: "maven", BuildCommand: "mvn clean install", GlobalSettingsFile: "http://jenkins-sap-test.com/test.xml"}
|
||||||
|
params := getMavenSettings(&config)
|
||||||
|
assert.Equal(t, "", params)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type CodeqlSarifUploaderMock struct {
|
type CodeqlSarifUploaderMock struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user