diff --git a/semgrep_output_v1.atd b/semgrep_output_v1.atd index 25bae594..1488a5b0 100644 --- a/semgrep_output_v1.atd +++ b/semgrep_output_v1.atd @@ -1937,32 +1937,24 @@ type apply_fixes_return = { fixed_lines: (int * string list) list; } +(* TODO: remove many fields so that CallSarifFormat gets close to CallFormatter. + * I think we just need the 'rules: fpath' as it can't be reconstructed + * from cli_output. + *) type sarif_format_params = { - hide_nudge: bool; - engine_label: string; - (* Path the the rules file *) rules: fpath; - (* Semgrep-core matches along with their match based ids, - * which are needed here because the ocaml implementation - * of fingerprints currently doesn't match python yet. - *) + (* TODO: remove, just use cli_output *) cli_matches: cli_match list; - - (* We use cli_error instead of core_error because it has - * extra info from the python side that cannot be fully - * recovered cleanly on the ocaml side just by the available - * info in core_error. - *) cli_errors: cli_error list; - - (* This field was added later and had to be optional to make it - * backward-compatible and pass PR checks. - *) - ?show_dataflow_traces: bool option; + (* TODO: remove, should be able to derive those from format_context *) + hide_nudge: bool; + engine_label: string; + show_dataflow_traces: bool; } +(* TODO: remove, reuse RetFormatter *) type sarif_format_return = { (* The formatted output. *) output: string; @@ -2151,7 +2143,8 @@ type resolution_result = [ type function_call = [ | CallContributions | CallApplyFixes of apply_fixes_params - | CallSarifFormat of sarif_format_params + (* TODO: merge with CallFormatter at some point *) + | CallSarifFormat of (format_context * sarif_format_params) | 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 @@ -2169,8 +2162,9 @@ type function_call = [ type function_return = [ | RetError of string | RetApplyFixes of apply_fixes_return - | RetSarifFormat of sarif_format_return | RetContributions of contributions + (* TODO: remove and use RetFormatter for the return of CallSarifFormat too *) + | RetSarifFormat of sarif_format_return | RetFormatter of string | RetValidate of bool | RetResolveDependencies of (dependency_source * resolution_result) list diff --git a/semgrep_output_v1.jsonschema b/semgrep_output_v1.jsonschema index 6d445d21..949665fd 100644 --- a/semgrep_output_v1.jsonschema +++ b/semgrep_output_v1.jsonschema @@ -1609,11 +1609,10 @@ "sarif_format_params": { "type": "object", "required": [ - "hide_nudge", "engine_label", "rules", "cli_matches", "cli_errors" + "rules", "cli_matches", "cli_errors", "hide_nudge", "engine_label", + "show_dataflow_traces" ], "properties": { - "hide_nudge": { "type": "boolean" }, - "engine_label": { "type": "string" }, "rules": { "$ref": "#/definitions/fpath" }, "cli_matches": { "type": "array", @@ -1623,6 +1622,8 @@ "type": "array", "items": { "$ref": "#/definitions/cli_error" } }, + "hide_nudge": { "type": "boolean" }, + "engine_label": { "type": "string" }, "show_dataflow_traces": { "type": "boolean" } } }, @@ -1860,7 +1861,15 @@ "items": false, "prefixItems": [ { "const": "CallSarifFormat" }, - { "$ref": "#/definitions/sarif_format_params" } + { + "type": "array", + "minItems": 2, + "items": false, + "prefixItems": [ + { "$ref": "#/definitions/format_context" }, + { "$ref": "#/definitions/sarif_format_params" } + ] + } ] }, { @@ -1934,8 +1943,8 @@ "minItems": 2, "items": false, "prefixItems": [ - { "const": "RetSarifFormat" }, - { "$ref": "#/definitions/sarif_format_return" } + { "const": "RetContributions" }, + { "$ref": "#/definitions/contributions" } ] }, { @@ -1943,8 +1952,8 @@ "minItems": 2, "items": false, "prefixItems": [ - { "const": "RetContributions" }, - { "$ref": "#/definitions/contributions" } + { "const": "RetSarifFormat" }, + { "$ref": "#/definitions/sarif_format_return" } ] }, { diff --git a/semgrep_output_v1.proto b/semgrep_output_v1.proto index d34e6165..1ba7d24c 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: 4fa61427814c36f7c021950234accc23d354b50d13f0300152d244cf6bb87aaa +// Source file sha256 digest: a481d8b00723625c34818da9a0986f0e1cc579fa3d5ba1ad7ae4cd7af79ab974 syntax = "proto3"; @@ -644,11 +644,11 @@ message ApplyFixesReturn { } message SarifFormatParams { - bool hide_nudge = 186555222; - string engine_label = 275040449; string rules = 109321335; repeated CliMatch cli_matches = 442665614; repeated CliError cli_errors = 87941111; + bool hide_nudge = 186555222; + string engine_label = 275040449; bool show_dataflow_traces = 310197169; } diff --git a/semgrep_output_v1.py b/semgrep_output_v1.py index 0a3485b8..4215d26a 100644 --- a/semgrep_output_v1.py +++ b/semgrep_output_v1.py @@ -6903,36 +6903,35 @@ def to_json_string(self, **kw: Any) -> str: class SarifFormatParams: """Original type: sarif_format_params = { ... }""" - hide_nudge: bool - engine_label: str rules: Fpath cli_matches: List[CliMatch] cli_errors: List[CliError] - show_dataflow_traces: Optional[bool] = None + hide_nudge: bool + engine_label: str + show_dataflow_traces: bool @classmethod def from_json(cls, x: Any) -> 'SarifFormatParams': if isinstance(x, dict): return cls( - hide_nudge=_atd_read_bool(x['hide_nudge']) if 'hide_nudge' in x else _atd_missing_json_field('SarifFormatParams', 'hide_nudge'), - engine_label=_atd_read_string(x['engine_label']) if 'engine_label' in x else _atd_missing_json_field('SarifFormatParams', 'engine_label'), rules=Fpath.from_json(x['rules']) if 'rules' in x else _atd_missing_json_field('SarifFormatParams', 'rules'), cli_matches=_atd_read_list(CliMatch.from_json)(x['cli_matches']) if 'cli_matches' in x else _atd_missing_json_field('SarifFormatParams', 'cli_matches'), cli_errors=_atd_read_list(CliError.from_json)(x['cli_errors']) if 'cli_errors' in x else _atd_missing_json_field('SarifFormatParams', 'cli_errors'), - show_dataflow_traces=_atd_read_bool(x['show_dataflow_traces']) if 'show_dataflow_traces' in x else None, + hide_nudge=_atd_read_bool(x['hide_nudge']) if 'hide_nudge' in x else _atd_missing_json_field('SarifFormatParams', 'hide_nudge'), + engine_label=_atd_read_string(x['engine_label']) if 'engine_label' in x else _atd_missing_json_field('SarifFormatParams', 'engine_label'), + show_dataflow_traces=_atd_read_bool(x['show_dataflow_traces']) if 'show_dataflow_traces' in x else _atd_missing_json_field('SarifFormatParams', 'show_dataflow_traces'), ) else: _atd_bad_json('SarifFormatParams', x) def to_json(self) -> Any: res: Dict[str, Any] = {} - res['hide_nudge'] = _atd_write_bool(self.hide_nudge) - res['engine_label'] = _atd_write_string(self.engine_label) res['rules'] = (lambda x: x.to_json())(self.rules) res['cli_matches'] = _atd_write_list((lambda x: x.to_json()))(self.cli_matches) res['cli_errors'] = _atd_write_list((lambda x: x.to_json()))(self.cli_errors) - if self.show_dataflow_traces is not None: - res['show_dataflow_traces'] = _atd_write_bool(self.show_dataflow_traces) + res['hide_nudge'] = _atd_write_bool(self.hide_nudge) + res['engine_label'] = _atd_write_string(self.engine_label) + res['show_dataflow_traces'] = _atd_write_bool(self.show_dataflow_traces) return res @classmethod @@ -8183,36 +8182,36 @@ def to_json_string(self, **kw: Any) -> str: @dataclass(frozen=True) -class RetSarifFormat: - """Original type: function_return = [ ... | RetSarifFormat of ... | ... ]""" +class RetContributions: + """Original type: function_return = [ ... | RetContributions of ... | ... ]""" - value: SarifFormatReturn + value: Contributions @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'RetSarifFormat' + return 'RetContributions' def to_json(self) -> Any: - return ['RetSarifFormat', (lambda x: x.to_json())(self.value)] + return ['RetContributions', (lambda x: x.to_json())(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class RetContributions: - """Original type: function_return = [ ... | RetContributions of ... | ... ]""" +class RetSarifFormat: + """Original type: function_return = [ ... | RetSarifFormat of ... | ... ]""" - value: Contributions + value: SarifFormatReturn @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'RetContributions' + return 'RetSarifFormat' def to_json(self) -> Any: - return ['RetContributions', (lambda x: x.to_json())(self.value)] + return ['RetSarifFormat', (lambda x: x.to_json())(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @@ -8294,7 +8293,7 @@ def to_json_string(self, **kw: Any) -> str: class FunctionReturn: """Original type: function_return = [ ... ]""" - value: Union[RetError, RetApplyFixes, RetSarifFormat, RetContributions, RetFormatter, RetValidate, RetResolveDependencies, RetDumpRulePartitions] + value: Union[RetError, RetApplyFixes, RetContributions, RetSarifFormat, RetFormatter, RetValidate, RetResolveDependencies, RetDumpRulePartitions] @property def kind(self) -> str: @@ -8309,10 +8308,10 @@ def from_json(cls, x: Any) -> 'FunctionReturn': return cls(RetError(_atd_read_string(x[1]))) if cons == 'RetApplyFixes': return cls(RetApplyFixes(ApplyFixesReturn.from_json(x[1]))) - if cons == 'RetSarifFormat': - return cls(RetSarifFormat(SarifFormatReturn.from_json(x[1]))) if cons == 'RetContributions': return cls(RetContributions(Contributions.from_json(x[1]))) + if cons == 'RetSarifFormat': + return cls(RetSarifFormat(SarifFormatReturn.from_json(x[1]))) if cons == 'RetFormatter': return cls(RetFormatter(_atd_read_string(x[1]))) if cons == 'RetValidate': @@ -8571,7 +8570,7 @@ def to_json_string(self, **kw: Any) -> str: class CallSarifFormat: """Original type: function_call = [ ... | CallSarifFormat of ... | ... ]""" - value: SarifFormatParams + value: Tuple[FormatContext, SarifFormatParams] @property def kind(self) -> str: @@ -8579,7 +8578,7 @@ def kind(self) -> str: return 'CallSarifFormat' def to_json(self) -> Any: - return ['CallSarifFormat', (lambda x: x.to_json())(self.value)] + return ['CallSarifFormat', (lambda x: [(lambda x: x.to_json())(x[0]), (lambda x: x.to_json())(x[1])] if isinstance(x, tuple) and len(x) == 2 else _atd_bad_python('tuple of length 2', x))(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @@ -8679,7 +8678,7 @@ def from_json(cls, x: Any) -> 'FunctionCall': if cons == 'CallApplyFixes': return cls(CallApplyFixes(ApplyFixesParams.from_json(x[1]))) if cons == 'CallSarifFormat': - return cls(CallSarifFormat(SarifFormatParams.from_json(x[1]))) + return cls(CallSarifFormat((lambda x: (FormatContext.from_json(x[0]), SarifFormatParams.from_json(x[1])) if isinstance(x, list) and len(x) == 2 else _atd_bad_json('array of length 2', x))(x[1]))) if cons == 'CallFormatter': return cls(CallFormatter((lambda x: (OutputFormat.from_json(x[0]), FormatContext.from_json(x[1]), CliOutput.from_json(x[2])) if isinstance(x, list) and len(x) == 3 else _atd_bad_json('array of length 3', x))(x[1]))) if cons == 'CallValidate': diff --git a/semgrep_output_v1.ts b/semgrep_output_v1.ts index d3bc45ec..effb4ec6 100644 --- a/semgrep_output_v1.ts +++ b/semgrep_output_v1.ts @@ -869,12 +869,12 @@ export type ApplyFixesReturn = { } export type SarifFormatParams = { - hide_nudge: boolean; - engine_label: string; rules: Fpath; cli_matches: CliMatch[]; cli_errors: CliError[]; - show_dataflow_traces?: boolean; + hide_nudge: boolean; + engine_label: string; + show_dataflow_traces: boolean; } export type SarifFormatReturn = { @@ -979,7 +979,7 @@ export type ResolutionResult = export type FunctionCall = | { kind: 'CallContributions' } | { kind: 'CallApplyFixes'; value: ApplyFixesParams } -| { kind: 'CallSarifFormat'; value: SarifFormatParams } +| { kind: 'CallSarifFormat'; value: [FormatContext, SarifFormatParams] } | { kind: 'CallFormatter'; value: [OutputFormat, FormatContext, CliOutput] } | { kind: 'CallValidate'; value: Fpath } | { kind: 'CallResolveDependencies'; value: DependencySource[] } @@ -988,8 +988,8 @@ export type FunctionCall = export type FunctionReturn = | { kind: 'RetError'; value: string } | { kind: 'RetApplyFixes'; value: ApplyFixesReturn } -| { kind: 'RetSarifFormat'; value: SarifFormatReturn } | { kind: 'RetContributions'; value: Contributions } +| { kind: 'RetSarifFormat'; value: SarifFormatReturn } | { kind: 'RetFormatter'; value: string } | { kind: 'RetValidate'; value: boolean } | { kind: 'RetResolveDependencies'; value: [DependencySource, ResolutionResult][] } @@ -3636,23 +3636,23 @@ export function readApplyFixesReturn(x: any, context: any = x): ApplyFixesReturn export function writeSarifFormatParams(x: SarifFormatParams, context: any = x): any { return { - 'hide_nudge': _atd_write_required_field('SarifFormatParams', 'hide_nudge', _atd_write_bool, x.hide_nudge, x), - 'engine_label': _atd_write_required_field('SarifFormatParams', 'engine_label', _atd_write_string, x.engine_label, x), 'rules': _atd_write_required_field('SarifFormatParams', 'rules', writeFpath, x.rules, x), 'cli_matches': _atd_write_required_field('SarifFormatParams', 'cli_matches', _atd_write_array(writeCliMatch), x.cli_matches, x), 'cli_errors': _atd_write_required_field('SarifFormatParams', 'cli_errors', _atd_write_array(writeCliError), x.cli_errors, x), - 'show_dataflow_traces': _atd_write_optional_field(_atd_write_bool, x.show_dataflow_traces, x), + 'hide_nudge': _atd_write_required_field('SarifFormatParams', 'hide_nudge', _atd_write_bool, x.hide_nudge, x), + 'engine_label': _atd_write_required_field('SarifFormatParams', 'engine_label', _atd_write_string, x.engine_label, x), + 'show_dataflow_traces': _atd_write_required_field('SarifFormatParams', 'show_dataflow_traces', _atd_write_bool, x.show_dataflow_traces, x), }; } export function readSarifFormatParams(x: any, context: any = x): SarifFormatParams { return { - hide_nudge: _atd_read_required_field('SarifFormatParams', 'hide_nudge', _atd_read_bool, x['hide_nudge'], x), - engine_label: _atd_read_required_field('SarifFormatParams', 'engine_label', _atd_read_string, x['engine_label'], x), rules: _atd_read_required_field('SarifFormatParams', 'rules', readFpath, x['rules'], x), cli_matches: _atd_read_required_field('SarifFormatParams', 'cli_matches', _atd_read_array(readCliMatch), x['cli_matches'], x), cli_errors: _atd_read_required_field('SarifFormatParams', 'cli_errors', _atd_read_array(readCliError), x['cli_errors'], x), - show_dataflow_traces: _atd_read_optional_field(_atd_read_bool, x['show_dataflow_traces'], x), + hide_nudge: _atd_read_required_field('SarifFormatParams', 'hide_nudge', _atd_read_bool, x['hide_nudge'], x), + engine_label: _atd_read_required_field('SarifFormatParams', 'engine_label', _atd_read_string, x['engine_label'], x), + show_dataflow_traces: _atd_read_required_field('SarifFormatParams', 'show_dataflow_traces', _atd_read_bool, x['show_dataflow_traces'], x), }; } @@ -4061,7 +4061,7 @@ export function writeFunctionCall(x: FunctionCall, context: any = x): any { case 'CallApplyFixes': return ['CallApplyFixes', writeApplyFixesParams(x.value, x)] case 'CallSarifFormat': - return ['CallSarifFormat', writeSarifFormatParams(x.value, x)] + return ['CallSarifFormat', ((x, context) => [writeFormatContext(x[0], x), writeSarifFormatParams(x[1], x)])(x.value, x)] case 'CallFormatter': return ['CallFormatter', ((x, context) => [writeOutputFormat(x[0], x), writeFormatContext(x[1], x), writeCliOutput(x[2], x)])(x.value, x)] case 'CallValidate': @@ -4089,7 +4089,7 @@ export function readFunctionCall(x: any, context: any = x): FunctionCall { case 'CallApplyFixes': return { kind: 'CallApplyFixes', value: readApplyFixesParams(x[1], x) } case 'CallSarifFormat': - return { kind: 'CallSarifFormat', value: readSarifFormatParams(x[1], x) } + return { kind: 'CallSarifFormat', value: ((x, context): [FormatContext, SarifFormatParams] => { _atd_check_json_tuple(2, x, context); return [readFormatContext(x[0], x), readSarifFormatParams(x[1], x)] })(x[1], x) } case 'CallFormatter': return { kind: 'CallFormatter', value: ((x, context): [OutputFormat, FormatContext, CliOutput] => { _atd_check_json_tuple(3, x, context); return [readOutputFormat(x[0], x), readFormatContext(x[1], x), readCliOutput(x[2], x)] })(x[1], x) } case 'CallValidate': @@ -4111,10 +4111,10 @@ export function writeFunctionReturn(x: FunctionReturn, context: any = x): any { return ['RetError', _atd_write_string(x.value, x)] case 'RetApplyFixes': return ['RetApplyFixes', writeApplyFixesReturn(x.value, x)] - case 'RetSarifFormat': - return ['RetSarifFormat', writeSarifFormatReturn(x.value, x)] case 'RetContributions': return ['RetContributions', writeContributions(x.value, x)] + case 'RetSarifFormat': + return ['RetSarifFormat', writeSarifFormatReturn(x.value, x)] case 'RetFormatter': return ['RetFormatter', _atd_write_string(x.value, x)] case 'RetValidate': @@ -4133,10 +4133,10 @@ export function readFunctionReturn(x: any, context: any = x): FunctionReturn { return { kind: 'RetError', value: _atd_read_string(x[1], x) } case 'RetApplyFixes': return { kind: 'RetApplyFixes', value: readApplyFixesReturn(x[1], x) } - case 'RetSarifFormat': - return { kind: 'RetSarifFormat', value: readSarifFormatReturn(x[1], x) } case 'RetContributions': return { kind: 'RetContributions', value: readContributions(x[1], x) } + case 'RetSarifFormat': + return { kind: 'RetSarifFormat', value: readSarifFormatReturn(x[1], x) } case 'RetFormatter': return { kind: 'RetFormatter', value: _atd_read_string(x[1], x) } case 'RetValidate': diff --git a/semgrep_output_v1_j.ml b/semgrep_output_v1_j.ml index 910138cc..ac9c702f 100644 --- a/semgrep_output_v1_j.ml +++ b/semgrep_output_v1_j.ml @@ -596,12 +596,12 @@ type cli_error = Semgrep_output_v1_t.cli_error = { } type sarif_format_params = Semgrep_output_v1_t.sarif_format_params = { - hide_nudge: bool; - engine_label: string; rules: fpath; cli_matches: cli_match list; cli_errors: cli_error list; - show_dataflow_traces: bool option + hide_nudge: bool; + engine_label: string; + show_dataflow_traces: bool } type engine_kind = Semgrep_output_v1_t.engine_kind [@@deriving show] @@ -22953,58 +22953,56 @@ let write_sarif_format_params : _ -> sarif_format_params -> _ = ( is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"hide_nudge\":"; + Buffer.add_string ob "\"rules\":"; ( - Yojson.Safe.write_bool + write_fpath ) - ob x.hide_nudge; + ob x.rules; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"engine_label\":"; + Buffer.add_string ob "\"cli_matches\":"; ( - Yojson.Safe.write_string + write__cli_match_list ) - ob x.engine_label; + ob x.cli_matches; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"rules\":"; + Buffer.add_string ob "\"cli_errors\":"; ( - write_fpath + write__cli_error_list ) - ob x.rules; + ob x.cli_errors; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"cli_matches\":"; + Buffer.add_string ob "\"hide_nudge\":"; ( - write__cli_match_list + Yojson.Safe.write_bool ) - ob x.cli_matches; + ob x.hide_nudge; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"cli_errors\":"; + Buffer.add_string ob "\"engine_label\":"; ( - write__cli_error_list + Yojson.Safe.write_string ) - ob x.cli_errors; - (match x.show_dataflow_traces with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"show_dataflow_traces\":"; - ( - Yojson.Safe.write_bool - ) - ob x; - ); + ob x.engine_label; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"show_dataflow_traces\":"; + ( + Yojson.Safe.write_bool + ) + ob x.show_dataflow_traces; Buffer.add_char ob '}'; ) let string_of_sarif_format_params ?(len = 1024) x = @@ -23015,11 +23013,11 @@ let read_sarif_format_params = ( fun p lb -> Yojson.Safe.read_space p lb; Yojson.Safe.read_lcurl p lb; - let field_hide_nudge = ref (None) in - let field_engine_label = ref (None) in let field_rules = ref (None) in let field_cli_matches = ref (None) in let field_cli_errors = ref (None) in + let field_hide_nudge = ref (None) in + let field_engine_label = ref (None) in let field_show_dataflow_traces = ref (None) in try Yojson.Safe.read_space p lb; @@ -23032,7 +23030,7 @@ let read_sarif_format_params = ( match len with | 5 -> ( if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' then ( - 2 + 0 ) else ( -1 @@ -23042,7 +23040,7 @@ let read_sarif_format_params = ( match String.unsafe_get s pos with | 'c' -> ( if String.unsafe_get s (pos+1) = 'l' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 'o' && String.unsafe_get s (pos+8) = 'r' && String.unsafe_get s (pos+9) = 's' then ( - 4 + 2 ) else ( -1 @@ -23050,7 +23048,7 @@ let read_sarif_format_params = ( ) | 'h' -> ( if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'u' && String.unsafe_get s (pos+7) = 'd' && String.unsafe_get s (pos+8) = 'g' && String.unsafe_get s (pos+9) = 'e' then ( - 0 + 3 ) else ( -1 @@ -23062,7 +23060,7 @@ let read_sarif_format_params = ( ) | 11 -> ( if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'l' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'm' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'h' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 's' then ( - 3 + 1 ) else ( -1 @@ -23070,7 +23068,7 @@ let read_sarif_format_params = ( ) | 12 -> ( if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'g' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'l' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'b' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 'l' then ( - 1 + 4 ) else ( -1 @@ -23093,55 +23091,53 @@ let read_sarif_format_params = ( ( match i with | 0 -> - field_hide_nudge := ( + field_rules := ( Some ( ( - Atdgen_runtime.Oj_run.read_bool + read_fpath ) p lb ) ); | 1 -> - field_engine_label := ( + field_cli_matches := ( Some ( ( - Atdgen_runtime.Oj_run.read_string + read__cli_match_list ) p lb ) ); | 2 -> - field_rules := ( + field_cli_errors := ( Some ( ( - read_fpath + read__cli_error_list ) p lb ) ); | 3 -> - field_cli_matches := ( + field_hide_nudge := ( Some ( ( - read__cli_match_list + Atdgen_runtime.Oj_run.read_bool ) p lb ) ); | 4 -> - field_cli_errors := ( + field_engine_label := ( Some ( ( - read__cli_error_list + Atdgen_runtime.Oj_run.read_string ) p lb ) ); | 5 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_show_dataflow_traces := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) + field_show_dataflow_traces := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); | _ -> ( Yojson.Safe.skip_json p lb ) @@ -23157,7 +23153,7 @@ let read_sarif_format_params = ( match len with | 5 -> ( if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' then ( - 2 + 0 ) else ( -1 @@ -23167,7 +23163,7 @@ let read_sarif_format_params = ( match String.unsafe_get s pos with | 'c' -> ( if String.unsafe_get s (pos+1) = 'l' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 'o' && String.unsafe_get s (pos+8) = 'r' && String.unsafe_get s (pos+9) = 's' then ( - 4 + 2 ) else ( -1 @@ -23175,7 +23171,7 @@ let read_sarif_format_params = ( ) | 'h' -> ( if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'u' && String.unsafe_get s (pos+7) = 'd' && String.unsafe_get s (pos+8) = 'g' && String.unsafe_get s (pos+9) = 'e' then ( - 0 + 3 ) else ( -1 @@ -23187,7 +23183,7 @@ let read_sarif_format_params = ( ) | 11 -> ( if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'l' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'm' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'h' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 's' then ( - 3 + 1 ) else ( -1 @@ -23195,7 +23191,7 @@ let read_sarif_format_params = ( ) | 12 -> ( if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'g' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'l' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'b' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 'l' then ( - 1 + 4 ) else ( -1 @@ -23218,55 +23214,53 @@ let read_sarif_format_params = ( ( match i with | 0 -> - field_hide_nudge := ( + field_rules := ( Some ( ( - Atdgen_runtime.Oj_run.read_bool + read_fpath ) p lb ) ); | 1 -> - field_engine_label := ( + field_cli_matches := ( Some ( ( - Atdgen_runtime.Oj_run.read_string + read__cli_match_list ) p lb ) ); | 2 -> - field_rules := ( + field_cli_errors := ( Some ( ( - read_fpath + read__cli_error_list ) p lb ) ); | 3 -> - field_cli_matches := ( + field_hide_nudge := ( Some ( ( - read__cli_match_list + Atdgen_runtime.Oj_run.read_bool ) p lb ) ); | 4 -> - field_cli_errors := ( + field_engine_label := ( Some ( ( - read__cli_error_list + Atdgen_runtime.Oj_run.read_string ) p lb ) ); | 5 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_show_dataflow_traces := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) + field_show_dataflow_traces := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); | _ -> ( Yojson.Safe.skip_json p lb ) @@ -23276,12 +23270,12 @@ let read_sarif_format_params = ( with Yojson.End_of_object -> ( ( { - hide_nudge = (match !field_hide_nudge with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "hide_nudge"); - engine_label = (match !field_engine_label with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "engine_label"); rules = (match !field_rules with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "rules"); cli_matches = (match !field_cli_matches with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "cli_matches"); cli_errors = (match !field_cli_errors with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "cli_errors"); - show_dataflow_traces = !field_show_dataflow_traces; + hide_nudge = (match !field_hide_nudge with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "hide_nudge"); + engine_label = (match !field_engine_label with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "engine_label"); + show_dataflow_traces = (match !field_show_dataflow_traces with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "show_dataflow_traces"); } : sarif_format_params) ) @@ -29441,18 +29435,18 @@ let write_function_return = ( write_apply_fixes_return ) ob x; Buffer.add_char ob ']' - | `RetSarifFormat x -> - Buffer.add_string ob "[\"RetSarifFormat\","; - ( - write_sarif_format_return - ) ob x; - Buffer.add_char ob ']' | `RetContributions x -> Buffer.add_string ob "[\"RetContributions\","; ( write_contributions ) ob x; Buffer.add_char ob ']' + | `RetSarifFormat x -> + Buffer.add_string ob "[\"RetSarifFormat\","; + ( + write_sarif_format_return + ) ob x; + Buffer.add_char ob ']' | `RetFormatter x -> Buffer.add_string ob "[\"RetFormatter\","; ( @@ -29506,24 +29500,24 @@ let read_function_return = ( Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; `RetApplyFixes x - | "RetSarifFormat" -> + | "RetContributions" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( - read_sarif_format_return + read_contributions ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - `RetSarifFormat x - | "RetContributions" -> + `RetContributions x + | "RetSarifFormat" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( - read_contributions + read_sarif_format_return ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - `RetContributions x + `RetSarifFormat x | "RetFormatter" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( @@ -29592,28 +29586,28 @@ let read_function_return = ( Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; `RetApplyFixes x - | "RetSarifFormat" -> + | "RetContributions" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; let x = ( - read_sarif_format_return + read_contributions ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; - `RetSarifFormat x - | "RetContributions" -> + `RetContributions x + | "RetSarifFormat" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; let x = ( - read_contributions + read_sarif_format_return ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; - `RetContributions x + `RetSarifFormat x | "RetFormatter" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; @@ -31298,7 +31292,20 @@ let write_function_call = ( | `CallSarifFormat x -> Buffer.add_string ob "[\"CallSarifFormat\","; ( - write_sarif_format_params + fun ob x -> + Buffer.add_char ob '['; + (let x, _ = x in + ( + write_format_context + ) ob x + ); + Buffer.add_char ob ','; + (let _, x = x in + ( + write_sarif_format_params + ) ob x + ); + Buffer.add_char ob ']'; ) ob x; Buffer.add_char ob ']' | `CallFormatter x -> @@ -31371,7 +31378,48 @@ let read_function_call = ( | "CallSarifFormat" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( - read_sarif_format_params + fun p lb -> + Yojson.Safe.read_space p lb; + let std_tuple = Yojson.Safe.start_any_tuple p lb in + let len = ref 0 in + let end_of_tuple = ref false in + (try + let x0 = + let x = + ( + read_format_context + ) p lb + in + incr len; + Yojson.Safe.read_space p lb; + Yojson.Safe.read_tuple_sep2 p std_tuple lb; + x + in + let x1 = + let x = + ( + read_sarif_format_params + ) p lb + in + incr len; + (try + Yojson.Safe.read_space p lb; + Yojson.Safe.read_tuple_sep2 p std_tuple lb; + with Yojson.End_of_tuple -> end_of_tuple := true); + x + in + if not !end_of_tuple then ( + try + while true do + Yojson.Safe.skip_json p lb; + Yojson.Safe.read_space p lb; + Yojson.Safe.read_tuple_sep2 p std_tuple lb; + done + with Yojson.End_of_tuple -> () + ); + (x0, x1) + with Yojson.End_of_tuple -> + Atdgen_runtime.Oj_run.missing_tuple_fields p !len [ 0; 1 ]); ) p lb in Yojson.Safe.read_space p lb; @@ -31493,7 +31541,48 @@ let read_function_call = ( Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; let x = ( - read_sarif_format_params + fun p lb -> + Yojson.Safe.read_space p lb; + let std_tuple = Yojson.Safe.start_any_tuple p lb in + let len = ref 0 in + let end_of_tuple = ref false in + (try + let x0 = + let x = + ( + read_format_context + ) p lb + in + incr len; + Yojson.Safe.read_space p lb; + Yojson.Safe.read_tuple_sep2 p std_tuple lb; + x + in + let x1 = + let x = + ( + read_sarif_format_params + ) p lb + in + incr len; + (try + Yojson.Safe.read_space p lb; + Yojson.Safe.read_tuple_sep2 p std_tuple lb; + with Yojson.End_of_tuple -> end_of_tuple := true); + x + in + if not !end_of_tuple then ( + try + while true do + Yojson.Safe.skip_json p lb; + Yojson.Safe.read_space p lb; + Yojson.Safe.read_tuple_sep2 p std_tuple lb; + done + with Yojson.End_of_tuple -> () + ); + (x0, x1) + with Yojson.End_of_tuple -> + Atdgen_runtime.Oj_run.missing_tuple_fields p !len [ 0; 1 ]); ) p lb in Yojson.Safe.read_space p lb; diff --git a/semgrep_output_v1_j.mli b/semgrep_output_v1_j.mli index 52275bb8..e9e33a70 100644 --- a/semgrep_output_v1_j.mli +++ b/semgrep_output_v1_j.mli @@ -596,12 +596,12 @@ type cli_error = Semgrep_output_v1_t.cli_error = { } type sarif_format_params = Semgrep_output_v1_t.sarif_format_params = { - hide_nudge: bool; - engine_label: string; rules: fpath; cli_matches: cli_match list; cli_errors: cli_error list; - show_dataflow_traces: bool option + hide_nudge: bool; + engine_label: string; + show_dataflow_traces: bool } type engine_kind = Semgrep_output_v1_t.engine_kind [@@deriving show]