Debian Codegraph @

gcc/testsuite/sarif-replay.dg/2.1.0-valid/spec-example-4.sarif

raw
1 /* Taken from SARIF v2.1.0, Appendix K.4: "Comprehensive SARIF file". */
2
3 {
4 "version": "2.1.0",
5 "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
6 "runs": [
7 {
8 "automationId": {
9 "guid": "BC650830-A9FE-44CB-8818-AD6C387279A0",
10 "id": "Nightly code scan/2018-10-08"
11 },
12 "baselineGuid": "0A106451-C9B1-4309-A7EE-06988B95F723",
13 "runAggregates": [
14 {
15 "id": "Build/14.0.1.2/Release/20160716-13:22:18",
16 "correlationGuid": "26F138B6-6014-4D3D-B174-6E1ACE9439F3"
17 }
18 ],
19 "tool": {
20 "driver": {
21 "name": "CodeScanner",
22 "fullName": "CodeScanner 1.1 for Microsoft Windows (R) (en-US)",
23 "version": "2.1",
24 "semanticVersion": "2.1.0",
25 "dottedQuadFileVersion": "2.1.0.0",
26 "releaseDateUtc": "2019-03-17",
27 "organization": "Example Corporation",
28 "product": "Code Scanner",
29 "productSuite": "Code Quality Tools",
30 "shortDescription": {
31 "text": "A scanner for code."
32 },
33 "fullDescription": {
34 "text": "A really great scanner for all your code."
35 },
36 "properties": {
37 "copyright": "Copyright (c) 2017 by Example Corporation."
38 },
39 "globalMessageStrings": {
40 "variableDeclared": {
41 "text": "Variable \"{0}\" was declared here.",
42 "markdown": " Variable `{0}` was declared here."
43 }
44 },
45 "rules": [
46 {
47 "id": "C2001",
48 "deprecatedIds": [
49 "CA2000"
50 ],
51 "defaultConfiguration": {
52 "level": "error",
53 "rank": 95
54 },
55 "shortDescription": {
56 "text": "A variable was used without being initialized."
57 },
58 "fullDescription": {
59 "text": "A variable was used without being initialized. This can result in runtime errors such as null reference exceptions."
60 },
61 "messageStrings": {
62 "default": {
63 "text": "Variable \"{0}\" was used without being initialized. It was declared [here]({1}).",
64 "markdown": "Variable `{0}` was used without being initialized. It was declared [here]({1})."
65 }
66 }
67 }
68 ],
69 "notifications": [
70 {
71 "id": "start",
72 "shortDescription": {
73 "text": "The run started."
74 },
75 "messageStrings": {
76 "default": {
77 "text": "Run started."
78 }
79 }
80 },
81 {
82 "id": "end",
83 "shortDescription": {
84 "text": "The run ended."
85 },
86 "messageStrings": {
87 "default": {
88 "text": "Run ended."
89 }
90 }
91 }
92 ],
93 "language": "en-US"
94 },
95 "extensions": [
96 {
97 "name": "CodeScanner Security Rules",
98 "version": "3.1",
99 "rules": [
100 {
101 "id": "S0001",
102 "defaultConfiguration": {
103 "level": "error"
104 },
105 "shortDescription": {
106 "text": "Do not use weak cryptographic algorithms."
107 },
108 "messageStrings": {
109 "default": {
110 "text": "The cryptographic algorithm '{0}' should not be used."
111 }
112 }
113 }
114 ]
115 }
116 ]
117 },
118 "language": "en-US",
119 "versionControlProvenance": [
120 {
121 "repositoryUri": "https://github.com/example-corp/browser",
122 "revisionId": "5da53fbb2a0aaa12d648b73984acc9aac2e11c2a",
123 "mappedTo": {
124 "uriBaseId": "PROJECTROOT"
125 }
126 }
127 ],
128 "originalUriBaseIds": {
129 "PROJECTROOT": {
130 "uri": "file://build.example.com/work/"
131 },
132 "SRCROOT": {
133 "uri": " src/",
134 "uriBaseId": "PROJECTROOT"
135 },
136 "BINROOT": {
137 "uri": " bin/",
138 "uriBaseId": "PROJECTROOT"
139 }
140 },
141 "invocations": [
142 {
143 "commandLine": "CodeScanner @build/collections.rsp",
144 "responseFiles": [
145 {
146 "uri": "build/collections.rsp",
147 "uriBaseId": "SRCROOT",
148 "index": 0
149 }
150 ],
151 "startTimeUtc": "2016-07-16T14:18:25Z",
152 "endTimeUtc": "2016-07-16T14:19:01Z",
153 "machine": "BLD01",
154 "account": "buildAgent",
155 "processId": 1218,
156 "fileName": "/bin/tools/CodeScanner",
157 "workingDirectory": {
158 "uri": "file:///home/buildAgent/src"
159 },
160 "environmentVariables": {
161 "PATH": "/usr/local/bin:/bin:/bin/tools:/home/buildAgent/bin",
162 "HOME": "/home/buildAgent",
163 "TZ": "EST"
164 },
165 "toolConfigurationNotifications": [
166 {
167 "descriptor": {
168 "id": "UnknownRule"
169 },
170 "associatedRule": {
171 "ruleId": "ABC0001"
172 },
173 "level": "warning",
174 "message": {
175 "text": "Could not disable rule \"ABC0001\" because there is no rule with that id."
176 }
177 }
178 ],
179 "toolExecutionNotifications": [
180 {
181 "descriptor": {
182 "id": "CTN0001"
183 },
184 "level": "note",
185 "message": {
186 "text": "Run started."
187 }
188 },
189 {
190 "descriptor": {
191 "id": "CTN9999"
192 },
193 "associatedRule": {
194 "id": "C2001",
195 "index": 0
196 },
197 "level": "error",
198 "message": {
199 "text": "Exception evaluating rule \"C2001\". Rule disabled; run continues."
200 },
201 "locations": [
202 {
203 "physicalLocation": {
204 "artifactLocation": {
205 "uri": "crypto/hash.cpp",
206 "uriBaseId": "SRCROOT",
207 "index": 4
208 }
209 }
210 }
211 ],
212 "threadId": 52,
213 "timeUtc": "2016-07-16T14:18:43.119Z",
214 "exception": {
215 "kind": "ExecutionEngine.RuleFailureException",
216 "message": "Unhandled exception during rule evaluation.",
217 "stack": {
218 "frames": [
219 {
220 "location": {
221 "message": {
222 "text": "Exception thrown"
223 },
224 "logicalLocations": [
225 {
226 "fullyQualifiedName":
227 "Rules.SecureHashAlgorithmRule.Evaluate"
228 }
229 ],
230 "physicalLocation": {
231 "address": {
232 "offset": 4244988
233 }
234 }
235 },
236 "module": "RuleLibrary",
237 "threadId": 52
238 },
239 {
240 "location": {
241 "logicalLocations": [
242 {
243 "fullyQualifiedName":
244 "ExecutionEngine.Engine.EvaluateRule"
245 }
246 ],
247 "physicalLocation": {
248 "address": {
249 "offset": 4245514
250 }
251 }
252 },
253 "module": "ExecutionEngine",
254 "threadId": 52
255 }
256 ]
257 },
258 "innerExceptions": [
259 {
260 "kind": "System.ArgumentException",
261 "message": "length is < 0"
262 }
263 ]
264 }
265 },
266 {
267 "descriptor": {
268 "id": "CTN0002"
269 },
270 "level": "note",
271 "message": {
272 "text": "Run ended."
273 }
274 }
275 ],
276 "exitCode": 0,
277 "executionSuccessful": true
278 }
279 ],
280 "artifacts": [
281 {
282 "location": {
283 "uri": "build/collections.rsp",
284 "uriBaseId": "SRCROOT"
285 },
286 "mimeType": "text/plain",
287 "length": 81,
288 "contents": {
289 "text": "-input src/collections/*.cpp -log out/collections.sarif -rules all -disable C9999"
290 }
291 },
292 {
293 "location": {
294 "uri": "application/main.cpp",
295 "uriBaseId": "SRCROOT"
296 },
297 "sourceLanguage": "cplusplus",
298 "length": 1742,
299 "hashes": {
300 "sha-256": "cc8e6a99f3eff00adc649fee132ba80fe333ea5a"
301 }
302 },
303 {
304 "location": {
305 "uri": "collections/list.cpp",
306 "uriBaseId": "SRCROOT"
307 },
308 "sourceLanguage": "cplusplus",
309 "length": 980,
310 "hashes": {
311 "sha-256": "b13ce2678a8807ba0765ab94a0ecd394f869bc81"
312 }
313 },
314 {
315 "location": {
316 "uri": "collections/list.h",
317 "uriBaseId": "SRCROOT"
318 },
319 "sourceLanguage": "cplusplus",
320 "length": 24656,
321 "hashes": {
322 "sha-256": "849be119aaba4e9f88921a99e3036fb6c2a8144a"
323 }
324 },
325 {
326 "location": {
327 "uri": "crypto/hash.cpp",
328 "uriBaseId": "SRCROOT"
329 },
330 "sourceLanguage": "cplusplus",
331 "length": 1424,
332 "hashes": {
333 "sha-256": "3ffe2b77dz255cdf95f97d986d7a6ad8f287eaed"
334 }
335 },
336 {
337 "location": {
338 "uri": "app.zip",
339 "uriBaseId": "BINROOT"
340 },
341 "mimeType": "application/zip",
342 "length": 310450,
343 "hashes": {
344 "sha-256": "df18a5e74b6b46ddaa23ad7271ee2b7c5731cbe1"
345 }
346 },
347 {
348 "location": {
349 "uri": "/docs/intro.docx"
350 },
351 "mimeType":
352 "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
353 "parentIndex": 5,
354 "offset": 17522,
355 "length": 4050
356 }
357 ],
358 "logicalLocations": [
359 {
360 "name": "add",
361 "fullyQualifiedName": "collections::list::add",
362 "decoratedName": "?add@list@collections@@QAEXH@Z",
363 "kind": "function",
364 "parentIndex": 1
365 },
366 {
367 "name": "list",
368 "fullyQualifiedName": "collections::list",
369 "kind": "type",
370 "parentIndex": 2
371 },
372 {
373 "name": "collections",
374 "kind": "namespace"
375 },
376 {
377 "name": "add_core",
378 "fullyQualfiedName": "collections::list::add_core",
379 "decoratedName": "?add_core@list@collections@@QAEXH@Z",
380 "kind": "function",
381 "parentIndex": 1
382 },
383 {
384 "fullyQualifiedName": "main",
385 "kind": "function"
386 }
387 ],
388 "results": [
389 {
390 "ruleId": "C2001",
391 "ruleIndex": 0,
392 "kind": "fail",
393 "level": "error",
394 "message": {
395 "id": "default",
396 "arguments": [
397 "ptr",
398 "0"
399 ]
400 },
401 "suppressions": [
402 {
403 "kind": "external",
404 "status": "accepted"
405 }
406 ],
407 "baselineState": "unchanged",
408 "rank": 95,
409 "analysisTarget": {
410 "uri": "collections/list.cpp",
411 "uriBaseId": "SRCROOT",
412 "index": 2
413 },
414 "locations": [
415 {
416 "physicalLocation": {
417 "artifactLocation": {
418 "uri": "collections/list.h",
419 "uriBaseId": "SRCROOT",
420 "index": 3
421 },
422 "region": {
423 "startLine": 15,
424 "startColumn": 9,
425 "endLine": 15,
426 "endColumn": 10,
427 "charLength": 1,
428 "charOffset": 254,
429 "snippet": {
430 "text": "add_core(ptr, offset, val);\n return;"
431 }
432 }
433 },
434 "logicalLocations": [
435 {
436 "fullyQualifiedName": "collections::list::add",
437 "index": 0
438 }
439 ]
440 }
441 ],
442 "relatedLocations": [
443 {
444 "id": 0,
445 "message": {
446 "id": "variableDeclared",
447 "arguments": [
448 "ptr"
449 ]
450 },
451 "physicalLocation": {
452 "artifactLocation": {
453 "uri": "collections/list.h",
454 "uriBaseId": "SRCROOT",
455 "index": 3
456 },
457 "region": {
458 "startLine": 8,
459 "startColumn": 5
460 }
461 },
462 "logicalLocations": [
463 {
464 "fullyQualifiedName": "collections::list::add",
465 "index": 0
466 }
467 ]
468 }
469 ],
470 "codeFlows": [
471 {
472 "message": {
473 "text": "Path from declaration to usage"
474 },
475
476 "threadFlows": [
477 {
478 "id": "thread-52",
479 "locations": [
480 {
481 "importance": "essential",
482 "location": {
483 "message": {
484 "text": "Variable \"ptr\" declared.",
485 "markdown": "Variable `ptr` declared."
486 },
487 "physicalLocation": {
488 "artifactLocation": {
489 "uri":"collections/list.h",
490 "uriBaseId": "SRCROOT",
491 "index": 3
492 },
493 "region": {
494 "startLine": 15,
495 "snippet": {
496 "text": "int *ptr;"
497 }
498 }
499 },
500 "logicalLocations": [
501 {
502 "fullyQualifiedName": "collections::list::add",
503 "index": 0
504 }
505 ]
506 },
507 "module": "platform"
508 },
509 {
510 "state": {
511 "y": {
512 "text": "2"
513 },
514 "z": {
515 "text": "4"
516 },
517 "y + z": {
518 "text": "6"
519 },
520 "q": {
521 "text": "7"
522 }
523 },
524 "importance": "unimportant",
525 "location": {
526 "physicalLocation": {
527 "artifactLocation": {
528 "uri":"collections/list.h",
529 "uriBaseId": "SRCROOT",
530 "index": 3
531 },
532 "region": {
533 "startLine": 15,
534 "snippet": {
535 "text": "offset = (y + z) * q + 1;"
536 }
537 }
538 },
539 "logicalLocations": [
540 {
541 "fullyQualifiedName": "collections::list::add",
542 "index": 0
543 }
544 ],
545 "annotations": [
546 {
547 "startLine": 15,
548 "startColumn": 13,
549 "endColumn": 19,
550 "message": {
551 "text": "(y + z) = 42",
552 "markdown": "`(y + z) = 42`"
553 }
554 }
555 ]
556 },
557 "module": "platform"
558 },
559 {
560 "importance": "essential",
561 "location": {
562 "message": {
563 "text": "Uninitialized variable \"ptr\" passed to method \"add_core\".",
564 "markdown": "Uninitialized variable `ptr` passed to method `add_core`."
565 },
566 "physicalLocation": {
567 "artifactLocation": {
568 "uri":"collections/list.h",
569 "uriBaseId": "SRCROOT",
570 "index": 3
571 },
572 "region": {
573 "startLine": 25,
574 "snippet": {
575 "text": "add_core(ptr, offset, val)"
576 }
577 }
578 },
579 "logicalLocations": [
580 {
581 "fullyQualifiedName": "collections::list::add",
582 "index": 0
583 }
584 ]
585 },
586 "module": "platform"
587 }
588 ]
589 }
590 ]
591 }
592 ],
593 "stacks": [
594 {
595 "message": {
596 "text": "Call stack resulting from usage of uninitialized variable."
597 },
598 "frames": [
599 {
600 "location": {
601 "message": {
602 "text": "Exception thrown."
603 },
604 "physicalLocation": {
605 "artifactLocation": {
606 "uri": "collections/list.h",
607 "uriBaseId": "SRCROOT",
608 "index": 3
609 },
610 "region": {
611 "startLine": 110,
612 "startColumn": 15
613 },
614 "address": {
615 "offset": 4229178
616 }
617 },
618 "logicalLocations": [
619 {
620 "fullyQualifiedName": "collections::list::add_core",
621 "index": 0
622 }
623 ]
624 },
625 "module": "platform",
626 "threadId": 52,
627 "parameters": [ "null", "0", "14" ]
628 },
629 {
630 "location": {
631 "physicalLocation": {
632 "artifactLocation": {
633 "uri": "collections/list.h",
634 "uriBaseId": "SRCROOT",
635 "index": 3
636 },
637 "region": {
638 "startLine": 43,
639 "startColumn": 15
640 },
641 "address": {
642 "offset": 4229268
643 }
644 },
645 "logicalLocations": [
646 {
647 "fullyQualifiedName": "collections::list::add",
648 "index": 0
649 }
650 ]
651 },
652 "module": "platform",
653 "threadId": 52,
654 "parameters": [ "14" ]
655 },
656 {
657 "location": {
658 "physicalLocation": {
659 "artifactLocation": {
660 "uri": "application/main.cpp",
661 "uriBaseId": "SRCROOT",
662 "index": 1
663 },
664 "region": {
665 "startLine": 28,
666 "startColumn": 9
667 },
668 "address": {
669 "offset": 4229836
670 }
671 },
672 "logicalLocations": [
673 {
674 "fullyQualifiedName": "main",
675 "index": 4
676 }
677 ]
678 },
679 "module": "application",
680 "threadId": 52
681 }
682 ]
683 }
684 ],
685 "addresses": [
686 {
687 "baseAddress": 4194304,
688 "fullyQualifiedName": "collections.dll",
689 "kind": "module",
690 "section": ".text"
691 },
692 {
693 "offset": 100,
694 "fullyQualifiedName": "collections.dll!collections::list::add",
695 "kind": "function",
696 "parentIndex": 0
697 },
698 {
699 "offset": 22,
700 "fullyQualifiedName": "collections.dll!collections::list::add+0x16",
701 "parentIndex": 1
702 }
703 ],
704 "fixes": [
705 {
706 "description": {
707 "text": "Initialize the variable to null"
708 },
709 "artifactChanges": [
710 {
711 "artifactLocation": {
712 "uri": "collections/list.h",
713 "uriBaseId": "SRCROOT",
714 "index": 3
715 },
716 "replacements": [
717 {
718 "deletedRegion": {
719 "startLine": 42
720 },
721 "insertedContent": {
722 "text": "A different line\n"
723 }
724 }
725 ]
726 }
727 ]
728 }
729 ],
730 "hostedViewerUri":
731 "https://www.example.com/viewer/3918d370-c636-40d8-bf23-8c176043a2df",
732 "workItemUris": [
733 "https://github.com/example/project/issues/42",
734 "https://github.com/example/project/issues/54"
735 ],
736 "provenance": {
737 "firstDetectionTimeUtc": "2016-07-15T14:20:42Z",
738 "firstDetectionRunGuid": "8F62D8A0-C14F-4516-9959-1A663BA6FB99",
739 "lastDetectionTimeUtc": "2016-07-16T14:20:42Z",
740 "lastDetectionRunGuid": "BC650830-A9FE-44CB-8818-AD6C387279A0",
741 "invocationIndex": 0
742 }
743 }
744 ]
745 }
746 ]
747 }
748
749 /* { dg-begin-multiline-output "" }
750 In function 'collections::list::add':
751 collections/list.h:15:9: error: Variable "ptr" was used without being initialized. It was declared here. [C2001]
752 'add': events 1-3
753 ......
754 { dg-end-multiline-output "" } */
755 /* { dg-begin-multiline-output "" }
756 collections/list.h:8:5: note: Variable "ptr" was declared here.
757 { dg-end-multiline-output "" } */
758
759 // TODO: what's up with the events?