Skip to content

Commit

Permalink
Add format_context and complete output_format for RPC call to format (#…
Browse files Browse the repository at this point in the history
…310)

This will help SAF-1696

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
  • Loading branch information
Yoann Padioleau authored Nov 6, 2024
1 parent 265f438 commit 1446208
Show file tree
Hide file tree
Showing 7 changed files with 681 additions and 47 deletions.
47 changes: 42 additions & 5 deletions semgrep_output_v1.atd
Original file line number Diff line number Diff line change
Expand Up @@ -1756,6 +1756,10 @@ type ci_env = (string * string) list

(* See src/rpc/README.txt in the Semgrep repository. *)

(* ----------------------------- *)
(* argument call types *)
(* ----------------------------- *)

(* coupling: Textedit.ml *)
type edit
<python decorator="dataclass(frozen=True)"> = {
Expand Down Expand Up @@ -1821,11 +1825,32 @@ type sarif_format_return
format_time_seconds: float;
}

(* TODO: merge with src/osemgrep/reporting/Output_format.ml *)
type output_format = [
| Vim
type output_format
<ocaml attr="deriving show">
<python decorator="dataclass(frozen=True)"> = [
| Text
| Json
| Emacs
]
| Vim
| Sarif
| Gitlab_sast
| Gitlab_secrets
| Junit_xml
(* osemgrep-only *)
| Files_with_matches
(* used to disable the final display of match results because
* we displayed them incrementally instead
*)
| Incremental
] <ocaml repr="classic">

type format_context
<ocaml attr="deriving show">
<python decorator="dataclass(frozen=True)"> = {
is_ci_invocation: bool;
is_logged_in: bool;
is_using_registry: bool;
}

type manifest_kind
<ocaml attr="deriving show, eq, yojson">
Expand Down Expand Up @@ -1891,12 +1916,16 @@ type dump_rule_partitions_params = {
output_dir: fpath;
}

(* ----------------------------- *)
(* The call *)
(* ----------------------------- *)

type function_call
<python decorator="dataclass(frozen=True)"> = [
| CallContributions
| CallApplyFixes of apply_fixes_params
| CallSarifFormat of sarif_format_params
| CallFormatter of (output_format * cli_output)
| CallFormatter of (output_format * format_context * cli_output)
(* NOTE: fpath is most likely a temporary file that contains all the rules in
JSON format. In the future, we could send the rules via a big string through
the RPC pipe.
Expand All @@ -1906,6 +1935,10 @@ type function_call
| CallDumpRulePartitions of dump_rule_partitions_params
]

(* ----------------------------- *)
(* The return *)
(* ----------------------------- *)

type function_return
<python decorator="dataclass(frozen=True)"> = [
| RetError of string
Expand All @@ -1918,6 +1951,10 @@ type function_return
| RetDumpRulePartitions of bool
]

(*****************************************************************************)
(* Misc *)
(*****************************************************************************)

(* ----------------------------- *)
(* Partial scans. Experimental and for internal use only. *)
(* ----------------------------- *)
Expand Down
25 changes: 23 additions & 2 deletions semgrep_output_v1.jsonschema

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion semgrep_output_v1.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1446208

Please sign in to comment.