Thanks for the report. Can you please provide a small sample project with a complete example of the valid SARIF report (just containing the one issue) where level is not taken into account?
Please find attached a sample project with one rule and one results.
In order to use it, please unfold under C:/gnatmail/gnathub/sdc_tuto/sdc. The sonar-project.properties is located under obj/gnathub/sonar folder and the SARIF file to be used is located under obj/gnatsas/sdc.sarif.
The level is set in the results part as "level": "note" and it is imported as Medium severity and we expected to be set to Low (as shown in the image).
In this case, I believe this section of the docs applies:
But as soon as I try to add the severity to the rule (as the docs suggest):
If a SARIF severity field is provided at the rule level for the issue then the mapping below is used to retrieve the corresponding impact level.
"rules": [
{
"id": "array index check",
"name": "Inspector - array index check",
"level": "note",
"shortDescription": {
"text": "index value could be outside the array bounds"
},
I get an error importing the analysis results.
10:47:41.739 WARN: Failed to process SARIF report from file 'obj/gnatsas/sdc.sarif', error: 'Failed to read SARIF report at '/Users/colin/Downloads/sdc/obj/gnatsas/sdc.sarif': invalid JSON syntax or file is not UTF-8 encoded'
So something seems wrong here. It’s also not good that our examples in the docs document exactly what we tell users will be ignored (severity at the issue level) and don’t document how it should be set at the rule level.
Thanks for flagging this.
Adding just "level": "note", as a field of rule definition is not SARIF format compliant AFAIK.
Could this be fixed and the "level": "note", mentioned at the results level be taken into account?
In any case, the documentation should be updated since it is not accurate to illustrate how to set the security level for the issues.
Thanks for your help!
I thought you figured it out the other day but for some reason you edited it out of your post
{
"id": "array index check",
"name": "Inspector - array index check",
"shortDescription": {
"text": "index value could be outside the array bounds"
},
"defaultConfiguration": {
"level": "note"
}
}
No, this is not actually working. The issue severity level stays on Medium and for "level" : "error" I would expect other than the Severity visible in the image