False positive in docker during PR analysis when renovate.json is unchanged
Environment
-
ALM: Azure DevOps
-
CI: Azure DevOps Pipelines (other repositories); no CI pipeline for this repository’s SonarCloud analysis
-
Analysis: SonarQube Cloud Automatic Analysis, also reproduced with SonarScanner CLI
-
Scanner: SonarScanner CLI 7.2.0.5079
-
IaC plugin: 2.23.0.24355
-
Repository languages: Dockerfile, PowerShell, YAML, XML, JSON
-
Affected rule:
docker:S8431— Specify either version tag or digest for image -
Affected analysis: Pull Request analysis
Problem description
We use Renovate to manage Docker image dependencies, including image references containing both a version tag and a SHA256 digest.
SonarQube Cloud’s rule docker:S8431 explicitly documents an exception for repositories containing a Renovate or Dependabot configuration file, since these tools keep tags and digests synchronized.
Our repository contains a valid renovate.json at the repository root:
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>xxx/yyy//renovate/presets/default"
]
}
This file already exists on main and is also present on the PR source branch.
However, docker:S8431 reports issues when renovate.json is unchanged in the PR. As soon as the root-level renovate.json is modified in the PR, the issues disappear. Reverting that modification causes the issues to reappear.
This behavior is consistently reproducible.
Steps to reproduce
-
Create a repository containing a root-level
renovate.jsonand a Dockerfile that uses an image reference combining a version tag and digest:FROM mcr.microsoft.com/dotnet/aspnet:10.0@sha256:<digest> -
Ensure
renovate.jsonis already committed to the target branch (main). -
Create a pull request that modifies a Dockerfile but does not modify
renovate.json. -
Run SonarQube Cloud PR analysis.
Result:
docker:S8431reports an issue despite the existing Renovate configuration. -
Modify the existing root-level
renovate.jsonin the PR without changing its effective configuration. -
Run the PR analysis again.
Result: The
docker:S8431issues disappear. -
Revert only the modification to the root-level
renovate.jsonand rerun PR analysis.Result: The issues reappear.
I also tested adding a separate renovate.json in the same directory as an affected Dockerfile. This file appeared in the PR Code view, but the docker:S8431 findings remained.
Only modifying the existing root-level configuration caused the findings to disappear.
Additional investigation
1. JSON analysis configuration
The project has JSON analysis enabled:
sonar.json.activate=true
sonar.json.file.suffixes=.json
sonar.sources=.
There are no relevant exclusions affecting renovate.json.
2. Scanner logs confirm that renovate.json is indexed
Running SonarScanner CLI locally on the checked-out repository produced:
DEBUG 'renovate.json' indexed with language 'json'
INFO Quality profile for json: SonarQube Way
INFO Sensor IaC Docker Sensor [iac]
INFO Sensor IaC Docker Sensor [iac] (done) | time=811ms
Therefore, the file is recognized by the scanner and the Docker analyzer executes.
3. JSON analyzer feature flag
During investigation, I discovered the following scanner message:
INFO Sensor for language "JSON" is disabled by a feature flag.
I explicitly enabled the JSON analyzer using:
sonar.featureflag.cloud-security-enable-generic-yaml-and-json-analyzer=true
The scanner then reported:
INFO Sensor for language "JSON" is enabled by a feature flag.
INFO Sensor IaC JSON Sensor [iac] (done) | time=1ms
This did not resolve docker:S8431 during PR analysis.
The findings remained even with the JSON analyzer explicitly enabled.
4. Scanner command
The issue was reproduced using SonarScanner CLI with PR parameters:
sonar-scanner -X \
-Dsonar.projectKey=<PROJECT_KEY> \
-Dsonar.organization=<ORGANIZATION> \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.sources=. \
-Dsonar.pullrequest.key=<PR_ID> \
-Dsonar.pullrequest.branch=<SOURCE_BRANCH> \
-Dsonar.pullrequest.base=main \
-Dsonar.featureflag.cloud-security-enable-generic-yaml-and-json-analyzer=true
The same behavior was observed with SonarQube Cloud Automatic Analysis.
Suspected cause
I investigated the public sonar-iac implementation and found the following change:
SONARIAC-3096 — Suppress Docker S8431 for Dependabot and Renovate projects
The relevant implementation is in DockerSensor.java:
The isUsingDependencyManagementBot() method checks for recognized configuration files using:
fileSystem.hasFiles(predicates.hasRelativePath(path))
My hypothesis: During PR analysis, this lookup may not reliably find an unchanged root-level renovate.json, even when the file exists on the source branch and is indexed by the scanner.
Once the file becomes part of the PR changes, the configuration is detected and the rule is suppressed.
This is an inference from the observed behavior, not a confirmed root cause.
Expected behavior
If a recognized Renovate or Dependabot configuration file exists in the repository, docker:S8431 should respect the documented exception regardless of whether that configuration file was modified in the current pull request.
Actual behavior
The exception appears to depend on whether the root-level renovate.json is modified in the PR.
| Scenario | S8431 findings |
|---|---|
Root-level renovate.json exists but is unchanged |
Reported |
Root-level renovate.json modified in PR |
Not reported |
| Root-level modification reverted | Reported again |
Additional renovate.json beside Dockerfile |
Still reported |
| JSON analyzer explicitly enabled | Still reported |
Potential workaround
Modifying the root-level renovate.json in every affected pull request suppresses the findings, but this is not a practical solution because it introduces unrelated changes.
Alternatively, the findings can be marked as Accepted or the rule disabled in the Quality Profile. However, both approaches weaken the usefulness of the rule.
Ideally, the existing Renovate configuration should be detected independently of whether it is part of the PR changes.