Skip to content

Commit 41bdd7f

Browse files
authored
Remove semgrep_version from project_metadata and meta from scan_request (#333)
The backend should not use those fields anymore so we can remove them. Note that even if old versions of semgrep are still producing those fields, it is fine because when the backend is consuming the JSON, any unknown field is skipped and those fields should not be used anymore. test plan: see related PR in semgrep - [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.50.0. See https://atd.readthedocs.io/en/latest/atdgen-tutorial.html#smooth-protocol-upgrades Note that the types related to the semgrep-core JSON output or the semgrep-core RPC do not need to be backward compatible! Co-authored-by: pad <[email protected]>
1 parent 147dcde commit 41bdd7f

7 files changed

+141
-258
lines changed

semgrep_output_v1.atd

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ type uuid = string wrap <ocaml module="ATD_string_wrap.Uuidm">
100100
(* RFC 3339 format *)
101101
type datetime = string wrap <ocaml module="ATD_string_wrap.Datetime">
102102

103+
type glob = string
104+
103105
(*****************************************************************************)
104106
(* Versioning *)
105107
(*****************************************************************************)
@@ -494,6 +496,7 @@ type match_intermediate_var <python decorator="dataclass(frozen=True)"> = {
494496
(* both ecosystem and transitivity below have frozen=True so the generated
495497
* classes can be hashed and put in sets (see calls to reachable_deps.add()
496498
* in semgrep SCA code)
499+
* TODO: use <ocaml repr="classic">, and do the same for manifest
497500
*)
498501
type ecosystem
499502
<python decorator="dataclass(frozen=True)">
@@ -595,6 +598,7 @@ type dependency_child <python decorator="dataclass(frozen=True)"> = {
595598
* the validity of a finding. No_validator is currently also used when no
596599
* validation has yet occurred, which if that becomes confusing we
597600
* could adjust that, by adding another state.
601+
* TODO: use <ocaml repr="classic">
598602
*)
599603
type validation_state
600604
<ocaml attr="deriving show, eq">
@@ -948,7 +952,7 @@ type cli_output_extra = {
948952

949953
type config_error_reason = [
950954
| UnparsableRule <json name="unparsable_rule">
951-
]
955+
] <ocaml repr="classic">
952956

953957
type config_error = {
954958
file: fpath;
@@ -1291,8 +1295,6 @@ type engine_configuration = {
12911295
~always_suppress_errors: bool;
12921296
}
12931297

1294-
type glob = string
1295-
12961298
type product_ignored_files = (product * glob list) list
12971299
(* We omit the usual <json repr="object"> otherwise we get a
12981300
* "keys must be strings" error *)
@@ -1319,18 +1321,9 @@ type deployment_response = {
13191321

13201322
(* Sent by the CLI to the POST /api/cli/scans to create a scan. *)
13211323
type scan_request = {
1322-
(* added in 1.43 as options, and mandatory since 1.100.0 (replacing meta) *)
13231324
project_metadata: project_metadata;
13241325
scan_metadata: scan_metadata;
1325-
1326-
(* added in 1.43 *)
13271326
?project_config: ci_config_from_repo option;
1328-
1329-
(* deprecated: moved as an option in 1.100.0 and was duplicative of
1330-
* information in project_metadata and scan_metadata since 1.43.0
1331-
* old: 'meta: project_metadata;' before 1.43
1332-
*)
1333-
?meta: raw_json option;
13341327
}
13351328

13361329
(* Collect information about a project from the environment, filesystem,
@@ -1340,9 +1333,6 @@ type scan_request = {
13401333
* clearer (while still being backward compatible)
13411334
*)
13421335
type project_metadata = {
1343-
(* TODO: deprecate in favor of scan_metadata.cli_version *)
1344-
semgrep_version: version;
1345-
13461336
(* TODO: use enum with <json name="..."> *)
13471337
(* "git" | "github-actions" | "gitlab-ci" | "circleci"
13481338
* "jenkins" | "bitbucket" | "azure-pipelines" | "buildkite" | "travis-ci"
@@ -1657,6 +1647,7 @@ type dependency_parser_error = {
16571647

16581648
(* json names are to maintain backwards compatibility with the python enum it
16591649
* is replacing
1650+
* TODO: use <ocaml repr="classic">
16601651
*)
16611652
type sca_parser_name = [
16621653
| Gemfile_lock <json name="gemfile_lock">
@@ -2015,6 +2006,7 @@ type lockfile_kind
20152006
| ConanLock
20162007
] <ocaml repr="classic">
20172008

2009+
(* TODO: use <ocaml repr="classic"> *)
20182010
type manifest_kind
20192011
<ocaml attr="deriving show, eq">
20202012
<python decorator="dataclass(frozen=True)"> =

semgrep_output_v1.jsonschema

Lines changed: 8 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

semgrep_output_v1.proto

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

semgrep_output_v1.py

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

semgrep_output_v1.ts

Lines changed: 10 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)