Search code examples
sonarqubecheckmarx

Automatically set Checkmarx configuration on project in SonarQube


Dear stackoverflow community;

I use : SonarQube 6.7.6 with Checkmarx plugin : 8.60.0

I need to configure my project in SonarQube with Checkmarx infos during security analysis so that in SonarQube analysis step, it can retrieve them and populate the project with all Checkmarx analysis data.

As explained on Configuring a Project for the Checkmarx SonarQube Plugin.

I can do it manually but, it's better my pipeline does it automatically. How can I set for example by Rest Api this project configs prior to SonarQube analysis (Server Url, Username, password, ...) or with some analyses properties so that they can be taken automatically.

I couldn't find the Rest Api on SonarQube to do that.

Can anyone help me ?

Thanks a lot. Wognin


Solution

  • Checkmarx settings can be configured in SonarQube by making multiple post calls

    POST /api/settings/set?component=${sonarProjectKey}

    component=${sonarProjectKey}
    key=checkmarx.server.credentials.secured
    value={
      cxServerUrl: ${cxServerUrl},
      cxUsername: ${cxUser},
      cxPassword: ${cxPassword}
    }
    
    component=${sonarProjectKey}
    key=checkmarx.server.project_name.secured
    value=${projectName}
    
    component=${sonarProjectKey}
    key=checkmarx.server.remediation
    value=${minutes}
    

    To fetch corresponding key & value

    GET /api/settings/values?keys=checkmarx.server.remediation&component=${sonarProjectKey}