Skip to content

Commit 1446208

Browse files
authored
Add format_context and complete output_format for RPC call to format (#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
1 parent 265f438 commit 1446208

7 files changed

+681
-47
lines changed

semgrep_output_v1.atd

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,6 +1756,10 @@ type ci_env = (string * string) list
17561756

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

1759+
(* ----------------------------- *)
1760+
(* argument call types *)
1761+
(* ----------------------------- *)
1762+
17591763
(* coupling: Textedit.ml *)
17601764
type edit
17611765
<python decorator="dataclass(frozen=True)"> = {
@@ -1821,11 +1825,32 @@ type sarif_format_return
18211825
format_time_seconds: float;
18221826
}
18231827

1824-
(* TODO: merge with src/osemgrep/reporting/Output_format.ml *)
1825-
type output_format = [
1826-
| Vim
1828+
type output_format
1829+
<ocaml attr="deriving show">
1830+
<python decorator="dataclass(frozen=True)"> = [
1831+
| Text
1832+
| Json
18271833
| Emacs
1828-
]
1834+
| Vim
1835+
| Sarif
1836+
| Gitlab_sast
1837+
| Gitlab_secrets
1838+
| Junit_xml
1839+
(* osemgrep-only *)
1840+
| Files_with_matches
1841+
(* used to disable the final display of match results because
1842+
* we displayed them incrementally instead
1843+
*)
1844+
| Incremental
1845+
] <ocaml repr="classic">
1846+
1847+
type format_context
1848+
<ocaml attr="deriving show">
1849+
<python decorator="dataclass(frozen=True)"> = {
1850+
is_ci_invocation: bool;
1851+
is_logged_in: bool;
1852+
is_using_registry: bool;
1853+
}
18291854

18301855
type manifest_kind
18311856
<ocaml attr="deriving show, eq, yojson">
@@ -1891,12 +1916,16 @@ type dump_rule_partitions_params = {
18911916
output_dir: fpath;
18921917
}
18931918

1919+
(* ----------------------------- *)
1920+
(* The call *)
1921+
(* ----------------------------- *)
1922+
18941923
type function_call
18951924
<python decorator="dataclass(frozen=True)"> = [
18961925
| CallContributions
18971926
| CallApplyFixes of apply_fixes_params
18981927
| CallSarifFormat of sarif_format_params
1899-
| CallFormatter of (output_format * cli_output)
1928+
| CallFormatter of (output_format * format_context * cli_output)
19001929
(* NOTE: fpath is most likely a temporary file that contains all the rules in
19011930
JSON format. In the future, we could send the rules via a big string through
19021931
the RPC pipe.
@@ -1906,6 +1935,10 @@ type function_call
19061935
| CallDumpRulePartitions of dump_rule_partitions_params
19071936
]
19081937

1938+
(* ----------------------------- *)
1939+
(* The return *)
1940+
(* ----------------------------- *)
1941+
19091942
type function_return
19101943
<python decorator="dataclass(frozen=True)"> = [
19111944
| RetError of string
@@ -1918,6 +1951,10 @@ type function_return
19181951
| RetDumpRulePartitions of bool
19191952
]
19201953

1954+
(*****************************************************************************)
1955+
(* Misc *)
1956+
(*****************************************************************************)
1957+
19211958
(* ----------------------------- *)
19221959
(* Partial scans. Experimental and for internal use only. *)
19231960
(* ----------------------------- *)

semgrep_output_v1.jsonschema

Lines changed: 23 additions & 2 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: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)