diff --git a/semgrep_output_v1.atd b/semgrep_output_v1.atd index bfbcc2f3..d5747141 100644 --- a/semgrep_output_v1.atd +++ b/semgrep_output_v1.atd @@ -833,7 +833,8 @@ type skipped_rule = { (* coupling: with semgrep_metrics.atd performance section *) (* coupling: if you change the JSON schema below, you probably need to - * also modify perf/run-benchmarks. Run locally $ ./run-benchmarks --dummy --upload + * also modify perf/run-benchmarks. + * Run locally $ ./run-benchmarks --dummy --upload *) type profile = { (* List of rules, including the one read but not run on any target. @@ -1359,12 +1360,18 @@ type scan_metadata = { (* Sent by the CLI to the POST /api/cli/scans to create a scan. *) type scan_request = { - (* until 1.43ish, was 'meta: project_metadata;' before *) - meta: raw_json; - (* from 1.43 *) - ?project_metadata: project_metadata option; (* replacing meta *) + (* added in 1.43 as options, and mandatory since 1.100.0 (replacing meta) *) + project_metadata: project_metadata; + scan_metadata: scan_metadata; + + (* added in 1.43 *) ?project_config: ci_config_from_repo option; - ?scan_metadata: scan_metadata option; + + (* deprecated: moved as an option in 1.100.0 and was duplicative of + * information in project_metadata and scan_metadata since 1.43.0 + * old: 'meta: project_metadata;' before 1.43 + *) + ?meta: raw_json option; } (* Response from the backend to the CLI to the POST /api/cli/scans *) @@ -1942,7 +1949,6 @@ type apply_fixes_return = { fixed_lines: (int * string list) list; } -(* The parameters here pretty much match what's needed by Sarif_output.sarif_output. *) type sarif_format_params = { hide_nudge: bool; engine_label: string; diff --git a/semgrep_output_v1.jsonschema b/semgrep_output_v1.jsonschema index 14d2c445..2b2f044a 100644 --- a/semgrep_output_v1.jsonschema +++ b/semgrep_output_v1.jsonschema @@ -1016,12 +1016,12 @@ }, "scan_request": { "type": "object", - "required": [ "meta" ], + "required": [ "project_metadata", "scan_metadata" ], "properties": { - "meta": { "$ref": "#/definitions/raw_json" }, "project_metadata": { "$ref": "#/definitions/project_metadata" }, + "scan_metadata": { "$ref": "#/definitions/scan_metadata" }, "project_config": { "$ref": "#/definitions/ci_config_from_repo" }, - "scan_metadata": { "$ref": "#/definitions/scan_metadata" } + "meta": { "$ref": "#/definitions/raw_json" } } }, "scan_response": { diff --git a/semgrep_output_v1.proto b/semgrep_output_v1.proto index 0f3f54b9..858051ce 100644 --- a/semgrep_output_v1.proto +++ b/semgrep_output_v1.proto @@ -1,6 +1,6 @@ // Generated by jsonschema2protobuf. DO NOT EDIT! // Source file: semgrep_output_v1.jsonschema -// Source file sha256 digest: 4259e2f9442c5d9ad81fe249f4ce630798fc9c008f2e6aab66329e21f4acd264 +// Source file sha256 digest: 3c5ed14031f0dd72ed2f739c26ab80f76a94337b5caa1da7e9a04d0facae95da syntax = "proto3"; @@ -383,10 +383,10 @@ message ScanMetadata { } message ScanRequest { - google.protobuf.Any meta = 3004443; ProjectMetadata project_metadata = 24255885; - CiConfigFromRepo project_config = 317758767; ScanMetadata scan_metadata = 76122041; + CiConfigFromRepo project_config = 317758767; + google.protobuf.Any meta = 3004443; } message ScanResponse { diff --git a/semgrep_output_v1.py b/semgrep_output_v1.py index f9339b9c..f44382fb 100644 --- a/semgrep_output_v1.py +++ b/semgrep_output_v1.py @@ -4923,32 +4923,31 @@ def to_json_string(self, **kw: Any) -> str: class ScanRequest: """Original type: scan_request = { ... }""" - meta: RawJson - project_metadata: Optional[ProjectMetadata] = None + project_metadata: ProjectMetadata + scan_metadata: ScanMetadata project_config: Optional[CiConfigFromRepo] = None - scan_metadata: Optional[ScanMetadata] = None + meta: Optional[RawJson] = None @classmethod def from_json(cls, x: Any) -> 'ScanRequest': if isinstance(x, dict): return cls( - meta=RawJson.from_json(x['meta']) if 'meta' in x else _atd_missing_json_field('ScanRequest', 'meta'), - project_metadata=ProjectMetadata.from_json(x['project_metadata']) if 'project_metadata' in x else None, + project_metadata=ProjectMetadata.from_json(x['project_metadata']) if 'project_metadata' in x else _atd_missing_json_field('ScanRequest', 'project_metadata'), + scan_metadata=ScanMetadata.from_json(x['scan_metadata']) if 'scan_metadata' in x else _atd_missing_json_field('ScanRequest', 'scan_metadata'), project_config=CiConfigFromRepo.from_json(x['project_config']) if 'project_config' in x else None, - scan_metadata=ScanMetadata.from_json(x['scan_metadata']) if 'scan_metadata' in x else None, + meta=RawJson.from_json(x['meta']) if 'meta' in x else None, ) else: _atd_bad_json('ScanRequest', x) def to_json(self) -> Any: res: Dict[str, Any] = {} - res['meta'] = (lambda x: x.to_json())(self.meta) - if self.project_metadata is not None: - res['project_metadata'] = (lambda x: x.to_json())(self.project_metadata) + res['project_metadata'] = (lambda x: x.to_json())(self.project_metadata) + res['scan_metadata'] = (lambda x: x.to_json())(self.scan_metadata) if self.project_config is not None: res['project_config'] = (lambda x: x.to_json())(self.project_config) - if self.scan_metadata is not None: - res['scan_metadata'] = (lambda x: x.to_json())(self.scan_metadata) + if self.meta is not None: + res['meta'] = (lambda x: x.to_json())(self.meta) return res @classmethod diff --git a/semgrep_output_v1.ts b/semgrep_output_v1.ts index 5aa73447..a9dc9115 100644 --- a/semgrep_output_v1.ts +++ b/semgrep_output_v1.ts @@ -560,10 +560,10 @@ export type ScanMetadata = { } export type ScanRequest = { - meta: RawJson; - project_metadata?: ProjectMetadata; + project_metadata: ProjectMetadata; + scan_metadata: ScanMetadata; project_config?: CiConfigFromRepo; - scan_metadata?: ScanMetadata; + meta?: RawJson; } export type ScanResponse = { @@ -2767,19 +2767,19 @@ export function readScanMetadata(x: any, context: any = x): ScanMetadata { export function writeScanRequest(x: ScanRequest, context: any = x): any { return { - 'meta': _atd_write_required_field('ScanRequest', 'meta', writeRawJson, x.meta, x), - 'project_metadata': _atd_write_optional_field(writeProjectMetadata, x.project_metadata, x), + 'project_metadata': _atd_write_required_field('ScanRequest', 'project_metadata', writeProjectMetadata, x.project_metadata, x), + 'scan_metadata': _atd_write_required_field('ScanRequest', 'scan_metadata', writeScanMetadata, x.scan_metadata, x), 'project_config': _atd_write_optional_field(writeCiConfigFromRepo, x.project_config, x), - 'scan_metadata': _atd_write_optional_field(writeScanMetadata, x.scan_metadata, x), + 'meta': _atd_write_optional_field(writeRawJson, x.meta, x), }; } export function readScanRequest(x: any, context: any = x): ScanRequest { return { - meta: _atd_read_required_field('ScanRequest', 'meta', readRawJson, x['meta'], x), - project_metadata: _atd_read_optional_field(readProjectMetadata, x['project_metadata'], x), + project_metadata: _atd_read_required_field('ScanRequest', 'project_metadata', readProjectMetadata, x['project_metadata'], x), + scan_metadata: _atd_read_required_field('ScanRequest', 'scan_metadata', readScanMetadata, x['scan_metadata'], x), project_config: _atd_read_optional_field(readCiConfigFromRepo, x['project_config'], x), - scan_metadata: _atd_read_optional_field(readScanMetadata, x['scan_metadata'], x), + meta: _atd_read_optional_field(readRawJson, x['meta'], x), }; } diff --git a/semgrep_output_v1_j.ml b/semgrep_output_v1_j.ml index aa29803d..3a80b162 100644 --- a/semgrep_output_v1_j.ml +++ b/semgrep_output_v1_j.ml @@ -404,10 +404,10 @@ type ci_config_from_repo = Semgrep_output_v1_t.ci_config_from_repo = { } type scan_request = Semgrep_output_v1_t.scan_request = { - meta: raw_json; - project_metadata: project_metadata option; + project_metadata: project_metadata; + scan_metadata: scan_metadata; project_config: ci_config_from_repo option; - scan_metadata: scan_metadata option + meta: raw_json option } type ci_env = Semgrep_output_v1_t.ci_env @@ -15154,120 +15154,6 @@ let read_ci_config_from_repo = ( ) let ci_config_from_repo_of_string s = read_ci_config_from_repo (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__scan_metadata_option = ( - Atdgen_runtime.Oj_run.write_std_option ( - write_scan_metadata - ) -) -let string_of__scan_metadata_option ?(len = 1024) x = - let ob = Buffer.create len in - write__scan_metadata_option ob x; - Buffer.contents ob -let read__scan_metadata_option = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read_scan_metadata - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_scan_metadata - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _scan_metadata_option_of_string s = - read__scan_metadata_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__project_metadata_option = ( - Atdgen_runtime.Oj_run.write_std_option ( - write_project_metadata - ) -) -let string_of__project_metadata_option ?(len = 1024) x = - let ob = Buffer.create len in - write__project_metadata_option ob x; - Buffer.contents ob -let read__project_metadata_option = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read_project_metadata - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_project_metadata - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _project_metadata_option_of_string s = - read__project_metadata_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__ci_config_from_repo_option = ( Atdgen_runtime.Oj_run.write_std_option ( write_ci_config_from_repo @@ -15333,22 +15219,20 @@ let write_scan_request : _ -> scan_request -> _ = ( is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"meta\":"; + Buffer.add_string ob "\"project_metadata\":"; ( - write_raw_json + write_project_metadata ) - ob x.meta; - (match x.project_metadata with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"project_metadata\":"; - ( - write_project_metadata - ) - ob x; - ); + ob x.project_metadata; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"scan_metadata\":"; + ( + write_scan_metadata + ) + ob x.scan_metadata; (match x.project_config with None -> () | Some x -> if !is_first then is_first := false @@ -15360,14 +15244,14 @@ let write_scan_request : _ -> scan_request -> _ = ( ) ob x; ); - (match x.scan_metadata with None -> () | Some x -> + (match x.meta with None -> () | Some x -> if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"scan_metadata\":"; + Buffer.add_string ob "\"meta\":"; ( - write_scan_metadata + write_raw_json ) ob x; ); @@ -15381,10 +15265,10 @@ let read_scan_request = ( fun p lb -> Yojson.Safe.read_space p lb; Yojson.Safe.read_lcurl p lb; - let field_meta = ref (None) in let field_project_metadata = ref (None) in - let field_project_config = ref (None) in let field_scan_metadata = ref (None) in + let field_project_config = ref (None) in + let field_meta = ref (None) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; @@ -15396,7 +15280,7 @@ let read_scan_request = ( match len with | 4 -> ( if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' then ( - 0 + 3 ) else ( -1 @@ -15404,7 +15288,7 @@ let read_scan_request = ( ) | 13 -> ( if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'c' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'm' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'd' && String.unsafe_get s (pos+10) = 'a' && String.unsafe_get s (pos+11) = 't' && String.unsafe_get s (pos+12) = 'a' then ( - 3 + 1 ) else ( -1 @@ -15420,7 +15304,7 @@ let read_scan_request = ( ) | 16 -> ( if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'j' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'm' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 't' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 'd' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'a' then ( - 1 + 0 ) else ( -1 @@ -15435,23 +15319,21 @@ let read_scan_request = ( ( match i with | 0 -> - field_meta := ( + field_project_metadata := ( Some ( ( - read_raw_json + read_project_metadata ) p lb ) ); | 1 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_project_metadata := ( - Some ( - ( - read_project_metadata - ) p lb - ) - ); - ) + field_scan_metadata := ( + Some ( + ( + read_scan_metadata + ) p lb + ) + ); | 2 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_project_config := ( @@ -15464,10 +15346,10 @@ let read_scan_request = ( ) | 3 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_scan_metadata := ( + field_meta := ( Some ( ( - read_scan_metadata + read_raw_json ) p lb ) ); @@ -15487,7 +15369,7 @@ let read_scan_request = ( match len with | 4 -> ( if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' then ( - 0 + 3 ) else ( -1 @@ -15495,7 +15377,7 @@ let read_scan_request = ( ) | 13 -> ( if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'c' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'm' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'd' && String.unsafe_get s (pos+10) = 'a' && String.unsafe_get s (pos+11) = 't' && String.unsafe_get s (pos+12) = 'a' then ( - 3 + 1 ) else ( -1 @@ -15511,7 +15393,7 @@ let read_scan_request = ( ) | 16 -> ( if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'j' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'm' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 't' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 'd' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'a' then ( - 1 + 0 ) else ( -1 @@ -15526,23 +15408,21 @@ let read_scan_request = ( ( match i with | 0 -> - field_meta := ( + field_project_metadata := ( Some ( ( - read_raw_json + read_project_metadata ) p lb ) ); | 1 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_project_metadata := ( - Some ( - ( - read_project_metadata - ) p lb - ) - ); - ) + field_scan_metadata := ( + Some ( + ( + read_scan_metadata + ) p lb + ) + ); | 2 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_project_config := ( @@ -15555,10 +15435,10 @@ let read_scan_request = ( ) | 3 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_scan_metadata := ( + field_meta := ( Some ( ( - read_scan_metadata + read_raw_json ) p lb ) ); @@ -15572,10 +15452,10 @@ let read_scan_request = ( with Yojson.End_of_object -> ( ( { - meta = (match !field_meta with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "meta"); - project_metadata = !field_project_metadata; + project_metadata = (match !field_project_metadata with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "project_metadata"); + scan_metadata = (match !field_scan_metadata with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "scan_metadata"); project_config = !field_project_config; - scan_metadata = !field_scan_metadata; + meta = !field_meta; } : scan_request) ) diff --git a/semgrep_output_v1_j.mli b/semgrep_output_v1_j.mli index 368c0e2d..e3ed8187 100644 --- a/semgrep_output_v1_j.mli +++ b/semgrep_output_v1_j.mli @@ -404,10 +404,10 @@ type ci_config_from_repo = Semgrep_output_v1_t.ci_config_from_repo = { } type scan_request = Semgrep_output_v1_t.scan_request = { - meta: raw_json; - project_metadata: project_metadata option; + project_metadata: project_metadata; + scan_metadata: scan_metadata; project_config: ci_config_from_repo option; - scan_metadata: scan_metadata option + meta: raw_json option } type ci_env = Semgrep_output_v1_t.ci_env