Skip to content

Commit 7b034f6

Browse files
authored
Make Core_error.location an option (#300)
There are cases where we don't have a location for an error, such as a Fatal error somewhere in semgrep-core. Right now we use Fpath_.is_fake_file for those cases but it's confusing then in the error reports so better to not have any location in those cases 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.17.0. See https://atd.readthedocs.io/en/latest/atdgen-tutorial.html#smooth-protocol-upgrades
1 parent 2bc0e2b commit 7b034f6

7 files changed

+246
-186
lines changed

semgrep_output_v1.atd

+11-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* This file specifies the JSON format of the 'semgrep scan --json' command,
88
* as well as the JSON format of messages sent to the Semgrep backend by the
99
* 'semgrep ci' command, and the format of 'semgrep test --json'.
10-
* For the definition of the Semgrep input, see rule_schema_v2.atd
10+
* For the definition of the Semgrep input (the rules), see rule_schema_v2.atd
1111
*
1212
* This file has the _v1 suffix to explicitely represent the
1313
* version of this JSON format. If you need to extend this file, please
@@ -534,14 +534,16 @@ type incompatible_rule
534534
(* TODO: try to make it as close as possible to 'cli_error' above, possibly
535535
* extending cli_error with more fields (but those fields must be optional
536536
* to remain backward compatible
537+
* LATER: use a proper variant in error_type so we would need less
538+
* of those ?xxx types below (like a ParseError should always have a location)
537539
*)
538540
type core_error <python decorator="dataclass(frozen=True)"> = {
539-
?rule_id: rule_id option;
540541
error_type: error_type;
541542
severity: error_severity;
542-
location: location;
543543
message: string;
544544
?details: string option;
545+
?location: location option;
546+
?rule_id: rule_id option;
545547
}
546548

547549
(* ----------------------------- *)
@@ -563,7 +565,6 @@ type cli_error = {
563565
type_ <json name="type">: error_type;
564566

565567
(* LATER: use a variant instead of all those ?xxx types *)
566-
567568
?rule_id: rule_id option;
568569

569570
(* for most parsing errors those are set *)
@@ -814,7 +815,7 @@ type matching_operation <ocaml attr="deriving show { with_path = false}"> = [
814815

815816
(* TODO: merge with cli_output *)
816817
type core_output = {
817-
?version: version option;
818+
version: version;
818819
results: core_match list;
819820
(* errors are guaranteed to be duplicate free; see also Report.ml *)
820821
errors: core_error list;
@@ -831,8 +832,8 @@ type cli_output = {
831832
(* since: 0.92 *)
832833
?version: version option;
833834

834-
errors: cli_error list;
835835
results: cli_match list;
836+
errors: cli_error list;
836837

837838
inherit cli_output_extra;
838839
}
@@ -1473,8 +1474,10 @@ type engine_configuration = {
14731474
~generic_slow_rollout: bool;
14741475
(* from 1.63.0 *)
14751476
?historical_config: historical_configuration option;
1476-
(* from 1.93 *)
1477-
(* sent by the app to indicate that fail open should always be enabled, overriding the CLI flag. coupling: server/semgrep_app/saas/models/deployment_products_mixin.py *)
1477+
(* from 1.93.
1478+
* Indicate that fail-open should always be enabled, overriding the CLI flag.
1479+
* coupling: server/semgrep_app/saas/models/deployment_products_mixin.py
1480+
*)
14781481
~always_suppress_errors: bool;
14791482
}
14801483

semgrep_output_v1.jsonschema

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

semgrep_output_v1.proto

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

semgrep_output_v1.py

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

semgrep_output_v1.ts

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

0 commit comments

Comments
 (0)