Skip to content

Commit a6c5828

Browse files
authored
Add updated examples from dsp-testing/sarif-demo (#15751)
1 parent 20790e7 commit a6c5828

File tree

1 file changed

+55
-53
lines changed

1 file changed

+55
-53
lines changed

content/github/finding-security-vulnerabilities-and-errors-in-your-code/sarif-support-for-code-scanning.md

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -125,38 +125,47 @@ This SARIF output file has example values to show the minimum required propertie
125125

126126
```json
127127
{
128-
"$schema" : "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
129-
"version" : "2.1.0",
130-
"runs" :
131-
[
132-
{
133-
"tool" : {
134-
"driver" : {
135-
"name" : "Tool Name"
136-
}
137-
},
138-
"results" : [ {
139-
"message" : {
140-
"text" : "Result text. This result does not have a rule associated."
141-
},
142-
"locations" : [ {
143-
"physicalLocation" : {
144-
"artifactLocation" : {
145-
"uri" : "src/build.cmd"
146-
},
147-
"region" : {
148-
"startLine" : 2,
149-
"startColumn" : 7,
150-
"endColumn" : 10
151-
}
152-
}
153-
} ],
154-
"partialFingerprints" : {
155-
"primaryLocationLineHash" : "39fa2ee980eb94b0:1"
156-
}
157-
}]
158-
}
159-
]
128+
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
129+
"version": "2.1.0",
130+
"runs": [
131+
{
132+
"tool": {
133+
"driver": {
134+
"name": "Tool Name",
135+
"rules": [
136+
{
137+
"id": "R01"
138+
}
139+
]
140+
}
141+
},
142+
"results": [
143+
{
144+
"ruleId": "R01",
145+
"message": {
146+
"text": "Result text. This result does not have a rule associated."
147+
},
148+
"locations": [
149+
{
150+
"physicalLocation": {
151+
"artifactLocation": {
152+
"uri": "fileURI"
153+
},
154+
"region": {
155+
"startLine": 2,
156+
"startColumn": 7,
157+
"endColumn": 10
158+
}
159+
}
160+
}
161+
],
162+
"partialFingerprints": {
163+
"primaryLocationLineHash": "39fa2ee980eb94b0:1"
164+
}
165+
}
166+
]
167+
}
168+
]
160169
}
161170
```
162171

@@ -176,7 +185,7 @@ This SARIF output file has example values to show all supported SARIF properties
176185
"semanticVersion": "2.0.0",
177186
"rules": [
178187
{
179-
"id": "js/unused-local-variable",
188+
"id": "3f292041e51d22005ce48f39df3585d44ce1b0ad",
180189
"name": "js/unused-local-variable",
181190
"shortDescription": {
182191
"text": "Unused variable, import, function or class"
@@ -195,15 +204,14 @@ This SARIF output file has example values to show all supported SARIF properties
195204
}
196205
},
197206
{
198-
"id": "js/inconsistent-use-of-new",
207+
"id": "d5b664aefd5ca4b21b52fdc1d744d7d6ab6886d0",
199208
"name": "js/inconsistent-use-of-new",
200209
"shortDescription": {
201210
"text": "Inconsistent use of 'new'"
202211
},
203212
"fullDescription": {
204213
"text": "If a function is intended to be a constructor, it should always be invoked with 'new'. Otherwise, it should always be invoked as a normal function, that is, without 'new'."
205214
},
206-
"defaultConfiguration": null,
207215
"properties": {
208216
"tags": [
209217
"reliability",
@@ -212,13 +220,16 @@ This SARIF output file has example values to show all supported SARIF properties
212220
],
213221
"precision": "very-high"
214222
}
223+
},
224+
{
225+
"id": "R01"
215226
}
216227
]
217228
}
218229
},
219230
"results": [
220231
{
221-
"ruleId": "js/unused-local-variable",
232+
"ruleId": "3f292041e51d22005ce48f39df3585d44ce1b0ad",
222233
"ruleIndex": 0,
223234
"message": {
224235
"text": "Unused variable foo."
@@ -228,8 +239,7 @@ This SARIF output file has example values to show all supported SARIF properties
228239
"physicalLocation": {
229240
"artifactLocation": {
230241
"uri": "main.js",
231-
"uriBaseId": "%SRCROOT%",
232-
"index": 0
242+
"uriBaseId": "%SRCROOT%"
233243
},
234244
"region": {
235245
"startLine": 2,
@@ -245,7 +255,7 @@ This SARIF output file has example values to show all supported SARIF properties
245255
}
246256
},
247257
{
248-
"ruleId": "js/inconsistent-use-of-new",
258+
"ruleId": "d5b664aefd5ca4b21b52fdc1d744d7d6ab6886d0",
249259
"ruleIndex": 1,
250260
"message": {
251261
"text": "Function resolvingPromise is sometimes invoked as a constructor (for example [here](1)), and sometimes as a normal function (for example [here](2))."
@@ -254,8 +264,8 @@ This SARIF output file has example values to show all supported SARIF properties
254264
{
255265
"physicalLocation": {
256266
"artifactLocation": {
257-
"uri": "https://github.com/github/example/blob/0000000000000000000000000000000000000000/src/promiseUtils.js",
258-
"index": 1
267+
"uri": "src/promises.js",
268+
"uriBaseId": "%SRCROOT%"
259269
},
260270
"region": {
261271
"startLine": 2
@@ -273,8 +283,7 @@ This SARIF output file has example values to show all supported SARIF properties
273283
"physicalLocation": {
274284
"artifactLocation": {
275285
"uri": "src/ParseObject.js",
276-
"uriBaseId": "%SRCROOT%",
277-
"index": 3
286+
"uriBaseId": "%SRCROOT%"
278287
},
279288
"region": {
280289
"startLine": 2281,
@@ -291,8 +300,7 @@ This SARIF output file has example values to show all supported SARIF properties
291300
"physicalLocation": {
292301
"artifactLocation": {
293302
"uri": "src/LiveQueryClient.js",
294-
"uriBaseId": "%SRCROOT%",
295-
"index": 2
303+
"uriBaseId": "%SRCROOT%"
296304
},
297305
"region": {
298306
"startLine": 166
@@ -305,6 +313,7 @@ This SARIF output file has example values to show all supported SARIF properties
305313
]
306314
},
307315
{
316+
"ruleId": "R01",
308317
"message": {
309318
"text": "Specifying both [ruleIndex](1) and [ruleID](2) might lead to inconsistencies."
310319
},
@@ -314,8 +323,7 @@ This SARIF output file has example values to show all supported SARIF properties
314323
"physicalLocation": {
315324
"artifactLocation": {
316325
"uri": "full.sarif",
317-
"uriBaseId": "%SRCROOT%",
318-
"index": 0
326+
"uriBaseId": "%SRCROOT%"
319327
},
320328
"region": {
321329
"startLine": 54,
@@ -409,12 +417,6 @@ This SARIF output file has example values to show all supported SARIF properties
409417
}
410418
}
411419
],
412-
"newlineSequences": [
413-
"\r\n",
414-
"\n",
415-
"",
416-
""
417-
],
418420
"columnKind": "utf16CodeUnits"
419421
}
420422
]

0 commit comments

Comments
 (0)