1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00

fix(checkmarx) Fix logic for engineConfigurationID (#4154)

* Fix logic for engineConfigurationID
Use the project-level value if no value is defined in the piper config.
Remove the default value of 1 for engineConfigurationID.
This commit is contained in:
Adrien 2022-12-12 15:31:21 +01:00 committed by GitHub
parent 50ac1a3ab5
commit 15d91ce659
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -350,7 +350,7 @@ func addCheckmarxExecuteScanFlags(cmd *cobra.Command, stepConfig *checkmarxExecu
cmd.Flags().StringVar(&stepConfig.PullRequestName, "pullRequestName", os.Getenv("PIPER_pullRequestName"), "Used to supply the name for the newly created PR project branch when being used in pull request scenarios")
cmd.Flags().StringVar(&stepConfig.Repository, "repository", os.Getenv("PIPER_repository"), "Set the GitHub repository.")
cmd.Flags().StringVar(&stepConfig.ServerURL, "serverUrl", os.Getenv("PIPER_serverUrl"), "The URL pointing to the root of the Checkmarx server to be used")
cmd.Flags().StringVar(&stepConfig.EngineConfigurationID, "engineConfigurationID", `1`, "The engine configuration ID to be used, if not set explicitly the project's default will be used")
cmd.Flags().StringVar(&stepConfig.EngineConfigurationID, "engineConfigurationID", os.Getenv("PIPER_engineConfigurationID"), "The engine configuration ID to be used, if not set explicitly the project's default will be used")
cmd.Flags().StringVar(&stepConfig.TeamID, "teamId", os.Getenv("PIPER_teamId"), "The group ID related to your team which can be obtained via the Pipeline Syntax plugin as described in the `Details` section")
cmd.Flags().StringVar(&stepConfig.TeamName, "teamName", os.Getenv("PIPER_teamName"), "The full name of the team to assign newly created projects to which is preferred to teamId")
cmd.Flags().StringVar(&stepConfig.Username, "username", os.Getenv("PIPER_username"), "The username to authenticate")
@ -584,7 +584,7 @@ func checkmarxExecuteScanMetadata() config.StepData {
Type: "string",
Mandatory: false,
Aliases: []config.Alias{{Name: "sourceEncoding"}},
Default: `1`,
Default: os.Getenv("PIPER_engineConfigurationID"),
},
{
Name: "teamId",

View File

@ -518,12 +518,17 @@ func (sys *SystemInstance) UpdateProjectConfiguration(projectID int, presetID in
} else {
// Check if the current project config needs to be updated
json.Unmarshal(data, &projectScanSettings)
if projectScanSettings.Preset.PresetID == presetID && projectScanSettings.EngineConfiguration.EngineConfigurationID == engineConfigID {
if projectScanSettings.Preset.PresetID == presetID && (projectScanSettings.EngineConfiguration.EngineConfigurationID == engineConfigID || engineConfigID == 0) {
sys.logger.Debugf("Project configuration does not need to be updated")
return nil
}
}
// use the project-level value to configure the project if no value was provided in piper config
if engineConfigID == 0 {
engineConfigID = projectScanSettings.EngineConfiguration.EngineConfigurationID
}
jsonData := map[string]interface{}{
"projectId": projectID,
"presetId": presetID,

View File

@ -208,7 +208,6 @@ spec:
- PARAMETERS
- STAGES
- STEPS
default: "1"
aliases:
- name: sourceEncoding
- name: teamId