You can import Static Analysis Results Interchange Format (SARIF) reports into SonarQube. The issues will be taken into account by SonarQube in the analysis report, but the rules corresponding to these issues will not be visible on the Rules page nor reflected in quality profiles. This means that the rules that raise external issues must be managed in your third-party tool.
SonarQube manages the import of a SARIF issue as follows:
- It assigns the
CONVENTIONALClean Code attribute and the
SECURITYsoftware quality to the issue.
- It manages the issue severity as follows:
- If a SARIF severity field is provided at the rule level for the issue then the mapping below is used to retrieve the corresponding SonarQube severity.
|SARIF 2.1.0 severity||SonarQube severity|
- Otherwise, the default MEDIUM severity is applied.
See Clean Code for details about the Clean Code concepts mentioned above.
To set up the import of SARIF reports into SonarQube:
- Prepare your SARIF report files according to the import file specifications below.
- Use on the scanner side the analysis parameter
sonar.sarifReportPathsto define the list of SARIF report files to be imported during your project analysis. This parameter accepts a comma-delimited list of paths.
The SARIF files must:
- Be UTF-8 file encoded.
- Comply with the official SARIF format, version 2.1.0.
|Must be set to “2.1.0”.|
|Name of the tool that created the report.|
|Message of the external issue.|
|Identifier of the corresponding rule in the tool that created the report.|
If a mandatory field is missing, the report is ignored (see the corresponding line in the logs).
|SonarQube only uses the first item in the array. It must be a physical location.|
Path of the file concerned by the issue.
If no location is defined, the issue is raised at the project level.
Text range concerned by the issue. Is defined by the following fields:
|Rule’s severity. SonarQube uses this field to determine the issue severity.|
|Rule’s severity. SonarQube uses this field to determine the issue severity if the driver field above is not used.|
The sarifLog.runs.results.level field which defines the issue's severity will be ignored by SonarQube.
© 2008-2023, SonarSource S.A, Switzerland. Except where otherwise noted, content in this space is licensed under a Creative Commons Attribution-NonCommercial 3.0 United States License. SONARQUBE is a trademark of SonarSource SA. All other trademarks and copyrights are the property of their respective owners.