github / github/codeql

Incorrect escaping of SARIF message.text

Aperta
#14,128 1 commento 0 reazioni 1 assegnatario Rivendicata da @aeisenberg Vedi su GitHub
question
Lingua principale
CodeQL
Stelle
10.1k
Fork
2.1k
Merge medio
2g 15h
PR unite (30g)
141

Descrizione

**Description of the issue**

Hello, after uploading a SARIF log to GitHub and opening the results using Code Scanning, I found that the message content had been altered before display: backquotes were not displayed in the message, and underscores were escaped.

For example:

```
"message": {
"text": "Some issue with `backquoted expression`, and path `some.path_with.underscore_suffix` on line 100"
},
```

and the result displayed on GitHub is:
```
Some issue with backquoted expression, and path some.path\_with.underscore\_suffix on line 100
```

This seems to be a bug, I did not see any requirement about this kind of escaping in the [SARIF specification](https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html). As far as I understand the text should be rendered as is.
However in section "K.4 Comprehensive SARIF file" I see in the example:

```
"text": "Variable \"{0}\" was used without being initialized.

It was declared [here]({1}).",

"markdown": "Variable `{0}` was used without being initialized.

It was declared [here]({1})."
```
so it seems more correct to use `"\` instead of backquotes in the plain text string, and use backquotes in the markdown string. I have tried that, and the Code Scanning displayed results did not have any issue this time (they seem to use the markdown string), so the markdown version can be used as a workaround.

Although there was no special highlighting of the escaped \`string\`, contrary to what would be expected in Markdown rendering, so that could be improved.

Thanks

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.