-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathsemgrep_output_v1.jsonschema
More file actions
4102 lines (4102 loc) · 161 KB
/
Copy pathsemgrep_output_v1.jsonschema
File metadata and controls
4102 lines (4102 loc) · 161 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "cli_output",
"description": "Translated by atdcat from 'semgrep_output_v1.atd'.\n\nSpecification of the Semgrep CLI JSON output formats using ATD (see https://atd.readthedocs.io/en/latest/ for information on ATD).\n\nThis file specifies mainly the JSON formats of:\n\n- the output of the {{semgrep scan --json}} command\n\n- the output of the {{semgrep test --json}} command\n\n- the messages exchanged with the Semgrep backend by the {{semgrep ci}} command\n\nIt's also (ab)used to specify the JSON input and output of semgrep-core, some RPC between pysemgrep and semgrep-core, and a few more internal things. We should use separate .atd for those different purposes but ATD does not have a proper module system yet and many types are shared so it is simpler for now to have everything in one file.\n\nThere are other important form of outputs which are not specified here:\n\n- The semgrep metrics sent to https://metrics.semgrep.dev in semgrep_metrics.atd\n\n- The parsing stats of semgrep-core -parsing_stats -json have its own Parsing_stats.atd\n\nFor the definition of the Semgrep input (the rules), see rule_schema_v2.atd\n\nThis file has the _v1 suffix to explicitely represent the version of this JSON format. If you need to extend this file, please be careful because you may break consumers of this format (e.g., the Semgrep playground or Semgrep backend or external users of this JSON). See https://atd.readthedocs.io/en/latest/atdgen-tutorial.html#smooth-protocol-upgrades for more information on how to smoothly extend the types in this file.\n\nAny backward incompatible changes should require to upgrade the major version of Semgrep as this JSON output is part of the \"API\" of Semgrep (any incompatible changes to the rule format should also require a major version upgrade). Hopefully, we will always be backward compatible. However, a few fields are tagged with [EXPERIMENTAL] meaning external users should not rely on them as those fields may be changed or removed. They are not part of the \"API\" of Semgrep.\n\nAgain, keep in mind that this file is used both by the CLI to *produce* a JSON output, and by our backends to *consume* the JSON, including to consume the JSON produced by old versions of the CLI. As of Nov 2024, our backend is still supporting as far as Semgrep 1.50.0 released Nov 2023. (see server/semgrep_app/util/cli_version_support.py in the semgrep-app repo)\n\nThis file is translated in OCaml modules by atdgen. Look for the corresponding Semgrep_output_v1_[tj].ml[i] generated files under dune's _build/ folder. A few types below have the 'deriving show' decorator because those types are reused in semgrep core data structures and we make heavy use of 'deriving show' in OCaml to help debug things.\n\nThis file is also translated in Python modules by atdpy. For Python, a few types have the 'dataclass(frozen=True)' decorator so that the class can be hashed and put in set. Indeed, with 'Frozen=True' the class is immutable and dataclass can autogenerate a hash function for it.\n\nFinally this file is translated in jsonschema/openapi spec by atdcat, and in Typescript modules by atdts.\n\nHistory:\n\n- the types in this file were originally inferred from JSON_report.ml for use by spacegrep when it was separate from semgrep-core. It's now also useds in JSON_report.ml (now called Core_json_output.ml)\n\n- it was extended to not only support semgrep-core JSON output but also (py)semgrep CLI output!\n\n- it was then simplified with the osemgrep migration effort by removing gradually the semgrep-core JSON output.\n\n- it was extended to support 'semgrep ci' output to type most messages sent between the Semgrep CLI and the Semgrep backend\n\n- we use this file to specify RPCs between pysemgrep and semgrep-core for the gradual migration effort of osemgrep\n\n- merged what was in Input_to_core.atd here",
"type": "object",
"required": [ "results", "errors", "paths" ],
"properties": {
"version": {
"description": "since: 0.92",
"$ref": "#/definitions/version"
},
"results": {
"type": "array",
"items": { "$ref": "#/definitions/cli_match" }
},
"errors": {
"type": "array",
"items": { "$ref": "#/definitions/cli_error" }
},
"paths": {
"description": "targeting information",
"$ref": "#/definitions/scanned_and_skipped"
},
"time": {
"description": "profiling information",
"$ref": "#/definitions/profile"
},
"explanations": {
"description": "debugging (rule writing) information. Note that as opposed to the dataflow trace, the explanations are not embedded inside a match because we give also explanations when things are not matching. EXPERIMENTAL: since semgrep 0.109",
"type": "array",
"items": { "$ref": "#/definitions/matching_explanation" }
},
"rules_by_engine": {
"description": "These rules, classified by engine used, will let us be transparent in the CLI output over what rules were run with what. EXPERIMENTAL: since: 1.11.0",
"type": "array",
"items": { "$ref": "#/definitions/rule_id_and_engine_kind" }
},
"engine_requested": { "$ref": "#/definitions/engine_kind" },
"interfile_languages_used": {
"description": "Reporting just the requested engine isn't granular enough. We want to know what languages had rules that invoked interfile. This is particularly important for tracking the performance impact of new interfile languages EXPERIMENTAL: since 1.49.0",
"type": "array",
"items": { "type": "string" }
},
"skipped_rules": {
"description": "EXPERIMENTAL: since: 1.37.0",
"type": "array",
"items": { "$ref": "#/definitions/skipped_rule" }
},
"subprojects": {
"description": "SCA subproject resolution results. Note: this is only available when logged in. EXPERIMENTAL: since: 1.125.0",
"type": "array",
"items": { "$ref": "#/definitions/cli_output_subproject_info" }
},
"mcp_scan_results": {
"description": "MCP scan results.",
"$ref": "#/definitions/mcp_scan_results"
},
"profiling_results": {
"description": "How long it took to execute this or that piece of code in semgrep-core",
"type": "array",
"items": { "$ref": "#/definitions/profiling_entry" }
}
},
"definitions": {
"raw_json": { "description": "escape hatch" },
"fpath": { "type": "string" },
"ppath": { "type": "string" },
"fppath": {
"description": "Same as Fppath.t: a nice filesystem path + the path relative to the project root provided for pattern-based filtering purposes.",
"type": "object",
"required": [ "fpath", "ppath" ],
"properties": {
"fpath": { "$ref": "#/definitions/fpath" },
"ppath": { "$ref": "#/definitions/ppath" }
}
},
"uri": { "type": "string" },
"sha1": { "type": "string" },
"uuid": { "type": "string" },
"datetime": { "description": "RFC 3339 format", "type": "string" },
"glob": { "type": "string" },
"version": { "description": "e.g., '1.1.0'", "type": "string" },
"position": {
"description": "Note that there is no filename here like in 'location' below",
"type": "object",
"required": [ "line", "col" ],
"properties": {
"line": { "type": "integer" },
"col": { "type": "integer" },
"offset": {
"description": "Byte position from the beginning of the file, starts at 0. OCaml code sets it correctly. Python code sets it to a dummy value (-1). This uses '~' because pysemgrep < 1.30? was *producing* positions without offset sometimes, and we want the backend to still *consume* such positions. Note that pysemgrep 1.97 was still producing dummy positions without an offset so we might need this ~offset longer than expected?",
"type": "integer"
}
}
},
"location": {
"description": "a.k.a range",
"type": "object",
"required": [ "path", "start", "end" ],
"properties": {
"path": { "$ref": "#/definitions/fpath" },
"start": { "$ref": "#/definitions/position" },
"end": { "$ref": "#/definitions/position" }
}
},
"rule_id": {
"description": "e.g., \"javascript.security.do-not-use-eval\"",
"type": "string"
},
"match_severity": {
"description": "This is used in rules to specify the severity of matches/findings. alt: could be called rule_severity, or finding_severity.\n\n{{{\nError = something wrong that must be fixed\nWarning = something wrong that should be fixed\nInfo = some special condition worth knowing about\nExperiment = deprecated: guess what\nInventory = deprecated: was used for the Code Asset Inventory (CAI) project\n}}}",
"oneOf": [
{ "const": "ERROR" },
{ "const": "WARNING" },
{ "const": "EXPERIMENT" },
{ "const": "INVENTORY" },
{
"description": "since 1.72.0, meant to replace the cases above where Error -> High, Warning -> Medium. Critical/Low are the only really new category here without equivalent before. Experiment and Inventory above should be removed. Info can be kept.",
"const": "CRITICAL"
},
{ "const": "HIGH" },
{ "const": "MEDIUM" },
{ "const": "LOW" },
{
"description": "generic placeholder for non-risky things (including experiments)",
"const": "INFO"
}
]
},
"error_severity": {
"description": "This is used to specify the severity of errors which happened during Semgrep execution (e.g., a parse error).\n\n{{{\nError = Always an error\nWarning = Only an error if \"strict\" is set\nInfo = Nothing may be wrong\n}}}\n\nalt: could reuse match_severity but seems cleaner to define its own type",
"oneOf": [
{ "const": "error" }, { "const": "warn" }, { "const": "info" }
]
},
"pro_feature": {
"description": "Used for a best-effort report to users about what findings they get with the pro engine that they couldn't with the oss engine.\n\n{{{\ninterproc_taint = requires interprocedural taint\ninterfile_taint = requires interfile taint\nproprietary_language = requires some non-taint pro feature\n}}}",
"type": "object",
"required": [
"interproc_taint", "interfile_taint", "proprietary_language"
],
"properties": {
"interproc_taint": { "type": "boolean" },
"interfile_taint": { "type": "boolean" },
"proprietary_language": { "type": "boolean" }
}
},
"engine_of_finding": {
"description": "Report the engine used to detect each finding. Additionally, if we are able to infer that the finding could only be detected using the pro engine, report that the pro engine is required and include basic information about which feature is required.\n\n{{{\nOSS = ran with OSS\nPRO = ran with PRO, but we didn't infer that OSS couldn't have found this\nfinding\nPRO_REQUIRED = ran with PRO and requires a PRO feature (see pro_feature_used)\n}}}\n\nNote: OSS and PRO could have clearer names, but for backwards compatibility we're leaving them as is",
"oneOf": [
{ "const": "OSS" },
{ "const": "PRO" },
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [
{
"description": "Semgrep 1.64.0 or later",
"const": "PRO_REQUIRED"
},
{ "$ref": "#/definitions/pro_feature" }
]
}
]
},
"engine_kind": { "oneOf": [ { "const": "OSS" }, { "const": "PRO" } ] },
"rule_id_and_engine_kind": {
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [
{ "$ref": "#/definitions/rule_id" },
{ "$ref": "#/definitions/engine_kind" }
]
},
"product": {
"oneOf": [
{ "description": "a.k.a. Code", "const": "sast" },
{ "description": "a.k.a. SSC", "const": "sca" },
{ "const": "secrets" }
]
},
"match_based_id": { "description": "e.g. \"ab023_1\"", "type": "string" },
"cli_match": {
"type": "object",
"required": [ "check_id", "path", "start", "end", "extra" ],
"properties": {
"check_id": { "$ref": "#/definitions/rule_id" },
"path": { "$ref": "#/definitions/fpath" },
"start": { "$ref": "#/definitions/position" },
"end": { "$ref": "#/definitions/position" },
"extra": { "$ref": "#/definitions/cli_match_extra" }
}
},
"cli_match_extra": {
"type": "object",
"required": [
"message", "metadata", "severity", "fingerprint", "lines"
],
"properties": {
"metavars": {
"description": "Since 1.98.0, you need to be logged in to get this field. note: we also need ?metavars because dependency_aware code",
"$ref": "#/definitions/metavars"
},
"message": {
"description": "Those fields are derived from the rule but the metavariables they contain have been expanded to their concrete value.",
"type": "string"
},
"fix": {
"description": "If present, semgrep was able to compute a string that should be inserted in place of the text in the matched range in order to fix the finding. Note that this is the result of applying both the fix: or fix_regex: in a rule.",
"type": "string"
},
"fixed_lines": { "type": "array", "items": { "type": "string" } },
"metadata": {
"description": "fields coming from the rule",
"$ref": "#/definitions/raw_json"
},
"severity": { "$ref": "#/definitions/match_severity" },
"fingerprint": {
"description": "Since 1.98.0, you need to be logged in to get those fields",
"type": "string"
},
"lines": { "type": "string" },
"is_ignored": { "description": "for nosemgrep", "type": "boolean" },
"sca_info": {
"description": "EXPERIMENTAL: added by dependency_aware code",
"$ref": "#/definitions/sca_match"
},
"validation_state": {
"description": "EXPERIMENTAL: If present indicates the status of postprocessor validation. This field not being present should be equivalent to No_validator. Added in semgrep 1.37.0",
"$ref": "#/definitions/validation_state"
},
"historical_info": {
"description": "EXPERIMENTAL: added by secrets post-processing & historical scanning code Since 1.60.0.",
"$ref": "#/definitions/historical_info"
},
"dataflow_trace": {
"description": "EXPERIMENTAL: For now, present only for taint findings. May be extended to others later on.",
"$ref": "#/definitions/match_dataflow_trace"
},
"engine_kind": { "$ref": "#/definitions/engine_of_finding" },
"extra_extra": {
"description": "EXPERIMENTAL: see core_match_extra.extra_extra",
"$ref": "#/definitions/raw_json"
}
}
},
"metavars": {
"description": "Name/value map of the matched metavariables. The leading '$' must be included in the metavariable name.",
"type": "object",
"additionalProperties": { "$ref": "#/definitions/metavar_value" }
},
"metavar_value": {
"type": "object",
"required": [ "start", "end", "abstract_content" ],
"properties": {
"start": {
"description": "for certain metavariable like $...ARGS, 'end' may be equal to 'start' to represent an empty metavariable value. The rest of the Python code (message metavariable substitution and autofix) works without change for empty ranges (when end = start).",
"$ref": "#/definitions/position"
},
"end": { "$ref": "#/definitions/position" },
"abstract_content": { "description": "value?", "type": "string" },
"propagated_value": { "$ref": "#/definitions/svalue_value" }
}
},
"svalue_value": {
"type": "object",
"required": [ "svalue_abstract_content" ],
"properties": {
"svalue_start": { "$ref": "#/definitions/position" },
"svalue_end": { "$ref": "#/definitions/position" },
"svalue_abstract_content": {
"description": "value?",
"type": "string"
}
}
},
"matching_explanation": {
"description": "EXPERIMENTAL",
"type": "object",
"required": [ "op", "children", "matches", "loc" ],
"properties": {
"op": { "$ref": "#/definitions/matching_operation" },
"children": {
"type": "array",
"items": { "$ref": "#/definitions/matching_explanation" }
},
"matches": {
"description": "result matches at this node (can be empty when we reach a nomatch)",
"type": "array",
"items": { "$ref": "#/definitions/core_match" }
},
"loc": {
"description": "location in the rule file! not target file. This tries to delimit the part of the rule relevant to the current operation (e.g., the position of the 'patterns:' token in the rule for the And operation).",
"$ref": "#/definitions/location"
},
"extra": {
"description": "NEW: since v1.79",
"$ref": "#/definitions/matching_explanation_extra"
}
}
},
"matching_explanation_extra": {
"description": "For any \"extra\" information that we cannot fit at the node itself. This is useful for kind-specific information, which we cannot put in the operation itself without giving up our ability to derive `show` (needed for `matching_operation` below).",
"type": "object",
"required": [ "before_negation_matches", "before_filter_matches" ],
"properties": {
"before_negation_matches": {
"description": "Only present in And kind. This information is useful for determining the input matches to the first Negation node.",
"oneOf": [
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [
{ "const": "Some" },
{
"type": "array",
"items": { "$ref": "#/definitions/core_match" }
}
]
},
{ "const": "None" }
]
},
"before_filter_matches": {
"description": "Only present in nodes which have children Filter nodes. This information is useful for determining the input matches to the first Filter node, as there is otherwise no way of obtaining the post-intersection matches in an And node, for instance",
"oneOf": [
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [
{ "const": "Some" },
{
"type": "array",
"items": { "$ref": "#/definitions/core_match" }
}
]
},
{ "const": "None" }
]
}
}
},
"matching_operation": {
"description": "Note that this type is used in Matching_explanation.ml hence the need for deriving show below.",
"oneOf": [
{ "const": "And" },
{ "const": "Or" },
{ "const": "Inside" },
{ "const": "Anywhere" },
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [
{
"description": "XPat for eXtended pattern. Can be a spacegrep pattern, a regexp pattern, or a proper semgrep pattern. see semgrep-core/src/core/XPattern.ml",
"const": "XPat"
},
{ "type": "string" }
]
},
{ "const": "Negation" },
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [ { "const": "Filter" }, { "type": "string" } ]
},
{ "const": "Taint" },
{ "const": "TaintSource" },
{ "const": "TaintSink" },
{ "const": "TaintSanitizer" },
{ "const": "EllipsisAndStmts" },
{ "const": "ClassHeaderAndElems" }
]
},
"match_dataflow_trace": {
"type": "object",
"required": [],
"properties": {
"taint_source": { "$ref": "#/definitions/match_call_trace" },
"intermediate_vars": {
"description": "Intermediate variables which are involved in the dataflow. This explains how the taint flows from the source to the sink.",
"type": "array",
"items": { "$ref": "#/definitions/match_intermediate_var" }
},
"taint_sink": { "$ref": "#/definitions/match_call_trace" }
}
},
"loc_and_content": {
"description": "The string attached to the location is the actual code from the file. This can contain sensitive information so be careful!\n\nTODO: the type seems redundant since location already specifies a range. maybe this saves some effort to the user of this type which do not need to read the file to get the content.",
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [
{ "$ref": "#/definitions/location" }, { "type": "string" }
]
},
"match_call_trace": {
"oneOf": [
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [
{ "const": "CliLoc" },
{ "$ref": "#/definitions/loc_and_content" }
]
},
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [
{ "const": "CliCall" },
{
"type": "array",
"minItems": 3,
"items": false,
"prefixItems": [
{ "$ref": "#/definitions/loc_and_content" },
{
"type": "array",
"items": { "$ref": "#/definitions/match_intermediate_var" }
},
{ "$ref": "#/definitions/match_call_trace" }
]
}
]
}
]
},
"match_intermediate_var": {
"description": "This type happens to be mostly the same as a loc_and_content for now, but it's split out because Iago has plans to extend this with more information",
"type": "object",
"required": [ "location", "content" ],
"properties": {
"location": { "$ref": "#/definitions/location" },
"content": {
"description": "Unlike abstract_content, this is the actual text read from the corresponding source file",
"type": "string"
}
}
},
"ecosystem": {
"description": "both ecosystem and transitivity below have frozen=True so the generated classes can be hashed and put in sets (see calls to reachable_deps.add() in semgrep SCA code)\n\nalt: type package_manager",
"oneOf": [
{ "const": "npm" },
{ "const": "pypi" },
{ "const": "gem" },
{ "const": "gomod" },
{ "const": "cargo" },
{ "const": "maven" },
{ "const": "composer" },
{ "const": "nuget" },
{ "const": "pub" },
{ "const": "swiftpm" },
{ "const": "cocoapods" },
{
"description": "Deprecated: Mix is a build system, should use Hex, which is the ecosystem",
"const": "mix"
},
{ "const": "hex" },
{ "const": "opam" }
]
},
"dependency_kind": {
"oneOf": [
{
"description": "we depend directly on the 3rd-party library mentioned in the lockfile (e.g., use of log4j library and concrete calls to log4j in 1st-party code). log4j must be declared as a direct dependency in the manifest file.",
"const": "direct"
},
{
"description": "we depend indirectly (transitively) on the 3rd-party library (e.g., if we use lodash which itself uses internally log4j then lodash is a Direct dependency and log4j a Transitive one)\n\nalt: Indirect",
"const": "transitive"
},
{
"description": "If there is insufficient information to determine the transitivity, such as a requirements.txt file without a requirements.in manifest, we leave it Unknown.",
"const": "unknown"
}
]
},
"sca_match": {
"description": "part of cli_match_extra, core_match_extra, and finding",
"type": "object",
"required": [
"reachability_rule", "sca_finding_schema", "dependency_match",
"reachable"
],
"properties": {
"reachability_rule": {
"description": "does the rule has a pattern part; otherwise it's a \"parity\" or \"upgrade-only\" rule.",
"type": "boolean"
},
"sca_finding_schema": { "type": "integer" },
"dependency_match": { "$ref": "#/definitions/dependency_match" },
"reachable": { "type": "boolean" },
"kind": {
"description": "EXPERIMENTAL since 1.108.0",
"$ref": "#/definitions/sca_match_kind"
}
}
},
"sca_match_kind": {
"description": "Note that in addition to \"reachable\" there are also the notions of \"vulnerable\" and \"exploitable\".",
"oneOf": [
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [
{
"description": "This is used for \"parity\" or \"upgrade-only\" rules. transitivity indicates whether the match is for a direct or transitive usage of the dependency; for a dependency that is both direct and transitive two findings should be generated.",
"const": "LockfileOnlyMatch"
},
{ "$ref": "#/definitions/dependency_kind" }
]
},
{
"description": "found the pattern-part of the SCA rule in 1st-party code (reachable as originally defined by Semgrep Inc.) the match location will be in some target code.",
"const": "DirectReachable"
},
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [
{
"description": "found the pattern-part of the SCA rule in third-party code and ultimately found a path from 1st party code to this vulnerable third-party code. The goal of transitive reachability analysis is to change some Undetermined or (LockfileOnlyMatch Transitive) into TransitiveReachable or TransitiveUnreachable",
"const": "TransitiveReachable"
},
{ "$ref": "#/definitions/transitive_reachable" }
]
},
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [
{
"description": "This is a \"positive\" finding in the sense that semgrep was able to prove that the transitive finding is \"safe\" and can be ignored because either there is no call to the pattern-part of the SCA rule in 3rd party code, or if there is it's in third-party code that is not accessed from the 1st-party code (e.g., via callgraph analysis) Note that there is no need for DirectUnreachable because semgrep would never generate such a finding. We have TransitiveUnreachable because semgrep first generates some Undetermined that we then retag as DirectUnreachable.",
"const": "TransitiveUnreachable"
},
{ "$ref": "#/definitions/transitive_unreachable" }
]
},
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [
{
"description": "could not decide because of the engine limitations (e.g., found the use of a vulnerable library in the lockfile but could not find the pattern in first party code and could not access third-party code for further investigation (similar to (LockfileOnlyMatch Transitive))",
"const": "TransitiveUndetermined"
},
{ "$ref": "#/definitions/transitive_undetermined" }
]
}
]
},
"transitive_reachable": {
"type": "object",
"required": [ "matches", "callgraph_reachable", "explanation" ],
"properties": {
"matches": {
"description": "The matches we found in 3rd party libraries. Ideally the location in cli_match are relative to the root of the project so one can display matches as package@/path/to/finding.py",
"type": "array",
"items": {
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [
{ "$ref": "#/definitions/found_dependency" },
{
"type": "array",
"items": { "$ref": "#/definitions/cli_match" }
}
]
}
},
"callgraph_reachable": {
"description": "LATER: add callgraph information so one can see the path from 1st party code to the vulnerable intermediate 3rd party function. This is set to None for now.",
"oneOf": [
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [ { "const": "Some" }, { "type": "boolean" } ]
},
{ "const": "None" }
]
},
"explanation": {
"description": "some extra explanation that the user can understand",
"oneOf": [
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [ { "const": "Some" }, { "type": "string" } ]
},
{ "const": "None" }
]
}
}
},
"transitive_unreachable": {
"type": "object",
"required": [ "analyzed_packages", "explanation" ],
"properties": {
"analyzed_packages": {
"description": "We didn't find any findings in all the 3rd party libraries that are using the 3rd party vulnerable library. This is a \"proof of work\".",
"type": "array",
"items": { "$ref": "#/definitions/found_dependency" }
},
"explanation": {
"description": "some extra explanation that the user can understand",
"oneOf": [
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [ { "const": "Some" }, { "type": "string" } ]
},
{ "const": "None" }
]
}
}
},
"transitive_undetermined": {
"type": "object",
"required": [ "explanation" ],
"properties": {
"explanation": {
"oneOf": [
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [ { "const": "Some" }, { "type": "string" } ]
},
{ "const": "None" }
]
}
}
},
"dependency_match": {
"type": "object",
"required": [ "dependency_pattern", "found_dependency", "lockfile" ],
"properties": {
"dependency_pattern": { "$ref": "#/definitions/sca_pattern" },
"found_dependency": { "$ref": "#/definitions/found_dependency" },
"lockfile": { "$ref": "#/definitions/fpath" },
"dependency_paths": {
"description": "All known dependency paths by which the matched (transitive) dependency was introduced into the project. Each path is ordered from the direct dependency that introduced it (node 0) to the matched (transitive) dependency (last node). Computed locally from the resolved dependency graph at scan time; only populated when dependency-graph (path-to-transitivity) resolution ran for the ecosystem. Empty/absent for direct dependencies or ecosystems without graph resolution. The number of paths per match is capped. EXPERIMENTAL since 1.166.0",
"type": "array",
"items": { "$ref": "#/definitions/dependency_path" }
}
}
},
"sca_pattern": {
"type": "object",
"required": [ "ecosystem", "package", "semver_range" ],
"properties": {
"ecosystem": { "$ref": "#/definitions/ecosystem" },
"package": { "type": "string" },
"semver_range": { "type": "string" }
}
},
"found_dependency": {
"type": "object",
"required": [
"package", "version", "ecosystem", "allowed_hashes", "transitivity"
],
"properties": {
"package": { "type": "string" },
"version": { "type": "string" },
"ecosystem": { "$ref": "#/definitions/ecosystem" },
"allowed_hashes": {
"description": "???",
"type": "object",
"additionalProperties": {
"type": "array",
"items": { "type": "string" }
}
},
"resolved_url": { "type": "string" },
"transitivity": { "$ref": "#/definitions/dependency_kind" },
"manifest_path": {
"description": "Path to the manifest file that defines the project containing this dependency. Examples: package.json, nested/folder/pom.xml",
"$ref": "#/definitions/fpath"
},
"lockfile_path": {
"description": "Path to the lockfile that contains this dependency. Examples: package-lock.json, nested/folder/requirements.txt, go.mod. Since 1.87.0",
"$ref": "#/definitions/fpath"
},
"line_number": {
"description": "The line number of the dependency in the lockfile. When combined with the lockfile_path, this can identify the location of the dependency in the lockfile.",
"type": "integer"
},
"children": {
"description": "If we have dependency relationship information for this dependency, this field will include the name and version of other found_dependency items that this dependency requires. These fields must match values in `package` and `version` of another `found_dependency` in the same set",
"type": "array",
"items": { "$ref": "#/definitions/dependency_child" }
},
"git_ref": {
"description": "Git ref of the dependency if the dependency comes directly from a git repo. Examples: refs/heads/main, refs/tags/v1.0.0, e5c704df4d308690fed696faf4c86453b4d88a95. Since 1.66.0",
"type": "string"
}
}
},
"dependency_child": {
"type": "object",
"required": [ "package", "version" ],
"properties": {
"package": { "type": "string" },
"version": { "type": "string" }
}
},
"dependency_path": {
"type": "object",
"required": [ "nodes" ],
"properties": {
"nodes": {
"type": "array",
"items": { "$ref": "#/definitions/dependency_child" }
}
}
},
"validation_state": {
"description": "This type is used by postprocessors for secrets to report back the validity of a finding. No_validator is currently also used when no validation has yet occurred, which if that becomes confusing we could adjust that, by adding another state.",
"oneOf": [
{ "const": "CONFIRMED_VALID" },
{ "const": "CONFIRMED_INVALID" },
{ "const": "VALIDATION_ERROR" },
{ "const": "NO_VALIDATOR" }
]
},
"historical_info": {
"description": "part of cli_match_extra",
"type": "object",
"required": [ "git_commit", "git_commit_timestamp" ],
"properties": {
"git_commit": {
"description": "Git commit at which the finding is present. Used by \"historical\" scans, which scan non-HEAD commits in the git history. Relevant for finding, e.g., secrets which are buried in the git history which we wouldn't find at HEAD",
"$ref": "#/definitions/sha1"
},
"git_blob": {
"description": "Git blob at which the finding is present. Sent in addition to the commit since some SCMs have permalinks which use the blob sha, so this information is useful when generating links back to the SCM.",
"$ref": "#/definitions/sha1"
},
"git_commit_timestamp": { "$ref": "#/definitions/datetime" }
}
},
"error_type": {
"oneOf": [
{
"description": "File parsing related errors; coupling: if you add a target parse error then metrics for cli need to be updated. See cli/src/semgrep/parsing_data.py.",
"const": "Lexical error"
},
{ "description": "a.k.a SyntaxError", "const": "Syntax error" },
{ "const": "Other syntax error" },
{ "const": "AST builder error" },
{
"description": "Pattern parsing related errors. There are more precise info about the error in Rule.invalid_rule_error_kind in Rule.ml.",
"const": "Rule parse error"
},
{
"description": "generated in pysemgrep only",
"const": "SemgrepWarning"
},
{ "const": "SemgrepError" },
{ "const": "InvalidRuleSchemaError" },
{ "const": "UnknownLanguageError" },
{ "const": "Invalid YAML" },
{
"description": "internal error, e.g., NoTokenLocation",
"const": "Internal matching error"
},
{ "const": "Semgrep match found" },
{ "const": "Too many matches" },
{
"description": "missing file, OCaml errors, etc.",
"const": "Fatal error"
},
{ "const": "Timeout" },
{ "const": "Out of memory" },
{
"description": "since semgrep 1.132.0",
"const": "Fixpoint timeout"
},
{ "description": "since semgrep 1.86.0", "const": "Stack overflow" },
{ "const": "Timeout during interfile analysis" },
{ "const": "OOM during interfile analysis" },
{ "description": "since semgrep 1.40.0", "const": "Missing plugin" },
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [
{
"description": "the string list is the \"YAML path\" of the pattern, e.g. {{[\"rules\"; \"1\"; ...]}}",
"const": "PatternParseError"
},
{ "type": "array", "items": { "type": "string" } }
]
},
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [
{
"description": "list of skipped tokens. Since semgrep 0.97.",
"const": "PartialParsing"
},
{
"type": "array",
"items": { "$ref": "#/definitions/location" }
}
]
},
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [
{
"description": "since semgrep 1.38.0",
"const": "IncompatibleRule"
},
{ "$ref": "#/definitions/incompatible_rule" }
]
},
{
"description": "Those Xxx0 variants were introduced in semgrep 1.45.0, but actually they are here so that our backend can read the cli_error.type_ from old semgrep versions that were translating the PatternParseError _ and IncompatibleRule _ above as a single string (instead of a list [\"PatternParseError\", ...] now). There is no PartialParsing0 because this was encoded as a ParseError instead.",
"const": "Pattern parse error"
},
{ "const": "Incompatible rule" },
{
"type": "array",
"minItems": 2,
"items": false,
"prefixItems": [
{
"description": "since semgrep 1.94.0",
"const": "DependencyResolutionError"
},
{ "$ref": "#/definitions/resolution_error_kind" }
]
}
]
},
"incompatible_rule": {
"type": "object",
"required": [ "rule_id", "this_version" ],
"properties": {
"rule_id": { "$ref": "#/definitions/rule_id" },
"this_version": { "$ref": "#/definitions/version" },
"min_version": { "$ref": "#/definitions/version" },
"max_version": { "$ref": "#/definitions/version" }
}
},
"cli_error": {
"description": "(called SemgrepError in error.py)",
"type": "object",
"required": [ "code", "level", "type" ],
"properties": {
"code": {
"description": "exit code for the type_ of error",
"type": "integer"
},
"level": { "$ref": "#/definitions/error_severity" },
"type": {
"description": "before 1.45.0 the type below was 'string', but was the result of converting error_type into a string, so using directly 'error_type' below should be mostly backward compatible thx to the <json name> annotations in error_type. To be fully backward compatible, we actually introduced the PatternParseError0 and IncompatibleRule0 cases in error_type.",
"$ref": "#/definitions/error_type"
},
"rule_id": { "$ref": "#/definitions/rule_id" },
"message": {
"description": "contains error location",
"type": "string"
},
"path": { "$ref": "#/definitions/fpath" },
"long_msg": {
"description": "for invalid rules, for ErrorWithSpan",
"type": "string"
},
"short_msg": { "type": "string" },
"spans": {
"type": "array",
"items": { "$ref": "#/definitions/error_span" }
},
"help": { "type": "string" }
}
},
"error_span": {
"type": "object",
"required": [ "file", "start", "end" ],
"properties": {
"file": {
"description": "for InvalidRuleSchemaError",
"$ref": "#/definitions/fpath"
},
"start": { "$ref": "#/definitions/position" },
"end": { "$ref": "#/definitions/position" },
"source_hash": { "type": "string" },
"config_start": {
"description": "The path to the pattern in the yaml rule and an adjusted start/end within just the pattern. Used to report playground parse errors in the simple editor",
"$ref": "#/definitions/position"
},
"config_end": { "$ref": "#/definitions/position" },
"config_path": {
"type": [ "array", "null" ],
"items": { "type": "string" }
},
"context_start": { "$ref": "#/definitions/position" },
"context_end": { "$ref": "#/definitions/position" }
}
},
"skip_reason": {
"description": "A reason for skipping a target file or a pair (target, rule). Note that this type is also used in Report.ml hence the need for deriving show here.\n\nFor consistency, please make sure all the JSON constructors use the same case rules (lowercase, underscores). This is hard to fix later! Please review your code carefully before committing to interface changes.",
"oneOf": [
{ "const": "always_skipped" },
{ "const": "semgrepignore_patterns_match" },
{ "const": "cli_include_flags_do_not_match" },
{ "const": "cli_exclude_flags_match" },
{ "const": "exceeded_size_limit" },
{ "const": "analysis_failed_parser_or_internal_error" },
{ "const": "excluded_by_config" },
{ "const": "wrong_language" },
{ "const": "too_big" },
{ "const": "minified" },
{ "const": "binary" },
{ "const": "irrelevant_rule" },
{ "const": "too_many_matches" },
{ "const": "Gitignore_patterns_match" },
{
"description": "since 1.40.0. They were always ignored, but not shown in the skip report",
"const": "Dotfile"
},
{ "description": "since 1.44.0", "const": "Nonexistent_file" },
{
"description": "since 1.94.0",
"const": "insufficient_permissions"
}
]
},
"skipped_target": {
"description": "coupling: ugly: with yield_json_objects() in target_manager.py",
"type": "object",
"required": [ "path", "reason" ],
"properties": {
"path": { "$ref": "#/definitions/fpath" },
"reason": { "$ref": "#/definitions/skip_reason" },
"details": {
"description": "since semgrep 1.39.0 (used to be return only by semgrep-core)",
"type": "string"
},
"rule_id": {
"description": "If the 'rule_id' field is missing, the target is assumed to have been skipped for all the rules",
"$ref": "#/definitions/rule_id"
}
}
},
"scanned_and_skipped": {
"type": "object",
"required": [ "scanned" ],
"properties": {
"scanned": {
"type": "array",
"items": { "$ref": "#/definitions/fpath" }
},
"skipped": {
"type": "array",
"items": { "$ref": "#/definitions/skipped_target" }
}
}
},
"skipped_rule": {
"type": "object",
"required": [ "rule_id", "details", "position" ],
"properties": {
"rule_id": { "$ref": "#/definitions/rule_id" },
"details": { "type": "string" },
"position": {
"description": "position of the error in the rule file",
"$ref": "#/definitions/position"
}
}
},
"target_discovery_result": {
"description": "Result of get_targets internal RPC, similar to scanned_and_skipped but more complete",
"type": "object",
"required": [ "target_paths", "errors", "skipped" ],
"properties": {
"target_paths": {