Security Hotspots Reappearing After Review

We are currently undergoing the process of using Sonar Cloud for all of our projects. We are planning on using Sonar to automatically break the build on our ADO hosted git repos and have set our quality gates to break on Bugs, Vulnerabilities and incomplete security reviews.

I am running into an issue where I have gone through the security review several times for the same hotspot despite marking the hotspot as safe on multiple prior reviews.

It seems every time new code is merged to our develop branch the security review does not remember that the hotspot has already been reviewed and marked as safe.

Additionally to this I am getting some errors raised against code that has already been changed to fix the security issue, but the file shown in sonar is an old version of the code.

Hey there.

What language(s) are you analyzing, and how is your Azure DevOps piplien configured? Feel free to share the Azure DevOps pipeline YAML here (or at least, an example of one where the SonarCloud project exhibits this behavior)

The language in question is C#.

Two issues as an example that re-occur after already being marked safe in review are.

  • An open CORS policy.
  • A local connection string in an appconfig.

Section of the YML dealing with SONAR is here.

      - checkout: self
      - task: SonarCloudPrepare@1
          SonarCloud: 'SonarCloud 2.0'
          organization: '<OurOrganization>'
          scannerMode: 'MSBuild'
          projectKey: '<OurProjectKey>'
          extraProperties: |
      - task: DotNetCoreCLI@2
        displayName: Restore
          command: restore
          projects: $(BuildParameters.RestoreBuildProjects)
          feedsToUse: config
          nugetConfigPath: "nuget.config"
      - task: DotNetCoreCLI@2
        displayName: Build
          projects: $(BuildParameters.RestoreBuildProjects)
          arguments: "--configuration $(BuildConfiguration)"
      - task: DotNetCoreCLI@2
        displayName: Test
          command: test
          projects: $(BuildParameters.TestProjects)
          arguments: >-
            --configuration $(BuildConfiguration)
      - task: SonarCloudAnalyze@1
      - task: SonarCloudPublish@1
          pollingTimeoutSec: '300'


The behavior you’re describing sounds like it could be the result of a non-clean (non-full) build happening, which SonarCloud needs. Without this, the Security Hotspots get closed and then reopened when some code is missing or analysis isn’t complete.

One way to check is looking at the Activity tab of your project. Do you see any wild variations for metrics like Lines of Code or Issues over time?

The builds are from Azure Devops Build Agents automatically triggered on a Pull request so these builds should be full builds every time?

Yes, especially when you’re building your main branch. Are they currently configured as an incremental build?