Skip to content

Commit 13fe14d

Browse files
authored
Add an engine flavor type to report findings that can only come from pro (#226)
- [x] I ran `make setup && make` to update the generated code after editing a `.atd` file (TODO: have a CI check) - [x] I made sure we're still backward compatible with old versions of the CLI. For example, the Semgrep backend need to still be able to *consume* data generated by Semgrep 1.17.0. See https://atd.readthedocs.io/en/latest/atdgen-tutorial.html#smooth-protocol-upgrades
1 parent 9845c86 commit 13fe14d

7 files changed

+816
-161
lines changed

semgrep_output_v1.atd

+37-4
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,44 @@ type error_severity
165165
| Info <json name="info">
166166
]
167167

168-
(* TODO? PRO can actually have "flavors" (see Engine_type.ml) *)
168+
(* Used for a best-effort report to users about what findings they get with
169+
the pro engine that they couldn't with the oss engine.
170+
171+
Interproc_taint = requires interprocedural taint
172+
Interfile_taint = requires interfile taint
173+
Other_pro_feature = requires some non-taint pro feature *)
174+
type pro_feature
175+
<ocaml attr="deriving show">
176+
<python decorator="dataclass(frozen=True)"> = {
177+
interproc_taint: bool;
178+
interfile_taint: bool;
179+
proprietary_language: bool;
180+
}
181+
182+
(* Report the engine used to detect each finding. Additionally, if we are able to
183+
infer that the finding could only be detected using the pro engine, report that
184+
the pro engine is required and include basic information about which feature is
185+
required.
186+
187+
OSS = ran with OSS
188+
PRO = ran with PRO, but we didn't infer that OSS couldn't have found this finding
189+
PRO_REQUIRED = ran with PRO and requires a PRO feature (see pro_feature_used)
190+
191+
Note: OSS and PRO could have clearer names, but for backwards compatibility
192+
we're leaving them as is *)
193+
type engine_of_finding
194+
<ocaml attr="deriving show">
195+
<python decorator="dataclass(frozen=True)"> = [
196+
| OSS
197+
| PRO
198+
(* Semgrep 1.64.0 or later *)
199+
| PRO_REQUIRED of pro_feature
200+
]
201+
169202
type engine_kind
170203
<ocaml attr="deriving show">
171204
<python decorator="dataclass(frozen=True)"> = [
172-
| OSS
205+
| OSS
173206
| PRO
174207
]
175208

@@ -233,7 +266,7 @@ type core_match_extra <python decorator="dataclass(frozen=True)"> = {
233266
?fix: string option;
234267

235268
?dataflow_trace: match_dataflow_trace option;
236-
engine_kind: engine_kind;
269+
engine_kind: engine_of_finding;
237270
(* for nosemgrep *)
238271
is_ignored: bool;
239272
(* If present indicates the status of postprocessor validation. This field
@@ -298,7 +331,7 @@ type cli_match_extra = {
298331
* later on. *)
299332
?dataflow_trace: match_dataflow_trace option;
300333

301-
?engine_kind: engine_kind option;
334+
?engine_kind: engine_of_finding option;
302335

303336
(* EXPERIMENTAL: If present indicates the status of postprocessor validation. This
304337
* field not being present should be equivalent to No_validator.

semgrep_output_v1.jsonschema

+28-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

semgrep_output_v1.proto

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)