From 48eb84135f9cfa5cf025da05d6f8b37bf58c1bb7 Mon Sep 17 00:00:00 2001 From: Martin Jambon Date: Thu, 9 Jan 2025 17:56:49 -0800 Subject: [PATCH 1/3] Rename type xlang -> analyzer (#331) This is part of renaming the OCaml module `Xlang` to `Analyzer`. This type name change doesn't change the data format because type names don't occur in JSON data. - [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.50.0. See https://atd.readthedocs.io/en/latest/atdgen-tutorial.html#smooth-protocol-upgrades Note that the types related to the semgrep-core JSON output or the semgrep-core RPC do not need to be backward compatible! --- semgrep_output_v1.atd | 7 ++-- semgrep_output_v1.jsonschema | 4 +- semgrep_output_v1.proto | 2 +- semgrep_output_v1.py | 46 +++++++++++----------- semgrep_output_v1.ts | 12 +++--- semgrep_output_v1_j.ml | 74 ++++++++++++++++++------------------ semgrep_output_v1_j.mli | 46 +++++++++++----------- 7 files changed, 96 insertions(+), 95 deletions(-) diff --git a/semgrep_output_v1.atd b/semgrep_output_v1.atd index 919f33d..e9b9a9e 100644 --- a/semgrep_output_v1.atd +++ b/semgrep_output_v1.atd @@ -1867,7 +1867,8 @@ type core_error = { those different files (because ATD does not have a proper module system yet). *) -type xlang = string wrap +type analyzer = + string wrap (* A target can either be a traditional code target (now with optional associated lockfile) or it can be a lockfile target, which will be used to @@ -1889,10 +1890,10 @@ type target = [ *) type code_target = { path: fpath (* source file *); - (* Must be a valid target analyzer as defined in Xlang.mli. + (* Must be a valid target analyzer as defined in Analyzer.mli. examples: "ocaml", "python", but also "spacegrep" or "regexp". *) - analyzer: xlang; + analyzer: analyzer; products: product list; ?lockfile_target: lockfile option; } diff --git a/semgrep_output_v1.jsonschema b/semgrep_output_v1.jsonschema index ace6318..2368698 100644 --- a/semgrep_output_v1.jsonschema +++ b/semgrep_output_v1.jsonschema @@ -1526,7 +1526,7 @@ "rule_id": { "$ref": "#/definitions/rule_id" } } }, - "xlang": { "type": "string" }, + "analyzer": { "type": "string" }, "target": { "oneOf": [ { @@ -1554,7 +1554,7 @@ "required": [ "path", "analyzer", "products" ], "properties": { "path": { "$ref": "#/definitions/fpath" }, - "analyzer": { "$ref": "#/definitions/xlang" }, + "analyzer": { "$ref": "#/definitions/analyzer" }, "products": { "type": "array", "items": { "$ref": "#/definitions/product" } diff --git a/semgrep_output_v1.proto b/semgrep_output_v1.proto index ce65ff5..e8a7ab5 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: 18d5eed99a95ef7ab173fc0b5a4b302224b414ffe16b5f33027813a6880c7097 +// Source file sha256 digest: b528a41b8d32b802921305aec117b05bf8623ba75a34ad2d8f12d1711ce89e54 syntax = "proto3"; diff --git a/semgrep_output_v1.py b/semgrep_output_v1.py index 395549e..8f473d3 100644 --- a/semgrep_output_v1.py +++ b/semgrep_output_v1.py @@ -2169,27 +2169,6 @@ def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class Xlang: - """Original type: xlang""" - - value: str - - @classmethod - def from_json(cls, x: Any) -> 'Xlang': - return cls(_atd_read_string(x)) - - def to_json(self) -> Any: - return _atd_write_string(self.value) - - @classmethod - def from_json_string(cls, x: str) -> 'Xlang': - return cls.from_json(json.loads(x)) - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - @dataclass class Version: """Original type: version""" @@ -3461,12 +3440,33 @@ def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) +@dataclass +class Analyzer: + """Original type: analyzer""" + + value: str + + @classmethod + def from_json(cls, x: Any) -> 'Analyzer': + return cls(_atd_read_string(x)) + + def to_json(self) -> Any: + return _atd_write_string(self.value) + + @classmethod + def from_json_string(cls, x: str) -> 'Analyzer': + return cls.from_json(json.loads(x)) + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + @dataclass class CodeTarget: """Original type: code_target = { ... }""" path: Fpath - analyzer: Xlang + analyzer: Analyzer products: List[Product] lockfile_target: Optional[Lockfile] = None @@ -3475,7 +3475,7 @@ def from_json(cls, x: Any) -> 'CodeTarget': if isinstance(x, dict): return cls( path=Fpath.from_json(x['path']) if 'path' in x else _atd_missing_json_field('CodeTarget', 'path'), - analyzer=Xlang.from_json(x['analyzer']) if 'analyzer' in x else _atd_missing_json_field('CodeTarget', 'analyzer'), + analyzer=Analyzer.from_json(x['analyzer']) if 'analyzer' in x else _atd_missing_json_field('CodeTarget', 'analyzer'), products=_atd_read_list(Product.from_json)(x['products']) if 'products' in x else _atd_missing_json_field('CodeTarget', 'products'), lockfile_target=Lockfile.from_json(x['lockfile_target']) if 'lockfile_target' in x else None, ) diff --git a/semgrep_output_v1.ts b/semgrep_output_v1.ts index 7b93cc0..6209cf6 100644 --- a/semgrep_output_v1.ts +++ b/semgrep_output_v1.ts @@ -838,7 +838,7 @@ export type CoreError = { rule_id?: RuleId; } -export type Xlang = string +export type Analyzer = string export type Target = | { kind: 'CodeTarget'; value: CodeTarget } @@ -846,7 +846,7 @@ export type Target = export type CodeTarget = { path: Fpath; - analyzer: Xlang; + analyzer: Analyzer; products: Product[]; lockfile_target?: Lockfile; } @@ -3544,11 +3544,11 @@ export function readCoreError(x: any, context: any = x): CoreError { }; } -export function writeXlang(x: Xlang, context: any = x): any { +export function writeAnalyzer(x: Analyzer, context: any = x): any { return _atd_write_string(x, context); } -export function readXlang(x: any, context: any = x): Xlang { +export function readAnalyzer(x: any, context: any = x): Analyzer { return _atd_read_string(x, context); } @@ -3577,7 +3577,7 @@ export function readTarget(x: any, context: any = x): Target { export function writeCodeTarget(x: CodeTarget, context: any = x): any { return { 'path': _atd_write_required_field('CodeTarget', 'path', writeFpath, x.path, x), - 'analyzer': _atd_write_required_field('CodeTarget', 'analyzer', writeXlang, x.analyzer, x), + 'analyzer': _atd_write_required_field('CodeTarget', 'analyzer', writeAnalyzer, x.analyzer, x), 'products': _atd_write_required_field('CodeTarget', 'products', _atd_write_array(writeProduct), x.products, x), 'lockfile_target': _atd_write_optional_field(writeLockfile, x.lockfile_target, x), }; @@ -3586,7 +3586,7 @@ export function writeCodeTarget(x: CodeTarget, context: any = x): any { export function readCodeTarget(x: any, context: any = x): CodeTarget { return { path: _atd_read_required_field('CodeTarget', 'path', readFpath, x['path'], x), - analyzer: _atd_read_required_field('CodeTarget', 'analyzer', readXlang, x['analyzer'], x), + analyzer: _atd_read_required_field('CodeTarget', 'analyzer', readAnalyzer, x['analyzer'], x), products: _atd_read_required_field('CodeTarget', 'products', _atd_read_array(readProduct), x['products'], x), lockfile_target: _atd_read_optional_field(readLockfile, x['lockfile_target'], x), }; diff --git a/semgrep_output_v1_j.ml b/semgrep_output_v1_j.ml index 79b61cc..ed759d3 100644 --- a/semgrep_output_v1_j.ml +++ b/semgrep_output_v1_j.ml @@ -177,8 +177,6 @@ type matching_explanation = Semgrep_output_v1_t.matching_explanation = { extra: matching_explanation_extra option } -type xlang = Semgrep_output_v1_t.xlang [@@deriving show] - type version = Semgrep_output_v1_t.version [@@deriving show] type uuid = Semgrep_output_v1_t.uuid @@ -276,9 +274,11 @@ type lockfile = Semgrep_output_v1_t.lockfile = { } [@@deriving show, eq] +type analyzer = Semgrep_output_v1_t.analyzer [@@deriving show] + type code_target = Semgrep_output_v1_t.code_target = { path: fpath; - analyzer: xlang; + analyzer: analyzer; products: product list; lockfile_target: lockfile option } @@ -7428,37 +7428,6 @@ and read_matching_explanation = ( ) and matching_explanation_of_string s = read_matching_explanation (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__x_893d00a = ( - fun ob x -> ( - let x = ( Xlang.unwrap ) x in ( - Yojson.Safe.write_string - ) ob x) -) -let string_of__x_893d00a ?(len = 1024) x = - let ob = Buffer.create len in - write__x_893d00a ob x; - Buffer.contents ob -let read__x_893d00a = ( - fun p lb -> - let x = ( - Atdgen_runtime.Oj_run.read_string - ) p lb in - ( Xlang.wrap ) x -) -let _x_893d00a_of_string s = - read__x_893d00a (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_xlang = ( - write__x_893d00a -) -let string_of_xlang ?(len = 1024) x = - let ob = Buffer.create len in - write_xlang ob x; - Buffer.contents ob -let read_xlang = ( - read__x_893d00a -) -let xlang_of_string s = - read_xlang (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_version = ( Yojson.Safe.write_string ) @@ -10532,6 +10501,37 @@ let read_lockfile = ( ) let lockfile_of_string s = read_lockfile (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__x_7982d5d = ( + fun ob x -> ( + let x = ( Analyzer.unwrap ) x in ( + Yojson.Safe.write_string + ) ob x) +) +let string_of__x_7982d5d ?(len = 1024) x = + let ob = Buffer.create len in + write__x_7982d5d ob x; + Buffer.contents ob +let read__x_7982d5d = ( + fun p lb -> + let x = ( + Atdgen_runtime.Oj_run.read_string + ) p lb in + ( Analyzer.wrap ) x +) +let _x_7982d5d_of_string s = + read__x_7982d5d (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_analyzer = ( + write__x_7982d5d +) +let string_of_analyzer ?(len = 1024) x = + let ob = Buffer.create len in + write_analyzer ob x; + Buffer.contents ob +let read_analyzer = ( + read__x_7982d5d +) +let analyzer_of_string s = + read_analyzer (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__product_list = ( Atdgen_runtime.Oj_run.write_list ( write_product @@ -10624,7 +10624,7 @@ let write_code_target : _ -> code_target -> _ = ( Buffer.add_char ob ','; Buffer.add_string ob "\"analyzer\":"; ( - write_xlang + write_analyzer ) ob x.analyzer; if !is_first then @@ -10728,7 +10728,7 @@ let read_code_target = ( field_analyzer := ( Some ( ( - read_xlang + read_analyzer ) p lb ) ); @@ -10821,7 +10821,7 @@ let read_code_target = ( field_analyzer := ( Some ( ( - read_xlang + read_analyzer ) p lb ) ); diff --git a/semgrep_output_v1_j.mli b/semgrep_output_v1_j.mli index 2b5c422..92a2440 100644 --- a/semgrep_output_v1_j.mli +++ b/semgrep_output_v1_j.mli @@ -177,8 +177,6 @@ type matching_explanation = Semgrep_output_v1_t.matching_explanation = { extra: matching_explanation_extra option } -type xlang = Semgrep_output_v1_t.xlang [@@deriving show] - type version = Semgrep_output_v1_t.version [@@deriving show] type uuid = Semgrep_output_v1_t.uuid @@ -276,9 +274,11 @@ type lockfile = Semgrep_output_v1_t.lockfile = { } [@@deriving show, eq] +type analyzer = Semgrep_output_v1_t.analyzer [@@deriving show] + type code_target = Semgrep_output_v1_t.code_target = { path: fpath; - analyzer: xlang; + analyzer: analyzer; products: product list; lockfile_target: lockfile option } @@ -1510,26 +1510,6 @@ val matching_explanation_of_string : string -> matching_explanation (** Deserialize JSON data of type {!type:matching_explanation}. *) -val write_xlang : - Buffer.t -> xlang -> unit - (** Output a JSON value of type {!type:xlang}. *) - -val string_of_xlang : - ?len:int -> xlang -> string - (** Serialize a value of type {!type:xlang} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_xlang : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> xlang - (** Input JSON data of type {!type:xlang}. *) - -val xlang_of_string : - string -> xlang - (** Deserialize JSON data of type {!type:xlang}. *) - val write_version : Buffer.t -> version -> unit (** Output a JSON value of type {!type:version}. *) @@ -1990,6 +1970,26 @@ val lockfile_of_string : string -> lockfile (** Deserialize JSON data of type {!type:lockfile}. *) +val write_analyzer : + Buffer.t -> analyzer -> unit + (** Output a JSON value of type {!type:analyzer}. *) + +val string_of_analyzer : + ?len:int -> analyzer -> string + (** Serialize a value of type {!type:analyzer} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_analyzer : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> analyzer + (** Input JSON data of type {!type:analyzer}. *) + +val analyzer_of_string : + string -> analyzer + (** Deserialize JSON data of type {!type:analyzer}. *) + val write_code_target : Buffer.t -> code_target -> unit (** Output a JSON value of type {!type:code_target}. *) From aec607b30f7a03729b5a21947ad62fa60f9cb9e2 Mon Sep 17 00:00:00 2001 From: Yoann Padioleau Date: Mon, 13 Jan 2025 08:53:10 +0100 Subject: [PATCH 2/3] cleanup semgrep ci config section (#334) test plan: make - [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.50.0. See https://atd.readthedocs.io/en/latest/atdgen-tutorial.html#smooth-protocol-upgrades Note that the types related to the semgrep-core JSON output or the semgrep-core RPC do not need to be backward compatible! Co-authored-by: pad --- semgrep_output_v1.atd | 179 +++++++++--------- semgrep_output_v1.jsonschema | 180 +++++++++--------- semgrep_output_v1.proto | 90 ++++----- semgrep_output_v1.py | 8 +- semgrep_output_v1.ts | 352 +++++++++++++++++------------------ semgrep_output_v1_j.ml | 142 +++++++------- semgrep_output_v1_j.mli | 4 +- 7 files changed, 477 insertions(+), 478 deletions(-) diff --git a/semgrep_output_v1.atd b/semgrep_output_v1.atd index e9b9a9e..f25c999 100644 --- a/semgrep_output_v1.atd +++ b/semgrep_output_v1.atd @@ -1120,13 +1120,12 @@ type killing_parent = { * types used to communicate with the Semgrep backend and are not meant * to be consumed directly by Semgrep users or tools wrapping Semgrep. * - * The sequence of HTTP requests is mostly: - * - /deployments/current with token + * The sequence of HTTP requests for 'semgrep ci' is mostly: + * - /api/agent/deployments/current with token * and response with deployment name in a deployment config - * - /deployments/scans when starting a scan, with information about the project - * and response with scan_id - * - /scans//config to request the scan config - * and response with scan_config including the rules to use + * (TODO? get rid of this one? useful?) + * - /api/cli/scans when starting a scan, with information about the project + * and response with scan_id and scan_config including the rules to use * - /results to send the findings to the backend * and response with errors and task_id * - /complete when done, with the exit code and a few more information @@ -1186,7 +1185,7 @@ type action = [ ] (* ----------------------------- *) -(* CI Configuration *) +(* CI configurations *) (* ----------------------------- *) (* Response by the backend to the CLI to the POST deployments/current *) @@ -1222,21 +1221,16 @@ type ci_config_from_repo = { (* ex: "webapp" *) type tag = string -(* Response by the backend to the CLI to the POST /scans//config *) +(* Response by the backend to the CLI to the POST deployments/scans/config + * DEPRECATED? seems to be used only by semgrep lsp. + *) type scan_config = { - (* TODO: remove deployment_id + deployment_name from here, instead this - * will be in scan_response.scan_info - *) deployment_id: int; deployment_name: string; (* ex: "audit", "comment", "block" TODO use enum? TODO: seems dead *) policy_names: string list; (* rules raw content in JSON format (but still sent as a string) *) rule_config: string; - (* since 1.47.0 but not created by the backend (nor used by the CLI) *) - ?ci_config_from_cloud: ci_config_from_cloud option; - - (* Deprecated: should rely on ci_config_from_cloud instead *) inherit features; inherit triage_ignored; (* glob patterns *) @@ -1245,8 +1239,70 @@ type scan_config = { ?enabled_products: product list option; (* since 1.64.0 *) ~actions: action list; + (* since 1.47.0 but not created by the backend (nor used by the CLI) *) + ?ci_config_from_cloud: ci_config_from_cloud option; } +(* Response from the backend to the CLI to the POST /api/cli/scans *) +type scan_response = { + info: scan_info; + config: scan_configuration; + engine_params: engine_configuration; + (* TODO: ~actions: action list; *) +} + +(* meta info about the scan *) +type scan_info = { + ?id: int option; (* the scan id, null for dry-runs *) + enabled_products: product list; + (* redundant with deployment_config? + * TODO? remove the intermediate call to get the deployment and + * start a scan to /api/cli/scans/ without first accessing + * api/agent/deployments/current? + *) + deployment_id: int; + deployment_name: string; +} + +(* config specific to the scan, eg *) +type scan_configuration = { + rules: raw_json; (* can we type this better *) + inherit triage_ignored; +} + +(* settings for the cli *) +type engine_configuration = { + inherit features; + (* TODO? glob list? fpath list? *) + ~ignored_files: string list; + (* from 1.71.0 *) + ?product_ignored_files: product_ignored_files option; + (* for features we only want to turn on for select customers *) + ~generic_slow_rollout: bool; + (* from 1.63.0 *) + ?historical_config: historical_configuration option; + (* from 1.93. + * Indicate that fail-open should always be enabled, overriding the CLI flag. + * coupling: server/semgrep_app/saas/models/deployment_products_mixin.py + *) + ~always_suppress_errors: bool; +} + +type glob = string + +type product_ignored_files = (product * glob list) list + (* We omit the usual otherwise we get a + * "keys must be strings" error *) + + +(* configuration for scanning version control history, + * e.g., looking back at past git commits for committed credentials which may + * have been removed *) +type historical_configuration = { + enabled: bool; + ?lookback_days: int option; +} + (* ----------------------------- *) (* CI Deployment response *) (* ----------------------------- *) @@ -1258,13 +1314,27 @@ type deployment_response = { (* CI Scan request *) (* ----------------------------- *) +(* Sent by the CLI to the POST /api/cli/scans to create a scan. *) +type scan_request = { + (* 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; + + (* 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; +} + (* Collect information about a project from the environment, filesystem, * git repo, etc. * See also semgrep_metrics.atd and PRIVACY.md - * - * TODO: - * - we could split it in different parts and use inherit to make things clearer - * (while still being backward compatible) + * TODO: we could split it in different parts and use inherit to make things + * clearer (while still being backward compatible) *) type project_metadata = { (* TODO: deprecate in favor of scan_metadata.cli_version *) @@ -1353,77 +1423,6 @@ type scan_metadata = { ?sms_scan_id: string option; } -(* Sent by the CLI to the POST /api/cli/scans to create a scan. *) -type scan_request = { - (* 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; - - (* 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 *) -type scan_response = { - info: scan_info; - config: scan_configuration; - engine_params: engine_configuration; -} - -(* meta info about the scan *) -type scan_info = { - ?id: int option; (* the scan id, null for dry-runs *) - enabled_products: product list; - deployment_id: int; - deployment_name: string; -} - - - -(* config specific to the scan, eg *) -type scan_configuration = { - rules: raw_json; (* can we type this better *) - inherit triage_ignored; -} - -(* configuration for scanning version control history, - * e.g., looking back at past git commits for committed credentials which may - * have been removed *) -type historical_configuration = { - enabled: bool; - ?lookback_days: int option; -} - -type glob = string - -type product_ignored_files = (product * glob list) list - (* We omit the usual otherwise we get a - * "keys must be strings" error *) - - -(* settings for the cli *) -type engine_configuration = { - inherit features; - ~ignored_files: string list; - (* from 1.71.0 *) - ?product_ignored_files: product_ignored_files option; - (* for features we only want to turn on for select customers *) - ~generic_slow_rollout: bool; - (* from 1.63.0 *) - ?historical_config: historical_configuration option; - (* from 1.93. - * Indicate that fail-open should always be enabled, overriding the CLI flag. - * coupling: server/semgrep_app/saas/models/deployment_products_mixin.py - *) - ~always_suppress_errors: bool; -} - (* ----------------------------- *) (* Findings *) (* ----------------------------- *) diff --git a/semgrep_output_v1.jsonschema b/semgrep_output_v1.jsonschema index 2368698..508773e 100644 --- a/semgrep_output_v1.jsonschema +++ b/semgrep_output_v1.jsonschema @@ -928,9 +928,6 @@ "deployment_name": { "type": "string" }, "policy_names": { "type": "array", "items": { "type": "string" } }, "rule_config": { "type": "string" }, - "ci_config_from_cloud": { - "$ref": "#/definitions/ci_config_from_cloud" - }, "autofix": { "type": "boolean" }, "deepsemgrep": { "type": "boolean" }, "dependency_query": { "type": "boolean" }, @@ -951,9 +948,89 @@ "actions": { "type": "array", "items": { "$ref": "#/definitions/action" } + }, + "ci_config_from_cloud": { + "$ref": "#/definitions/ci_config_from_cloud" } } }, + "scan_response": { + "type": "object", + "required": [ "info", "config", "engine_params" ], + "properties": { + "info": { "$ref": "#/definitions/scan_info" }, + "config": { "$ref": "#/definitions/scan_configuration" }, + "engine_params": { "$ref": "#/definitions/engine_configuration" } + } + }, + "scan_info": { + "type": "object", + "required": [ "enabled_products", "deployment_id", "deployment_name" ], + "properties": { + "id": { "type": "integer" }, + "enabled_products": { + "type": "array", + "items": { "$ref": "#/definitions/product" } + }, + "deployment_id": { "type": "integer" }, + "deployment_name": { "type": "string" } + } + }, + "scan_configuration": { + "type": "object", + "required": [ "rules" ], + "properties": { + "rules": { "$ref": "#/definitions/raw_json" }, + "triage_ignored_syntactic_ids": { + "type": "array", + "items": { "type": "string" } + }, + "triage_ignored_match_based_ids": { + "type": "array", + "items": { "type": "string" } + } + } + }, + "engine_configuration": { + "type": "object", + "required": [], + "properties": { + "autofix": { "type": "boolean" }, + "deepsemgrep": { "type": "boolean" }, + "dependency_query": { "type": "boolean" }, + "path_to_transitivity": { "type": "boolean" }, + "ignored_files": { "type": "array", "items": { "type": "string" } }, + "product_ignored_files": { + "$ref": "#/definitions/product_ignored_files" + }, + "generic_slow_rollout": { "type": "boolean" }, + "historical_config": { + "$ref": "#/definitions/historical_configuration" + }, + "always_suppress_errors": { "type": "boolean" } + } + }, + "glob": { "type": "string" }, + "product_ignored_files": { + "type": "array", + "items": { + "type": "array", + "minItems": 2, + "items": false, + "prefixItems": [ + { "$ref": "#/definitions/product" }, + { "type": "array", "items": { "$ref": "#/definitions/glob" } } + ] + } + }, + "historical_configuration": { + "type": "object", + "required": [ "enabled" ], + "properties": { + "enabled": { "type": "boolean" }, + "lookback_days": { "type": "integer" } + } + }, "deployment_response": { "type": "object", "required": [ "deployment" ], @@ -961,6 +1038,16 @@ "deployment": { "$ref": "#/definitions/deployment_config" } } }, + "scan_request": { + "type": "object", + "required": [ "project_metadata", "scan_metadata" ], + "properties": { + "project_metadata": { "$ref": "#/definitions/project_metadata" }, + "scan_metadata": { "$ref": "#/definitions/scan_metadata" }, + "project_config": { "$ref": "#/definitions/ci_config_from_repo" }, + "meta": { "$ref": "#/definitions/raw_json" } + } + }, "project_metadata": { "type": "object", "required": [ @@ -1015,93 +1102,6 @@ "sms_scan_id": { "type": "string" } } }, - "scan_request": { - "type": "object", - "required": [ "project_metadata", "scan_metadata" ], - "properties": { - "project_metadata": { "$ref": "#/definitions/project_metadata" }, - "scan_metadata": { "$ref": "#/definitions/scan_metadata" }, - "project_config": { "$ref": "#/definitions/ci_config_from_repo" }, - "meta": { "$ref": "#/definitions/raw_json" } - } - }, - "scan_response": { - "type": "object", - "required": [ "info", "config", "engine_params" ], - "properties": { - "info": { "$ref": "#/definitions/scan_info" }, - "config": { "$ref": "#/definitions/scan_configuration" }, - "engine_params": { "$ref": "#/definitions/engine_configuration" } - } - }, - "scan_info": { - "type": "object", - "required": [ "enabled_products", "deployment_id", "deployment_name" ], - "properties": { - "id": { "type": "integer" }, - "enabled_products": { - "type": "array", - "items": { "$ref": "#/definitions/product" } - }, - "deployment_id": { "type": "integer" }, - "deployment_name": { "type": "string" } - } - }, - "scan_configuration": { - "type": "object", - "required": [ "rules" ], - "properties": { - "rules": { "$ref": "#/definitions/raw_json" }, - "triage_ignored_syntactic_ids": { - "type": "array", - "items": { "type": "string" } - }, - "triage_ignored_match_based_ids": { - "type": "array", - "items": { "type": "string" } - } - } - }, - "historical_configuration": { - "type": "object", - "required": [ "enabled" ], - "properties": { - "enabled": { "type": "boolean" }, - "lookback_days": { "type": "integer" } - } - }, - "glob": { "type": "string" }, - "product_ignored_files": { - "type": "array", - "items": { - "type": "array", - "minItems": 2, - "items": false, - "prefixItems": [ - { "$ref": "#/definitions/product" }, - { "type": "array", "items": { "$ref": "#/definitions/glob" } } - ] - } - }, - "engine_configuration": { - "type": "object", - "required": [], - "properties": { - "autofix": { "type": "boolean" }, - "deepsemgrep": { "type": "boolean" }, - "dependency_query": { "type": "boolean" }, - "path_to_transitivity": { "type": "boolean" }, - "ignored_files": { "type": "array", "items": { "type": "string" } }, - "product_ignored_files": { - "$ref": "#/definitions/product_ignored_files" - }, - "generic_slow_rollout": { "type": "boolean" }, - "historical_config": { - "$ref": "#/definitions/historical_configuration" - }, - "always_suppress_errors": { "type": "boolean" } - } - }, "finding": { "type": "object", "required": [ diff --git a/semgrep_output_v1.proto b/semgrep_output_v1.proto index e8a7ab5..9396e90 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: b528a41b8d32b802921305aec117b05bf8623ba75a34ad2d8f12d1711ce89e54 +// Source file sha256 digest: 8eec7fa475dcdfa9d54dbf1a6cbc1f86731f97350d74e88bb8c9645750b0ff72 syntax = "proto3"; @@ -328,7 +328,6 @@ message ScanConfig { string deployment_name = 129624728; repeated string policy_names = 175625923; string rule_config = 403140712; - CiConfigFromCloud ci_config_from_cloud = 120268883; bool autofix = 82457874; bool deepsemgrep = 444846865; bool dependency_query = 471197362; @@ -338,12 +337,56 @@ message ScanConfig { repeated string ignored_files = 482076310; repeated google.protobuf.Any enabled_products = 447415338; repeated google.protobuf.Any actions = 91184897; + CiConfigFromCloud ci_config_from_cloud = 120268883; +} + +message ScanResponse { + ScanInfo info = 3408338; + ScanConfiguration config = 364565635; + EngineConfiguration engine_params = 411399043; +} + +message ScanInfo { + int64 id = 3205; + repeated google.protobuf.Any enabled_products = 447415338; + int64 deployment_id = 188822146; + string deployment_name = 129624728; +} + +message ScanConfiguration { + google.protobuf.Any rules = 109321335; + repeated string triage_ignored_syntactic_ids = 211590151; + repeated string triage_ignored_match_based_ids = 327942260; +} + +message EngineConfiguration { + bool autofix = 82457874; + bool deepsemgrep = 444846865; + bool dependency_query = 471197362; + bool path_to_transitivity = 52910370; + repeated string ignored_files = 482076310; + repeated google.protobuf.Any product_ignored_files = 298217262; + bool generic_slow_rollout = 78139686; + HistoricalConfiguration historical_config = 66628402; + bool always_suppress_errors = 432871568; +} + +message HistoricalConfiguration { + bool enabled = 476613995; + int64 lookback_days = 382926518; } message DeploymentResponse { DeploymentConfig deployment = 498084672; } +message ScanRequest { + ProjectMetadata project_metadata = 24255885; + ScanMetadata scan_metadata = 76122041; + CiConfigFromRepo project_config = 317758767; + google.protobuf.Any meta = 3004443; +} + message ProjectMetadata { string semgrep_version = 118812144; string scan_environment = 288669428; @@ -382,49 +425,6 @@ message ScanMetadata { string sms_scan_id = 129251445; } -message ScanRequest { - ProjectMetadata project_metadata = 24255885; - ScanMetadata scan_metadata = 76122041; - CiConfigFromRepo project_config = 317758767; - google.protobuf.Any meta = 3004443; -} - -message ScanResponse { - ScanInfo info = 3408338; - ScanConfiguration config = 364565635; - EngineConfiguration engine_params = 411399043; -} - -message ScanInfo { - int64 id = 3205; - repeated google.protobuf.Any enabled_products = 447415338; - int64 deployment_id = 188822146; - string deployment_name = 129624728; -} - -message ScanConfiguration { - google.protobuf.Any rules = 109321335; - repeated string triage_ignored_syntactic_ids = 211590151; - repeated string triage_ignored_match_based_ids = 327942260; -} - -message HistoricalConfiguration { - bool enabled = 476613995; - int64 lookback_days = 382926518; -} - -message EngineConfiguration { - bool autofix = 82457874; - bool deepsemgrep = 444846865; - bool dependency_query = 471197362; - bool path_to_transitivity = 52910370; - repeated string ignored_files = 482076310; - repeated google.protobuf.Any product_ignored_files = 298217262; - bool generic_slow_rollout = 78139686; - HistoricalConfiguration historical_config = 66628402; - bool always_suppress_errors = 432871568; -} - message Finding { string check_id = 244492357; string path = 3212859; diff --git a/semgrep_output_v1.py b/semgrep_output_v1.py index 8f473d3..53b13f1 100644 --- a/semgrep_output_v1.py +++ b/semgrep_output_v1.py @@ -5422,7 +5422,6 @@ class ScanConfig: deployment_name: str policy_names: List[str] rule_config: str - ci_config_from_cloud: Optional[CiConfigFromCloud] = None autofix: bool = field(default_factory=lambda: False) deepsemgrep: bool = field(default_factory=lambda: False) dependency_query: bool = field(default_factory=lambda: False) @@ -5432,6 +5431,7 @@ class ScanConfig: ignored_files: List[str] = field(default_factory=lambda: []) enabled_products: Optional[List[Product]] = None actions: List[Action] = field(default_factory=lambda: []) + ci_config_from_cloud: Optional[CiConfigFromCloud] = None @classmethod def from_json(cls, x: Any) -> 'ScanConfig': @@ -5441,7 +5441,6 @@ def from_json(cls, x: Any) -> 'ScanConfig': deployment_name=_atd_read_string(x['deployment_name']) if 'deployment_name' in x else _atd_missing_json_field('ScanConfig', 'deployment_name'), policy_names=_atd_read_list(_atd_read_string)(x['policy_names']) if 'policy_names' in x else _atd_missing_json_field('ScanConfig', 'policy_names'), rule_config=_atd_read_string(x['rule_config']) if 'rule_config' in x else _atd_missing_json_field('ScanConfig', 'rule_config'), - ci_config_from_cloud=CiConfigFromCloud.from_json(x['ci_config_from_cloud']) if 'ci_config_from_cloud' in x else None, autofix=_atd_read_bool(x['autofix']) if 'autofix' in x else False, deepsemgrep=_atd_read_bool(x['deepsemgrep']) if 'deepsemgrep' in x else False, dependency_query=_atd_read_bool(x['dependency_query']) if 'dependency_query' in x else False, @@ -5451,6 +5450,7 @@ def from_json(cls, x: Any) -> 'ScanConfig': ignored_files=_atd_read_list(_atd_read_string)(x['ignored_files']) if 'ignored_files' in x else [], enabled_products=_atd_read_list(Product.from_json)(x['enabled_products']) if 'enabled_products' in x else None, actions=_atd_read_list(Action.from_json)(x['actions']) if 'actions' in x else [], + ci_config_from_cloud=CiConfigFromCloud.from_json(x['ci_config_from_cloud']) if 'ci_config_from_cloud' in x else None, ) else: _atd_bad_json('ScanConfig', x) @@ -5461,8 +5461,6 @@ def to_json(self) -> Any: res['deployment_name'] = _atd_write_string(self.deployment_name) res['policy_names'] = _atd_write_list(_atd_write_string)(self.policy_names) res['rule_config'] = _atd_write_string(self.rule_config) - if self.ci_config_from_cloud is not None: - res['ci_config_from_cloud'] = (lambda x: x.to_json())(self.ci_config_from_cloud) res['autofix'] = _atd_write_bool(self.autofix) res['deepsemgrep'] = _atd_write_bool(self.deepsemgrep) res['dependency_query'] = _atd_write_bool(self.dependency_query) @@ -5473,6 +5471,8 @@ def to_json(self) -> Any: if self.enabled_products is not None: res['enabled_products'] = _atd_write_list((lambda x: x.to_json()))(self.enabled_products) res['actions'] = _atd_write_list((lambda x: x.to_json()))(self.actions) + if self.ci_config_from_cloud is not None: + res['ci_config_from_cloud'] = (lambda x: x.to_json())(self.ci_config_from_cloud) return res @classmethod diff --git a/semgrep_output_v1.ts b/semgrep_output_v1.ts index 6209cf6..64cf645 100644 --- a/semgrep_output_v1.ts +++ b/semgrep_output_v1.ts @@ -506,7 +506,6 @@ export type ScanConfig = { deployment_name: string; policy_names: string[]; rule_config: string; - ci_config_from_cloud?: CiConfigFromCloud; autofix: boolean; deepsemgrep: boolean; dependency_query: boolean; @@ -516,12 +515,60 @@ export type ScanConfig = { ignored_files: string[]; enabled_products?: Product[]; actions: Action[]; + ci_config_from_cloud?: CiConfigFromCloud; +} + +export type ScanResponse = { + info: ScanInfo; + config: ScanConfiguration; + engine_params: EngineConfiguration; +} + +export type ScanInfo = { + id?: number /*int*/; + enabled_products: Product[]; + deployment_id: number /*int*/; + deployment_name: string; +} + +export type ScanConfiguration = { + rules: RawJson; + triage_ignored_syntactic_ids: string[]; + triage_ignored_match_based_ids: string[]; +} + +export type EngineConfiguration = { + autofix: boolean; + deepsemgrep: boolean; + dependency_query: boolean; + path_to_transitivity: boolean; + ignored_files: string[]; + product_ignored_files?: ProductIgnoredFiles; + generic_slow_rollout: boolean; + historical_config?: HistoricalConfiguration; + always_suppress_errors: boolean; +} + +export type Glob = string + +export type ProductIgnoredFiles = Map + +export type HistoricalConfiguration = { + enabled: boolean; + lookback_days?: number /*int*/; } export type DeploymentResponse = { deployment: DeploymentConfig; } +export type ScanRequest = { + project_metadata: ProjectMetadata; + scan_metadata: ScanMetadata; + project_config?: CiConfigFromRepo; + meta?: RawJson; +} + export type ProjectMetadata = { semgrep_version: Version; scan_environment: string; @@ -560,53 +607,6 @@ export type ScanMetadata = { sms_scan_id?: string; } -export type ScanRequest = { - project_metadata: ProjectMetadata; - scan_metadata: ScanMetadata; - project_config?: CiConfigFromRepo; - meta?: RawJson; -} - -export type ScanResponse = { - info: ScanInfo; - config: ScanConfiguration; - engine_params: EngineConfiguration; -} - -export type ScanInfo = { - id?: number /*int*/; - enabled_products: Product[]; - deployment_id: number /*int*/; - deployment_name: string; -} - -export type ScanConfiguration = { - rules: RawJson; - triage_ignored_syntactic_ids: string[]; - triage_ignored_match_based_ids: string[]; -} - -export type HistoricalConfiguration = { - enabled: boolean; - lookback_days?: number /*int*/; -} - -export type Glob = string - -export type ProductIgnoredFiles = Map - -export type EngineConfiguration = { - autofix: boolean; - deepsemgrep: boolean; - dependency_query: boolean; - path_to_transitivity: boolean; - ignored_files: string[]; - product_ignored_files?: ProductIgnoredFiles; - generic_slow_rollout: boolean; - historical_config?: HistoricalConfiguration; - always_suppress_errors: boolean; -} - export type Finding = { check_id: RuleId; path: Fpath; @@ -2646,7 +2646,6 @@ export function writeScanConfig(x: ScanConfig, context: any = x): any { 'deployment_name': _atd_write_required_field('ScanConfig', 'deployment_name', _atd_write_string, x.deployment_name, x), 'policy_names': _atd_write_required_field('ScanConfig', 'policy_names', _atd_write_array(_atd_write_string), x.policy_names, x), 'rule_config': _atd_write_required_field('ScanConfig', 'rule_config', _atd_write_string, x.rule_config, x), - 'ci_config_from_cloud': _atd_write_optional_field(writeCiConfigFromCloud, x.ci_config_from_cloud, x), 'autofix': _atd_write_field_with_default(_atd_write_bool, false, x.autofix, x), 'deepsemgrep': _atd_write_field_with_default(_atd_write_bool, false, x.deepsemgrep, x), 'dependency_query': _atd_write_field_with_default(_atd_write_bool, false, x.dependency_query, x), @@ -2656,6 +2655,7 @@ export function writeScanConfig(x: ScanConfig, context: any = x): any { 'ignored_files': _atd_write_field_with_default(_atd_write_array(_atd_write_string), [], x.ignored_files, x), 'enabled_products': _atd_write_optional_field(_atd_write_array(writeProduct), x.enabled_products, x), 'actions': _atd_write_field_with_default(_atd_write_array(writeAction), [], x.actions, x), + 'ci_config_from_cloud': _atd_write_optional_field(writeCiConfigFromCloud, x.ci_config_from_cloud, x), }; } @@ -2665,7 +2665,6 @@ export function readScanConfig(x: any, context: any = x): ScanConfig { deployment_name: _atd_read_required_field('ScanConfig', 'deployment_name', _atd_read_string, x['deployment_name'], x), policy_names: _atd_read_required_field('ScanConfig', 'policy_names', _atd_read_array(_atd_read_string), x['policy_names'], x), rule_config: _atd_read_required_field('ScanConfig', 'rule_config', _atd_read_string, x['rule_config'], x), - ci_config_from_cloud: _atd_read_optional_field(readCiConfigFromCloud, x['ci_config_from_cloud'], x), autofix: _atd_read_field_with_default(_atd_read_bool, false, x['autofix'], x), deepsemgrep: _atd_read_field_with_default(_atd_read_bool, false, x['deepsemgrep'], x), dependency_query: _atd_read_field_with_default(_atd_read_bool, false, x['dependency_query'], x), @@ -2675,6 +2674,115 @@ export function readScanConfig(x: any, context: any = x): ScanConfig { ignored_files: _atd_read_field_with_default(_atd_read_array(_atd_read_string), [], x['ignored_files'], x), enabled_products: _atd_read_optional_field(_atd_read_array(readProduct), x['enabled_products'], x), actions: _atd_read_field_with_default(_atd_read_array(readAction), [], x['actions'], x), + ci_config_from_cloud: _atd_read_optional_field(readCiConfigFromCloud, x['ci_config_from_cloud'], x), + }; +} + +export function writeScanResponse(x: ScanResponse, context: any = x): any { + return { + 'info': _atd_write_required_field('ScanResponse', 'info', writeScanInfo, x.info, x), + 'config': _atd_write_required_field('ScanResponse', 'config', writeScanConfiguration, x.config, x), + 'engine_params': _atd_write_required_field('ScanResponse', 'engine_params', writeEngineConfiguration, x.engine_params, x), + }; +} + +export function readScanResponse(x: any, context: any = x): ScanResponse { + return { + info: _atd_read_required_field('ScanResponse', 'info', readScanInfo, x['info'], x), + config: _atd_read_required_field('ScanResponse', 'config', readScanConfiguration, x['config'], x), + engine_params: _atd_read_required_field('ScanResponse', 'engine_params', readEngineConfiguration, x['engine_params'], x), + }; +} + +export function writeScanInfo(x: ScanInfo, context: any = x): any { + return { + 'id': _atd_write_optional_field(_atd_write_int, x.id, x), + 'enabled_products': _atd_write_required_field('ScanInfo', 'enabled_products', _atd_write_array(writeProduct), x.enabled_products, x), + 'deployment_id': _atd_write_required_field('ScanInfo', 'deployment_id', _atd_write_int, x.deployment_id, x), + 'deployment_name': _atd_write_required_field('ScanInfo', 'deployment_name', _atd_write_string, x.deployment_name, x), + }; +} + +export function readScanInfo(x: any, context: any = x): ScanInfo { + return { + id: _atd_read_optional_field(_atd_read_int, x['id'], x), + enabled_products: _atd_read_required_field('ScanInfo', 'enabled_products', _atd_read_array(readProduct), x['enabled_products'], x), + deployment_id: _atd_read_required_field('ScanInfo', 'deployment_id', _atd_read_int, x['deployment_id'], x), + deployment_name: _atd_read_required_field('ScanInfo', 'deployment_name', _atd_read_string, x['deployment_name'], x), + }; +} + +export function writeScanConfiguration(x: ScanConfiguration, context: any = x): any { + return { + 'rules': _atd_write_required_field('ScanConfiguration', 'rules', writeRawJson, x.rules, x), + 'triage_ignored_syntactic_ids': _atd_write_field_with_default(_atd_write_array(_atd_write_string), [], x.triage_ignored_syntactic_ids, x), + 'triage_ignored_match_based_ids': _atd_write_field_with_default(_atd_write_array(_atd_write_string), [], x.triage_ignored_match_based_ids, x), + }; +} + +export function readScanConfiguration(x: any, context: any = x): ScanConfiguration { + return { + rules: _atd_read_required_field('ScanConfiguration', 'rules', readRawJson, x['rules'], x), + triage_ignored_syntactic_ids: _atd_read_field_with_default(_atd_read_array(_atd_read_string), [], x['triage_ignored_syntactic_ids'], x), + triage_ignored_match_based_ids: _atd_read_field_with_default(_atd_read_array(_atd_read_string), [], x['triage_ignored_match_based_ids'], x), + }; +} + +export function writeEngineConfiguration(x: EngineConfiguration, context: any = x): any { + return { + 'autofix': _atd_write_field_with_default(_atd_write_bool, false, x.autofix, x), + 'deepsemgrep': _atd_write_field_with_default(_atd_write_bool, false, x.deepsemgrep, x), + 'dependency_query': _atd_write_field_with_default(_atd_write_bool, false, x.dependency_query, x), + 'path_to_transitivity': _atd_write_field_with_default(_atd_write_bool, false, x.path_to_transitivity, x), + 'ignored_files': _atd_write_field_with_default(_atd_write_array(_atd_write_string), [], x.ignored_files, x), + 'product_ignored_files': _atd_write_optional_field(writeProductIgnoredFiles, x.product_ignored_files, x), + 'generic_slow_rollout': _atd_write_field_with_default(_atd_write_bool, false, x.generic_slow_rollout, x), + 'historical_config': _atd_write_optional_field(writeHistoricalConfiguration, x.historical_config, x), + 'always_suppress_errors': _atd_write_field_with_default(_atd_write_bool, false, x.always_suppress_errors, x), + }; +} + +export function readEngineConfiguration(x: any, context: any = x): EngineConfiguration { + return { + autofix: _atd_read_field_with_default(_atd_read_bool, false, x['autofix'], x), + deepsemgrep: _atd_read_field_with_default(_atd_read_bool, false, x['deepsemgrep'], x), + dependency_query: _atd_read_field_with_default(_atd_read_bool, false, x['dependency_query'], x), + path_to_transitivity: _atd_read_field_with_default(_atd_read_bool, false, x['path_to_transitivity'], x), + ignored_files: _atd_read_field_with_default(_atd_read_array(_atd_read_string), [], x['ignored_files'], x), + product_ignored_files: _atd_read_optional_field(readProductIgnoredFiles, x['product_ignored_files'], x), + generic_slow_rollout: _atd_read_field_with_default(_atd_read_bool, false, x['generic_slow_rollout'], x), + historical_config: _atd_read_optional_field(readHistoricalConfiguration, x['historical_config'], x), + always_suppress_errors: _atd_read_field_with_default(_atd_read_bool, false, x['always_suppress_errors'], x), + }; +} + +export function writeGlob(x: Glob, context: any = x): any { + return _atd_write_string(x, context); +} + +export function readGlob(x: any, context: any = x): Glob { + return _atd_read_string(x, context); +} + +export function writeProductIgnoredFiles(x: ProductIgnoredFiles, context: any = x): any { + return _atd_write_assoc_map_to_array(writeProduct, _atd_write_array(writeGlob))(x, context); +} + +export function readProductIgnoredFiles(x: any, context: any = x): ProductIgnoredFiles { + return _atd_read_assoc_array_into_map(readProduct, _atd_read_array(readGlob))(x, context); +} + +export function writeHistoricalConfiguration(x: HistoricalConfiguration, context: any = x): any { + return { + 'enabled': _atd_write_required_field('HistoricalConfiguration', 'enabled', _atd_write_bool, x.enabled, x), + 'lookback_days': _atd_write_optional_field(_atd_write_int, x.lookback_days, x), + }; +} + +export function readHistoricalConfiguration(x: any, context: any = x): HistoricalConfiguration { + return { + enabled: _atd_read_required_field('HistoricalConfiguration', 'enabled', _atd_read_bool, x['enabled'], x), + lookback_days: _atd_read_optional_field(_atd_read_int, x['lookback_days'], x), }; } @@ -2690,6 +2798,24 @@ export function readDeploymentResponse(x: any, context: any = x): DeploymentResp }; } +export function writeScanRequest(x: ScanRequest, context: any = x): any { + return { + '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), + 'meta': _atd_write_optional_field(writeRawJson, x.meta, x), + }; +} + +export function readScanRequest(x: any, context: any = x): ScanRequest { + return { + 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), + meta: _atd_read_optional_field(readRawJson, x['meta'], x), + }; +} + export function writeProjectMetadata(x: ProjectMetadata, context: any = x): any { return { 'semgrep_version': _atd_write_required_field('ProjectMetadata', 'semgrep_version', writeVersion, x.semgrep_version, x), @@ -2774,132 +2900,6 @@ export function readScanMetadata(x: any, context: any = x): ScanMetadata { }; } -export function writeScanRequest(x: ScanRequest, context: any = x): any { - return { - '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), - 'meta': _atd_write_optional_field(writeRawJson, x.meta, x), - }; -} - -export function readScanRequest(x: any, context: any = x): ScanRequest { - return { - 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), - meta: _atd_read_optional_field(readRawJson, x['meta'], x), - }; -} - -export function writeScanResponse(x: ScanResponse, context: any = x): any { - return { - 'info': _atd_write_required_field('ScanResponse', 'info', writeScanInfo, x.info, x), - 'config': _atd_write_required_field('ScanResponse', 'config', writeScanConfiguration, x.config, x), - 'engine_params': _atd_write_required_field('ScanResponse', 'engine_params', writeEngineConfiguration, x.engine_params, x), - }; -} - -export function readScanResponse(x: any, context: any = x): ScanResponse { - return { - info: _atd_read_required_field('ScanResponse', 'info', readScanInfo, x['info'], x), - config: _atd_read_required_field('ScanResponse', 'config', readScanConfiguration, x['config'], x), - engine_params: _atd_read_required_field('ScanResponse', 'engine_params', readEngineConfiguration, x['engine_params'], x), - }; -} - -export function writeScanInfo(x: ScanInfo, context: any = x): any { - return { - 'id': _atd_write_optional_field(_atd_write_int, x.id, x), - 'enabled_products': _atd_write_required_field('ScanInfo', 'enabled_products', _atd_write_array(writeProduct), x.enabled_products, x), - 'deployment_id': _atd_write_required_field('ScanInfo', 'deployment_id', _atd_write_int, x.deployment_id, x), - 'deployment_name': _atd_write_required_field('ScanInfo', 'deployment_name', _atd_write_string, x.deployment_name, x), - }; -} - -export function readScanInfo(x: any, context: any = x): ScanInfo { - return { - id: _atd_read_optional_field(_atd_read_int, x['id'], x), - enabled_products: _atd_read_required_field('ScanInfo', 'enabled_products', _atd_read_array(readProduct), x['enabled_products'], x), - deployment_id: _atd_read_required_field('ScanInfo', 'deployment_id', _atd_read_int, x['deployment_id'], x), - deployment_name: _atd_read_required_field('ScanInfo', 'deployment_name', _atd_read_string, x['deployment_name'], x), - }; -} - -export function writeScanConfiguration(x: ScanConfiguration, context: any = x): any { - return { - 'rules': _atd_write_required_field('ScanConfiguration', 'rules', writeRawJson, x.rules, x), - 'triage_ignored_syntactic_ids': _atd_write_field_with_default(_atd_write_array(_atd_write_string), [], x.triage_ignored_syntactic_ids, x), - 'triage_ignored_match_based_ids': _atd_write_field_with_default(_atd_write_array(_atd_write_string), [], x.triage_ignored_match_based_ids, x), - }; -} - -export function readScanConfiguration(x: any, context: any = x): ScanConfiguration { - return { - rules: _atd_read_required_field('ScanConfiguration', 'rules', readRawJson, x['rules'], x), - triage_ignored_syntactic_ids: _atd_read_field_with_default(_atd_read_array(_atd_read_string), [], x['triage_ignored_syntactic_ids'], x), - triage_ignored_match_based_ids: _atd_read_field_with_default(_atd_read_array(_atd_read_string), [], x['triage_ignored_match_based_ids'], x), - }; -} - -export function writeHistoricalConfiguration(x: HistoricalConfiguration, context: any = x): any { - return { - 'enabled': _atd_write_required_field('HistoricalConfiguration', 'enabled', _atd_write_bool, x.enabled, x), - 'lookback_days': _atd_write_optional_field(_atd_write_int, x.lookback_days, x), - }; -} - -export function readHistoricalConfiguration(x: any, context: any = x): HistoricalConfiguration { - return { - enabled: _atd_read_required_field('HistoricalConfiguration', 'enabled', _atd_read_bool, x['enabled'], x), - lookback_days: _atd_read_optional_field(_atd_read_int, x['lookback_days'], x), - }; -} - -export function writeGlob(x: Glob, context: any = x): any { - return _atd_write_string(x, context); -} - -export function readGlob(x: any, context: any = x): Glob { - return _atd_read_string(x, context); -} - -export function writeProductIgnoredFiles(x: ProductIgnoredFiles, context: any = x): any { - return _atd_write_assoc_map_to_array(writeProduct, _atd_write_array(writeGlob))(x, context); -} - -export function readProductIgnoredFiles(x: any, context: any = x): ProductIgnoredFiles { - return _atd_read_assoc_array_into_map(readProduct, _atd_read_array(readGlob))(x, context); -} - -export function writeEngineConfiguration(x: EngineConfiguration, context: any = x): any { - return { - 'autofix': _atd_write_field_with_default(_atd_write_bool, false, x.autofix, x), - 'deepsemgrep': _atd_write_field_with_default(_atd_write_bool, false, x.deepsemgrep, x), - 'dependency_query': _atd_write_field_with_default(_atd_write_bool, false, x.dependency_query, x), - 'path_to_transitivity': _atd_write_field_with_default(_atd_write_bool, false, x.path_to_transitivity, x), - 'ignored_files': _atd_write_field_with_default(_atd_write_array(_atd_write_string), [], x.ignored_files, x), - 'product_ignored_files': _atd_write_optional_field(writeProductIgnoredFiles, x.product_ignored_files, x), - 'generic_slow_rollout': _atd_write_field_with_default(_atd_write_bool, false, x.generic_slow_rollout, x), - 'historical_config': _atd_write_optional_field(writeHistoricalConfiguration, x.historical_config, x), - 'always_suppress_errors': _atd_write_field_with_default(_atd_write_bool, false, x.always_suppress_errors, x), - }; -} - -export function readEngineConfiguration(x: any, context: any = x): EngineConfiguration { - return { - autofix: _atd_read_field_with_default(_atd_read_bool, false, x['autofix'], x), - deepsemgrep: _atd_read_field_with_default(_atd_read_bool, false, x['deepsemgrep'], x), - dependency_query: _atd_read_field_with_default(_atd_read_bool, false, x['dependency_query'], x), - path_to_transitivity: _atd_read_field_with_default(_atd_read_bool, false, x['path_to_transitivity'], x), - ignored_files: _atd_read_field_with_default(_atd_read_array(_atd_read_string), [], x['ignored_files'], x), - product_ignored_files: _atd_read_optional_field(readProductIgnoredFiles, x['product_ignored_files'], x), - generic_slow_rollout: _atd_read_field_with_default(_atd_read_bool, false, x['generic_slow_rollout'], x), - historical_config: _atd_read_optional_field(readHistoricalConfiguration, x['historical_config'], x), - always_suppress_errors: _atd_read_field_with_default(_atd_read_bool, false, x['always_suppress_errors'], x), - }; -} - export function writeFinding(x: Finding, context: any = x): any { return { 'check_id': _atd_write_required_field('Finding', 'check_id', writeRuleId, x.check_id, x), diff --git a/semgrep_output_v1_j.ml b/semgrep_output_v1_j.ml index ed759d3..89bc7df 100644 --- a/semgrep_output_v1_j.ml +++ b/semgrep_output_v1_j.ml @@ -475,7 +475,6 @@ type scan_config = Semgrep_output_v1_t.scan_config = { deployment_name: string; policy_names: string list; rule_config: string; - ci_config_from_cloud: ci_config_from_cloud option; autofix: bool; deepsemgrep: bool; dependency_query: bool; @@ -484,7 +483,8 @@ type scan_config = Semgrep_output_v1_t.scan_config = { triage_ignored_match_based_ids: string list; ignored_files: string list; enabled_products: product list option; - actions: action list + actions: action list; + ci_config_from_cloud: ci_config_from_cloud option } type sca_parser_name = Semgrep_output_v1_t.sca_parser_name @@ -18284,17 +18284,6 @@ let write_scan_config : _ -> scan_config -> _ = ( Yojson.Safe.write_string ) ob x.rule_config; - (match x.ci_config_from_cloud with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"ci_config_from_cloud\":"; - ( - write_ci_config_from_cloud - ) - ob x; - ); if !is_first then is_first := false else @@ -18378,6 +18367,17 @@ let write_scan_config : _ -> scan_config -> _ = ( write__action_list ) ob x.actions; + (match x.ci_config_from_cloud with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"ci_config_from_cloud\":"; + ( + write_ci_config_from_cloud + ) + ob x; + ); Buffer.add_char ob '}'; ) let string_of_scan_config ?(len = 1024) x = @@ -18392,7 +18392,6 @@ let read_scan_config = ( let field_deployment_name = ref (None) in let field_policy_names = ref (None) in let field_rule_config = ref (None) in - let field_ci_config_from_cloud = ref (None) in let field_autofix = ref (false) in let field_deepsemgrep = ref (false) in let field_dependency_query = ref (false) in @@ -18402,6 +18401,7 @@ let read_scan_config = ( let field_ignored_files = ref ([]) in let field_enabled_products = ref (None) in let field_actions = ref ([]) in + let field_ci_config_from_cloud = ref (None) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; @@ -18416,7 +18416,7 @@ let read_scan_config = ( match String.unsafe_get s (pos+1) with | 'c' -> ( if String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 's' then ( - 13 + 12 ) else ( -1 @@ -18424,7 +18424,7 @@ let read_scan_config = ( ) | 'u' -> ( if String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'o' && String.unsafe_get s (pos+4) = 'f' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'x' then ( - 5 + 4 ) else ( -1 @@ -18442,7 +18442,7 @@ let read_scan_config = ( match String.unsafe_get s pos with | 'd' -> ( if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 's' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'g' && String.unsafe_get s (pos+8) = 'r' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 'p' then ( - 6 + 5 ) else ( -1 @@ -18480,7 +18480,7 @@ let read_scan_config = ( ) | 'i' -> ( if String.unsafe_get s (pos+1) = 'g' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'o' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'd' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'f' && String.unsafe_get s (pos+9) = 'i' && String.unsafe_get s (pos+10) = 'l' && String.unsafe_get s (pos+11) = 'e' && String.unsafe_get s (pos+12) = 's' then ( - 11 + 10 ) else ( -1 @@ -18502,7 +18502,7 @@ let read_scan_config = ( match String.unsafe_get s pos with | 'd' -> ( if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'c' && String.unsafe_get s (pos+9) = 'y' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'q' && String.unsafe_get s (pos+12) = 'u' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 'r' && String.unsafe_get s (pos+15) = 'y' then ( - 7 + 6 ) else ( -1 @@ -18510,7 +18510,7 @@ let read_scan_config = ( ) | 'e' -> ( if String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'b' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'd' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'p' && String.unsafe_get s (pos+9) = 'r' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'd' && String.unsafe_get s (pos+12) = 'u' && String.unsafe_get s (pos+13) = 'c' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 's' then ( - 12 + 11 ) else ( -1 @@ -18524,7 +18524,7 @@ let read_scan_config = ( match String.unsafe_get s pos with | 'c' -> ( if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'f' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'g' && String.unsafe_get s (pos+9) = '_' && String.unsafe_get s (pos+10) = 'f' && String.unsafe_get s (pos+11) = 'r' && String.unsafe_get s (pos+12) = 'o' && String.unsafe_get s (pos+13) = 'm' && String.unsafe_get s (pos+14) = '_' && String.unsafe_get s (pos+15) = 'c' && String.unsafe_get s (pos+16) = 'l' && String.unsafe_get s (pos+17) = 'o' && String.unsafe_get s (pos+18) = 'u' && String.unsafe_get s (pos+19) = 'd' then ( - 4 + 13 ) else ( -1 @@ -18532,7 +18532,7 @@ let read_scan_config = ( ) | 'p' -> ( if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'r' && String.unsafe_get s (pos+10) = 'a' && String.unsafe_get s (pos+11) = 'n' && String.unsafe_get s (pos+12) = 's' && String.unsafe_get s (pos+13) = 'i' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'i' && String.unsafe_get s (pos+16) = 'v' && String.unsafe_get s (pos+17) = 'i' && String.unsafe_get s (pos+18) = 't' && String.unsafe_get s (pos+19) = 'y' then ( - 8 + 7 ) else ( -1 @@ -18544,7 +18544,7 @@ let read_scan_config = ( ) | 28 -> ( if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'g' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'g' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'r' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'd' && String.unsafe_get s (pos+14) = '_' && String.unsafe_get s (pos+15) = 's' && String.unsafe_get s (pos+16) = 'y' && String.unsafe_get s (pos+17) = 'n' && String.unsafe_get s (pos+18) = 't' && String.unsafe_get s (pos+19) = 'a' && String.unsafe_get s (pos+20) = 'c' && String.unsafe_get s (pos+21) = 't' && String.unsafe_get s (pos+22) = 'i' && String.unsafe_get s (pos+23) = 'c' && String.unsafe_get s (pos+24) = '_' && String.unsafe_get s (pos+25) = 'i' && String.unsafe_get s (pos+26) = 'd' && String.unsafe_get s (pos+27) = 's' then ( - 9 + 8 ) else ( -1 @@ -18552,7 +18552,7 @@ let read_scan_config = ( ) | 30 -> ( if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'g' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'g' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'r' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'd' && String.unsafe_get s (pos+14) = '_' && String.unsafe_get s (pos+15) = 'm' && String.unsafe_get s (pos+16) = 'a' && String.unsafe_get s (pos+17) = 't' && String.unsafe_get s (pos+18) = 'c' && String.unsafe_get s (pos+19) = 'h' && String.unsafe_get s (pos+20) = '_' && String.unsafe_get s (pos+21) = 'b' && String.unsafe_get s (pos+22) = 'a' && String.unsafe_get s (pos+23) = 's' && String.unsafe_get s (pos+24) = 'e' && String.unsafe_get s (pos+25) = 'd' && String.unsafe_get s (pos+26) = '_' && String.unsafe_get s (pos+27) = 'i' && String.unsafe_get s (pos+28) = 'd' && String.unsafe_get s (pos+29) = 's' then ( - 10 + 9 ) else ( -1 @@ -18599,16 +18599,6 @@ let read_scan_config = ( ) ); | 4 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_ci_config_from_cloud := ( - Some ( - ( - read_ci_config_from_cloud - ) p lb - ) - ); - ) - | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_autofix := ( ( @@ -18616,7 +18606,7 @@ let read_scan_config = ( ) p lb ); ) - | 6 -> + | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_deepsemgrep := ( ( @@ -18624,7 +18614,7 @@ let read_scan_config = ( ) p lb ); ) - | 7 -> + | 6 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_dependency_query := ( ( @@ -18632,7 +18622,7 @@ let read_scan_config = ( ) p lb ); ) - | 8 -> + | 7 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_path_to_transitivity := ( ( @@ -18640,7 +18630,7 @@ let read_scan_config = ( ) p lb ); ) - | 9 -> + | 8 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_triage_ignored_syntactic_ids := ( ( @@ -18648,7 +18638,7 @@ let read_scan_config = ( ) p lb ); ) - | 10 -> + | 9 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_triage_ignored_match_based_ids := ( ( @@ -18656,7 +18646,7 @@ let read_scan_config = ( ) p lb ); ) - | 11 -> + | 10 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_ignored_files := ( ( @@ -18664,7 +18654,7 @@ let read_scan_config = ( ) p lb ); ) - | 12 -> + | 11 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_enabled_products := ( Some ( @@ -18674,7 +18664,7 @@ let read_scan_config = ( ) ); ) - | 13 -> + | 12 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_actions := ( ( @@ -18682,6 +18672,16 @@ let read_scan_config = ( ) p lb ); ) + | 13 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_ci_config_from_cloud := ( + Some ( + ( + read_ci_config_from_cloud + ) p lb + ) + ); + ) | _ -> ( Yojson.Safe.skip_json p lb ) @@ -18700,7 +18700,7 @@ let read_scan_config = ( match String.unsafe_get s (pos+1) with | 'c' -> ( if String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 's' then ( - 13 + 12 ) else ( -1 @@ -18708,7 +18708,7 @@ let read_scan_config = ( ) | 'u' -> ( if String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'o' && String.unsafe_get s (pos+4) = 'f' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'x' then ( - 5 + 4 ) else ( -1 @@ -18726,7 +18726,7 @@ let read_scan_config = ( match String.unsafe_get s pos with | 'd' -> ( if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 's' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'g' && String.unsafe_get s (pos+8) = 'r' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 'p' then ( - 6 + 5 ) else ( -1 @@ -18764,7 +18764,7 @@ let read_scan_config = ( ) | 'i' -> ( if String.unsafe_get s (pos+1) = 'g' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'o' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'd' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'f' && String.unsafe_get s (pos+9) = 'i' && String.unsafe_get s (pos+10) = 'l' && String.unsafe_get s (pos+11) = 'e' && String.unsafe_get s (pos+12) = 's' then ( - 11 + 10 ) else ( -1 @@ -18786,7 +18786,7 @@ let read_scan_config = ( match String.unsafe_get s pos with | 'd' -> ( if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'c' && String.unsafe_get s (pos+9) = 'y' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'q' && String.unsafe_get s (pos+12) = 'u' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 'r' && String.unsafe_get s (pos+15) = 'y' then ( - 7 + 6 ) else ( -1 @@ -18794,7 +18794,7 @@ let read_scan_config = ( ) | 'e' -> ( if String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'b' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'd' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'p' && String.unsafe_get s (pos+9) = 'r' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'd' && String.unsafe_get s (pos+12) = 'u' && String.unsafe_get s (pos+13) = 'c' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 's' then ( - 12 + 11 ) else ( -1 @@ -18808,7 +18808,7 @@ let read_scan_config = ( match String.unsafe_get s pos with | 'c' -> ( if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'f' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'g' && String.unsafe_get s (pos+9) = '_' && String.unsafe_get s (pos+10) = 'f' && String.unsafe_get s (pos+11) = 'r' && String.unsafe_get s (pos+12) = 'o' && String.unsafe_get s (pos+13) = 'm' && String.unsafe_get s (pos+14) = '_' && String.unsafe_get s (pos+15) = 'c' && String.unsafe_get s (pos+16) = 'l' && String.unsafe_get s (pos+17) = 'o' && String.unsafe_get s (pos+18) = 'u' && String.unsafe_get s (pos+19) = 'd' then ( - 4 + 13 ) else ( -1 @@ -18816,7 +18816,7 @@ let read_scan_config = ( ) | 'p' -> ( if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'r' && String.unsafe_get s (pos+10) = 'a' && String.unsafe_get s (pos+11) = 'n' && String.unsafe_get s (pos+12) = 's' && String.unsafe_get s (pos+13) = 'i' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'i' && String.unsafe_get s (pos+16) = 'v' && String.unsafe_get s (pos+17) = 'i' && String.unsafe_get s (pos+18) = 't' && String.unsafe_get s (pos+19) = 'y' then ( - 8 + 7 ) else ( -1 @@ -18828,7 +18828,7 @@ let read_scan_config = ( ) | 28 -> ( if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'g' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'g' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'r' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'd' && String.unsafe_get s (pos+14) = '_' && String.unsafe_get s (pos+15) = 's' && String.unsafe_get s (pos+16) = 'y' && String.unsafe_get s (pos+17) = 'n' && String.unsafe_get s (pos+18) = 't' && String.unsafe_get s (pos+19) = 'a' && String.unsafe_get s (pos+20) = 'c' && String.unsafe_get s (pos+21) = 't' && String.unsafe_get s (pos+22) = 'i' && String.unsafe_get s (pos+23) = 'c' && String.unsafe_get s (pos+24) = '_' && String.unsafe_get s (pos+25) = 'i' && String.unsafe_get s (pos+26) = 'd' && String.unsafe_get s (pos+27) = 's' then ( - 9 + 8 ) else ( -1 @@ -18836,7 +18836,7 @@ let read_scan_config = ( ) | 30 -> ( if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'g' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'g' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'r' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'd' && String.unsafe_get s (pos+14) = '_' && String.unsafe_get s (pos+15) = 'm' && String.unsafe_get s (pos+16) = 'a' && String.unsafe_get s (pos+17) = 't' && String.unsafe_get s (pos+18) = 'c' && String.unsafe_get s (pos+19) = 'h' && String.unsafe_get s (pos+20) = '_' && String.unsafe_get s (pos+21) = 'b' && String.unsafe_get s (pos+22) = 'a' && String.unsafe_get s (pos+23) = 's' && String.unsafe_get s (pos+24) = 'e' && String.unsafe_get s (pos+25) = 'd' && String.unsafe_get s (pos+26) = '_' && String.unsafe_get s (pos+27) = 'i' && String.unsafe_get s (pos+28) = 'd' && String.unsafe_get s (pos+29) = 's' then ( - 10 + 9 ) else ( -1 @@ -18883,16 +18883,6 @@ let read_scan_config = ( ) ); | 4 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_ci_config_from_cloud := ( - Some ( - ( - read_ci_config_from_cloud - ) p lb - ) - ); - ) - | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_autofix := ( ( @@ -18900,7 +18890,7 @@ let read_scan_config = ( ) p lb ); ) - | 6 -> + | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_deepsemgrep := ( ( @@ -18908,7 +18898,7 @@ let read_scan_config = ( ) p lb ); ) - | 7 -> + | 6 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_dependency_query := ( ( @@ -18916,7 +18906,7 @@ let read_scan_config = ( ) p lb ); ) - | 8 -> + | 7 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_path_to_transitivity := ( ( @@ -18924,7 +18914,7 @@ let read_scan_config = ( ) p lb ); ) - | 9 -> + | 8 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_triage_ignored_syntactic_ids := ( ( @@ -18932,7 +18922,7 @@ let read_scan_config = ( ) p lb ); ) - | 10 -> + | 9 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_triage_ignored_match_based_ids := ( ( @@ -18940,7 +18930,7 @@ let read_scan_config = ( ) p lb ); ) - | 11 -> + | 10 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_ignored_files := ( ( @@ -18948,7 +18938,7 @@ let read_scan_config = ( ) p lb ); ) - | 12 -> + | 11 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_enabled_products := ( Some ( @@ -18958,7 +18948,7 @@ let read_scan_config = ( ) ); ) - | 13 -> + | 12 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_actions := ( ( @@ -18966,6 +18956,16 @@ let read_scan_config = ( ) p lb ); ) + | 13 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_ci_config_from_cloud := ( + Some ( + ( + read_ci_config_from_cloud + ) p lb + ) + ); + ) | _ -> ( Yojson.Safe.skip_json p lb ) @@ -18979,7 +18979,6 @@ let read_scan_config = ( deployment_name = (match !field_deployment_name with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_name"); policy_names = (match !field_policy_names with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "policy_names"); rule_config = (match !field_rule_config with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "rule_config"); - ci_config_from_cloud = !field_ci_config_from_cloud; autofix = !field_autofix; deepsemgrep = !field_deepsemgrep; dependency_query = !field_dependency_query; @@ -18989,6 +18988,7 @@ let read_scan_config = ( ignored_files = !field_ignored_files; enabled_products = !field_enabled_products; actions = !field_actions; + ci_config_from_cloud = !field_ci_config_from_cloud; } : scan_config) ) diff --git a/semgrep_output_v1_j.mli b/semgrep_output_v1_j.mli index 92a2440..aac9526 100644 --- a/semgrep_output_v1_j.mli +++ b/semgrep_output_v1_j.mli @@ -475,7 +475,6 @@ type scan_config = Semgrep_output_v1_t.scan_config = { deployment_name: string; policy_names: string list; rule_config: string; - ci_config_from_cloud: ci_config_from_cloud option; autofix: bool; deepsemgrep: bool; dependency_query: bool; @@ -484,7 +483,8 @@ type scan_config = Semgrep_output_v1_t.scan_config = { triage_ignored_match_based_ids: string list; ignored_files: string list; enabled_products: product list option; - actions: action list + actions: action list; + ci_config_from_cloud: ci_config_from_cloud option } type sca_parser_name = Semgrep_output_v1_t.sca_parser_name From b54e43b4afaeab44bb0c99004272292d8549953a Mon Sep 17 00:00:00 2001 From: Yoann Padioleau Date: Tue, 14 Jan 2025 10:49:08 +0100 Subject: [PATCH 3/3] simplify the RPC for SARIF (#336) The goal is to make it as close as possible as the general CallFormat so at some point we can merge them. 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.50.0. See https://atd.readthedocs.io/en/latest/atdgen-tutorial.html#smooth-protocol-upgrades Note that the types related to the semgrep-core JSON output or the semgrep-core RPC do not need to be backward compatible! Co-authored-by: pad --- semgrep_output_v1.atd | 38 +- semgrep_output_v1.jsonschema | 42 +- semgrep_output_v1.proto | 14 +- semgrep_output_v1.py | 1530 +++-- semgrep_output_v1.ts | 68 +- semgrep_output_v1_j.ml | 10578 ++++++++++++++++----------------- semgrep_output_v1_j.mli | 628 +- 7 files changed, 6240 insertions(+), 6658 deletions(-) diff --git a/semgrep_output_v1.atd b/semgrep_output_v1.atd index f25c999..0d25c95 100644 --- a/semgrep_output_v1.atd +++ b/semgrep_output_v1.atd @@ -1939,35 +1939,15 @@ 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 = { - (* Path the the rules file *) +type sarif_format = { + (* Path to the rules file. We need it because rules can't be reconstructed + * from cli_output (which is one of the other param of CallSarifFormat) *) rules: fpath; - - (* TODO: remove, just use cli_output *) - cli_matches: cli_match list; - cli_errors: cli_error list; - (* TODO: remove, should be able to derive those from format_context *) - hide_nudge: bool; - engine_label: string; + (* TODO? move to format_context? *) + is_pro: bool; show_dataflow_traces: bool; } -(* TODO: remove, reuse RetFormatter *) -type sarif_format_return = { - (* The formatted output. *) - output: string; - (* Time (in seconds) it took to format the output. - * This helps tracking how much actual formatting time is needed - * compared to the whole RPC call, so we can profile and improve - * performace when needed. - *) - format_time_seconds: float; -} - type output_format = @@ -2148,9 +2128,9 @@ type resolution_result = [ type function_call = [ | CallContributions | CallApplyFixes of apply_fixes_params - (* TODO: merge with CallFormatter at some point *) - | CallSarifFormat of (format_context * sarif_format_params) | CallFormatter of (output_format * format_context * cli_output) + (* TODO: merge with CallFormatter at some point *) + | CallSarifFormat of (sarif_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. @@ -2168,9 +2148,9 @@ type function_return = [ | RetError of string | RetApplyFixes of apply_fixes_return | RetContributions of contributions - (* TODO: remove and use RetFormatter for the return of CallSarifFormat too *) - | RetSarifFormat of sarif_format_return | RetFormatter of string + (* alt: reuse RetFormatter *) + | RetSarifFormat of string | RetValidate of bool | RetResolveDependencies of (dependency_source * resolution_result) list | RetDumpRulePartitions of bool diff --git a/semgrep_output_v1.jsonschema b/semgrep_output_v1.jsonschema index 508773e..e3ebc7a 100644 --- a/semgrep_output_v1.jsonschema +++ b/semgrep_output_v1.jsonschema @@ -1608,35 +1608,15 @@ } } }, - "sarif_format_params": { + "sarif_format": { "type": "object", - "required": [ - "rules", "cli_matches", "cli_errors", "hide_nudge", "engine_label", - "show_dataflow_traces" - ], + "required": [ "rules", "is_pro", "show_dataflow_traces" ], "properties": { "rules": { "$ref": "#/definitions/fpath" }, - "cli_matches": { - "type": "array", - "items": { "$ref": "#/definitions/cli_match" } - }, - "cli_errors": { - "type": "array", - "items": { "$ref": "#/definitions/cli_error" } - }, - "hide_nudge": { "type": "boolean" }, - "engine_label": { "type": "string" }, + "is_pro": { "type": "boolean" }, "show_dataflow_traces": { "type": "boolean" } } }, - "sarif_format_return": { - "type": "object", - "required": [ "output", "format_time_seconds" ], - "properties": { - "output": { "type": "string" }, - "format_time_seconds": { "type": "number" } - } - }, "output_format": { "oneOf": [ { "const": "Text" }, @@ -1864,14 +1844,15 @@ "minItems": 2, "items": false, "prefixItems": [ - { "const": "CallSarifFormat" }, + { "const": "CallFormatter" }, { "type": "array", - "minItems": 2, + "minItems": 3, "items": false, "prefixItems": [ + { "$ref": "#/definitions/output_format" }, { "$ref": "#/definitions/format_context" }, - { "$ref": "#/definitions/sarif_format_params" } + { "$ref": "#/definitions/cli_output" } ] } ] @@ -1881,13 +1862,13 @@ "minItems": 2, "items": false, "prefixItems": [ - { "const": "CallFormatter" }, + { "const": "CallSarifFormat" }, { "type": "array", "minItems": 3, "items": false, "prefixItems": [ - { "$ref": "#/definitions/output_format" }, + { "$ref": "#/definitions/sarif_format" }, { "$ref": "#/definitions/format_context" }, { "$ref": "#/definitions/cli_output" } ] @@ -1956,8 +1937,7 @@ "minItems": 2, "items": false, "prefixItems": [ - { "const": "RetSarifFormat" }, - { "$ref": "#/definitions/sarif_format_return" } + { "const": "RetFormatter" }, { "type": "string" } ] }, { @@ -1965,7 +1945,7 @@ "minItems": 2, "items": false, "prefixItems": [ - { "const": "RetFormatter" }, { "type": "string" } + { "const": "RetSarifFormat" }, { "type": "string" } ] }, { diff --git a/semgrep_output_v1.proto b/semgrep_output_v1.proto index 9396e90..9a47fa5 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: 8eec7fa475dcdfa9d54dbf1a6cbc1f86731f97350d74e88bb8c9645750b0ff72 +// Source file sha256 digest: 4c4133c7adab129a370e0fb7a071620321e181412c14609d09e81f0865d39b6e syntax = "proto3"; @@ -643,20 +643,12 @@ message ApplyFixesReturn { repeated google.protobuf.Any fixed_lines = 405597072; } -message SarifFormatParams { +message SarifFormat { string rules = 109321335; - repeated CliMatch cli_matches = 442665614; - repeated CliError cli_errors = 87941111; - bool hide_nudge = 186555222; - string engine_label = 275040449; + bool is_pro = 65323246; bool show_dataflow_traces = 310197169; } -message SarifFormatReturn { - string output = 211259813; - float format_time_seconds = 462877603; -} - message FormatContext { bool is_ci_invocation = 208091716; bool is_logged_in = 214813956; diff --git a/semgrep_output_v1.py b/semgrep_output_v1.py index 53b13f1..a84033b 100644 --- a/semgrep_output_v1.py +++ b/semgrep_output_v1.py @@ -5911,30 +5911,120 @@ def to_json_string(self, **kw: Any) -> str: @dataclass(frozen=True) -class SarifFormatReturn: - """Original type: sarif_format_return = { ... }""" +class SarifFormat: + """Original type: sarif_format = { ... }""" - output: str - format_time_seconds: float + rules: Fpath + is_pro: bool + show_dataflow_traces: bool @classmethod - def from_json(cls, x: Any) -> 'SarifFormatReturn': + def from_json(cls, x: Any) -> 'SarifFormat': if isinstance(x, dict): return cls( - output=_atd_read_string(x['output']) if 'output' in x else _atd_missing_json_field('SarifFormatReturn', 'output'), - format_time_seconds=_atd_read_float(x['format_time_seconds']) if 'format_time_seconds' in x else _atd_missing_json_field('SarifFormatReturn', 'format_time_seconds'), + rules=Fpath.from_json(x['rules']) if 'rules' in x else _atd_missing_json_field('SarifFormat', 'rules'), + is_pro=_atd_read_bool(x['is_pro']) if 'is_pro' in x else _atd_missing_json_field('SarifFormat', 'is_pro'), + show_dataflow_traces=_atd_read_bool(x['show_dataflow_traces']) if 'show_dataflow_traces' in x else _atd_missing_json_field('SarifFormat', 'show_dataflow_traces'), ) else: - _atd_bad_json('SarifFormatReturn', x) + _atd_bad_json('SarifFormat', x) def to_json(self) -> Any: res: Dict[str, Any] = {} - res['output'] = _atd_write_string(self.output) - res['format_time_seconds'] = _atd_write_float(self.format_time_seconds) + res['rules'] = (lambda x: x.to_json())(self.rules) + res['is_pro'] = _atd_write_bool(self.is_pro) + res['show_dataflow_traces'] = _atd_write_bool(self.show_dataflow_traces) return res @classmethod - def from_json_string(cls, x: str) -> 'SarifFormatReturn': + def from_json_string(cls, x: str) -> 'SarifFormat': + return cls.from_json(json.loads(x)) + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass(frozen=True) +class OSS_: + """Original type: engine_kind = [ ... | OSS | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'OSS_' + + @staticmethod + def to_json() -> Any: + return 'OSS' + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass(frozen=True) +class PRO_: + """Original type: engine_kind = [ ... | PRO | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'PRO_' + + @staticmethod + def to_json() -> Any: + return 'PRO' + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass(frozen=True) +class EngineKind: + """Original type: engine_kind = [ ... ]""" + + value: Union[OSS_, PRO_] + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return self.value.kind + + @classmethod + def from_json(cls, x: Any) -> 'EngineKind': + if isinstance(x, str): + if x == 'OSS': + return cls(OSS_()) + if x == 'PRO': + return cls(PRO_()) + _atd_bad_json('EngineKind', x) + _atd_bad_json('EngineKind', x) + + def to_json(self) -> Any: + return self.value.to_json() + + @classmethod + def from_json_string(cls, x: str) -> 'EngineKind': + return cls.from_json(json.loads(x)) + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass(frozen=True) +class RuleIdAndEngineKind: + """Original type: rule_id_and_engine_kind""" + + value: Tuple[RuleId, EngineKind] + + @classmethod + def from_json(cls, x: Any) -> 'RuleIdAndEngineKind': + return cls((lambda x: (RuleId.from_json(x[0]), EngineKind.from_json(x[1])) if isinstance(x, list) and len(x) == 2 else _atd_bad_json('array of length 2', x))(x)) + + def to_json(self) -> Any: + return (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) + + @classmethod + def from_json_string(cls, x: str) -> 'RuleIdAndEngineKind': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: @@ -6082,287 +6172,570 @@ def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True) -class IncompatibleRule: - """Original type: incompatible_rule = { ... }""" - - rule_id: RuleId - this_version: Version - min_version: Optional[Version] = None - max_version: Optional[Version] = None - - @classmethod - def from_json(cls, x: Any) -> 'IncompatibleRule': - if isinstance(x, dict): - return cls( - rule_id=RuleId.from_json(x['rule_id']) if 'rule_id' in x else _atd_missing_json_field('IncompatibleRule', 'rule_id'), - this_version=Version.from_json(x['this_version']) if 'this_version' in x else _atd_missing_json_field('IncompatibleRule', 'this_version'), - min_version=Version.from_json(x['min_version']) if 'min_version' in x else None, - max_version=Version.from_json(x['max_version']) if 'max_version' in x else None, - ) - else: - _atd_bad_json('IncompatibleRule', x) - - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['rule_id'] = (lambda x: x.to_json())(self.rule_id) - res['this_version'] = (lambda x: x.to_json())(self.this_version) - if self.min_version is not None: - res['min_version'] = (lambda x: x.to_json())(self.min_version) - if self.max_version is not None: - res['max_version'] = (lambda x: x.to_json())(self.max_version) - return res - - @classmethod - def from_json_string(cls, x: str) -> 'IncompatibleRule': - return cls.from_json(json.loads(x)) - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - +@dataclass +class ResolutionOk: + """Original type: resolution_result = [ ... | ResolutionOk of ... | ... ]""" -@dataclass(frozen=True, order=True) -class LexicalError: - """Original type: error_type = [ ... | LexicalError | ... ]""" + value: Tuple[List[FoundDependency], List[ResolutionError]] @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'LexicalError' + return 'ResolutionOk' - @staticmethod - def to_json() -> Any: - return 'Lexical error' + def to_json(self) -> Any: + return ['ResolutionOk', (lambda x: [_atd_write_list((lambda x: x.to_json()))(x[0]), _atd_write_list((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) -@dataclass(frozen=True, order=True) -class ParseError: - """Original type: error_type = [ ... | ParseError | ... ]""" +@dataclass +class ResolutionError_: + """Original type: resolution_result = [ ... | ResolutionError of ... | ... ]""" + + value: List[ResolutionError] @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'ParseError' + return 'ResolutionError_' - @staticmethod - def to_json() -> Any: - return 'Syntax error' + def to_json(self) -> Any: + return ['ResolutionError', _atd_write_list((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, order=True) -class OtherParseError: - """Original type: error_type = [ ... | OtherParseError | ... ]""" +@dataclass +class ResolutionResult: + """Original type: resolution_result = [ ... ]""" + + value: Union[ResolutionOk, ResolutionError_] @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'OtherParseError' - - @staticmethod - def to_json() -> Any: - return 'Other syntax error' - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - + return self.value.kind -@dataclass(frozen=True, order=True) -class AstBuilderError: - """Original type: error_type = [ ... | AstBuilderError | ... ]""" + @classmethod + def from_json(cls, x: Any) -> 'ResolutionResult': + if isinstance(x, List) and len(x) == 2: + cons = x[0] + if cons == 'ResolutionOk': + return cls(ResolutionOk((lambda x: (_atd_read_list(FoundDependency.from_json)(x[0]), _atd_read_list(ResolutionError.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 == 'ResolutionError': + return cls(ResolutionError_(_atd_read_list(ResolutionError.from_json)(x[1]))) + _atd_bad_json('ResolutionResult', x) + _atd_bad_json('ResolutionResult', x) - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'AstBuilderError' + def to_json(self) -> Any: + return self.value.to_json() - @staticmethod - def to_json() -> Any: - return 'AST builder error' + @classmethod + def from_json_string(cls, x: str) -> 'ResolutionResult': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class RuleParseError: - """Original type: error_type = [ ... | RuleParseError | ... ]""" +@dataclass +class Profile: + """Original type: profile = { ... }""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'RuleParseError' + rules: List[RuleId] + rules_parse_time: float + profiling_times: Dict[str, float] + targets: List[TargetTimes] + total_bytes: int + max_memory_bytes: Optional[int] = None - @staticmethod - def to_json() -> Any: - return 'Rule parse error' + @classmethod + def from_json(cls, x: Any) -> 'Profile': + if isinstance(x, dict): + return cls( + rules=_atd_read_list(RuleId.from_json)(x['rules']) if 'rules' in x else _atd_missing_json_field('Profile', 'rules'), + rules_parse_time=_atd_read_float(x['rules_parse_time']) if 'rules_parse_time' in x else _atd_missing_json_field('Profile', 'rules_parse_time'), + profiling_times=_atd_read_assoc_object_into_dict(_atd_read_float)(x['profiling_times']) if 'profiling_times' in x else _atd_missing_json_field('Profile', 'profiling_times'), + targets=_atd_read_list(TargetTimes.from_json)(x['targets']) if 'targets' in x else _atd_missing_json_field('Profile', 'targets'), + total_bytes=_atd_read_int(x['total_bytes']) if 'total_bytes' in x else _atd_missing_json_field('Profile', 'total_bytes'), + max_memory_bytes=_atd_read_int(x['max_memory_bytes']) if 'max_memory_bytes' in x else None, + ) + else: + _atd_bad_json('Profile', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['rules'] = _atd_write_list((lambda x: x.to_json()))(self.rules) + res['rules_parse_time'] = _atd_write_float(self.rules_parse_time) + res['profiling_times'] = _atd_write_assoc_dict_to_object(_atd_write_float)(self.profiling_times) + res['targets'] = _atd_write_list((lambda x: x.to_json()))(self.targets) + res['total_bytes'] = _atd_write_int(self.total_bytes) + if self.max_memory_bytes is not None: + res['max_memory_bytes'] = _atd_write_int(self.max_memory_bytes) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'Profile': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class SemgrepWarning: - """Original type: error_type = [ ... | SemgrepWarning | ... ]""" +@dataclass +class ParsingStats: + """Original type: parsing_stats = { ... }""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'SemgrepWarning' + targets_parsed: int + num_targets: int + bytes_parsed: int + num_bytes: int - @staticmethod - def to_json() -> Any: - return 'SemgrepWarning' + @classmethod + def from_json(cls, x: Any) -> 'ParsingStats': + if isinstance(x, dict): + return cls( + targets_parsed=_atd_read_int(x['targets_parsed']) if 'targets_parsed' in x else _atd_missing_json_field('ParsingStats', 'targets_parsed'), + num_targets=_atd_read_int(x['num_targets']) if 'num_targets' in x else _atd_missing_json_field('ParsingStats', 'num_targets'), + bytes_parsed=_atd_read_int(x['bytes_parsed']) if 'bytes_parsed' in x else _atd_missing_json_field('ParsingStats', 'bytes_parsed'), + num_bytes=_atd_read_int(x['num_bytes']) if 'num_bytes' in x else _atd_missing_json_field('ParsingStats', 'num_bytes'), + ) + else: + _atd_bad_json('ParsingStats', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['targets_parsed'] = _atd_write_int(self.targets_parsed) + res['num_targets'] = _atd_write_int(self.num_targets) + res['bytes_parsed'] = _atd_write_int(self.bytes_parsed) + res['num_bytes'] = _atd_write_int(self.num_bytes) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'ParsingStats': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class SemgrepError: - """Original type: error_type = [ ... | SemgrepError | ... ]""" +@dataclass(frozen=True) +class IncompatibleRule: + """Original type: incompatible_rule = { ... }""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'SemgrepError' + rule_id: RuleId + this_version: Version + min_version: Optional[Version] = None + max_version: Optional[Version] = None - @staticmethod - def to_json() -> Any: - return 'SemgrepError' + @classmethod + def from_json(cls, x: Any) -> 'IncompatibleRule': + if isinstance(x, dict): + return cls( + rule_id=RuleId.from_json(x['rule_id']) if 'rule_id' in x else _atd_missing_json_field('IncompatibleRule', 'rule_id'), + this_version=Version.from_json(x['this_version']) if 'this_version' in x else _atd_missing_json_field('IncompatibleRule', 'this_version'), + min_version=Version.from_json(x['min_version']) if 'min_version' in x else None, + max_version=Version.from_json(x['max_version']) if 'max_version' in x else None, + ) + else: + _atd_bad_json('IncompatibleRule', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['rule_id'] = (lambda x: x.to_json())(self.rule_id) + res['this_version'] = (lambda x: x.to_json())(self.this_version) + if self.min_version is not None: + res['min_version'] = (lambda x: x.to_json())(self.min_version) + if self.max_version is not None: + res['max_version'] = (lambda x: x.to_json())(self.max_version) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'IncompatibleRule': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class InvalidRuleSchemaError: - """Original type: error_type = [ ... | InvalidRuleSchemaError | ... ]""" +@dataclass +class FindingHashes: + """Original type: finding_hashes = { ... }""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'InvalidRuleSchemaError' + start_line_hash: str + end_line_hash: str + code_hash: str + pattern_hash: str - @staticmethod - def to_json() -> Any: - return 'InvalidRuleSchemaError' + @classmethod + def from_json(cls, x: Any) -> 'FindingHashes': + if isinstance(x, dict): + return cls( + start_line_hash=_atd_read_string(x['start_line_hash']) if 'start_line_hash' in x else _atd_missing_json_field('FindingHashes', 'start_line_hash'), + end_line_hash=_atd_read_string(x['end_line_hash']) if 'end_line_hash' in x else _atd_missing_json_field('FindingHashes', 'end_line_hash'), + code_hash=_atd_read_string(x['code_hash']) if 'code_hash' in x else _atd_missing_json_field('FindingHashes', 'code_hash'), + pattern_hash=_atd_read_string(x['pattern_hash']) if 'pattern_hash' in x else _atd_missing_json_field('FindingHashes', 'pattern_hash'), + ) + else: + _atd_bad_json('FindingHashes', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['start_line_hash'] = _atd_write_string(self.start_line_hash) + res['end_line_hash'] = _atd_write_string(self.end_line_hash) + res['code_hash'] = _atd_write_string(self.code_hash) + res['pattern_hash'] = _atd_write_string(self.pattern_hash) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'FindingHashes': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class UnknownLanguageError: - """Original type: error_type = [ ... | UnknownLanguageError | ... ]""" +@dataclass +class Finding: + """Original type: finding = { ... }""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'UnknownLanguageError' + check_id: RuleId + path: Fpath + line: int + column: int + end_line: int + end_column: int + message: str + severity: Any + index: int + commit_date: str + syntactic_id: str + metadata: RawJson + is_blocking: bool + match_based_id: Optional[str] = None + hashes: Optional[FindingHashes] = None + fixed_lines: Optional[List[str]] = None + sca_info: Optional[ScaMatch] = None + dataflow_trace: Optional[MatchDataflowTrace] = None + validation_state: Optional[ValidationState] = None + historical_info: Optional[HistoricalInfo] = None + engine_kind: Optional[EngineOfFinding] = None - @staticmethod - def to_json() -> Any: - return 'UnknownLanguageError' + @classmethod + def from_json(cls, x: Any) -> 'Finding': + if isinstance(x, dict): + return cls( + check_id=RuleId.from_json(x['check_id']) if 'check_id' in x else _atd_missing_json_field('Finding', 'check_id'), + path=Fpath.from_json(x['path']) if 'path' in x else _atd_missing_json_field('Finding', 'path'), + line=_atd_read_int(x['line']) if 'line' in x else _atd_missing_json_field('Finding', 'line'), + column=_atd_read_int(x['column']) if 'column' in x else _atd_missing_json_field('Finding', 'column'), + end_line=_atd_read_int(x['end_line']) if 'end_line' in x else _atd_missing_json_field('Finding', 'end_line'), + end_column=_atd_read_int(x['end_column']) if 'end_column' in x else _atd_missing_json_field('Finding', 'end_column'), + message=_atd_read_string(x['message']) if 'message' in x else _atd_missing_json_field('Finding', 'message'), + severity=(lambda x: x)(x['severity']) if 'severity' in x else _atd_missing_json_field('Finding', 'severity'), + index=_atd_read_int(x['index']) if 'index' in x else _atd_missing_json_field('Finding', 'index'), + commit_date=_atd_read_string(x['commit_date']) if 'commit_date' in x else _atd_missing_json_field('Finding', 'commit_date'), + syntactic_id=_atd_read_string(x['syntactic_id']) if 'syntactic_id' in x else _atd_missing_json_field('Finding', 'syntactic_id'), + metadata=RawJson.from_json(x['metadata']) if 'metadata' in x else _atd_missing_json_field('Finding', 'metadata'), + is_blocking=_atd_read_bool(x['is_blocking']) if 'is_blocking' in x else _atd_missing_json_field('Finding', 'is_blocking'), + match_based_id=_atd_read_string(x['match_based_id']) if 'match_based_id' in x else None, + hashes=FindingHashes.from_json(x['hashes']) if 'hashes' in x else None, + fixed_lines=_atd_read_list(_atd_read_string)(x['fixed_lines']) if 'fixed_lines' in x else None, + sca_info=ScaMatch.from_json(x['sca_info']) if 'sca_info' in x else None, + dataflow_trace=MatchDataflowTrace.from_json(x['dataflow_trace']) if 'dataflow_trace' in x else None, + validation_state=ValidationState.from_json(x['validation_state']) if 'validation_state' in x else None, + historical_info=HistoricalInfo.from_json(x['historical_info']) if 'historical_info' in x else None, + engine_kind=EngineOfFinding.from_json(x['engine_kind']) if 'engine_kind' in x else None, + ) + else: + _atd_bad_json('Finding', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['check_id'] = (lambda x: x.to_json())(self.check_id) + res['path'] = (lambda x: x.to_json())(self.path) + res['line'] = _atd_write_int(self.line) + res['column'] = _atd_write_int(self.column) + res['end_line'] = _atd_write_int(self.end_line) + res['end_column'] = _atd_write_int(self.end_column) + res['message'] = _atd_write_string(self.message) + res['severity'] = (lambda x: x)(self.severity) + res['index'] = _atd_write_int(self.index) + res['commit_date'] = _atd_write_string(self.commit_date) + res['syntactic_id'] = _atd_write_string(self.syntactic_id) + res['metadata'] = (lambda x: x.to_json())(self.metadata) + res['is_blocking'] = _atd_write_bool(self.is_blocking) + if self.match_based_id is not None: + res['match_based_id'] = _atd_write_string(self.match_based_id) + if self.hashes is not None: + res['hashes'] = (lambda x: x.to_json())(self.hashes) + if self.fixed_lines is not None: + res['fixed_lines'] = _atd_write_list(_atd_write_string)(self.fixed_lines) + if self.sca_info is not None: + res['sca_info'] = (lambda x: x.to_json())(self.sca_info) + if self.dataflow_trace is not None: + res['dataflow_trace'] = (lambda x: x.to_json())(self.dataflow_trace) + if self.validation_state is not None: + res['validation_state'] = (lambda x: x.to_json())(self.validation_state) + if self.historical_info is not None: + res['historical_info'] = (lambda x: x.to_json())(self.historical_info) + if self.engine_kind is not None: + res['engine_kind'] = (lambda x: x.to_json())(self.engine_kind) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'Finding': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True, order=True) -class InvalidYaml: - """Original type: error_type = [ ... | InvalidYaml | ... ]""" +class LexicalError: + """Original type: error_type = [ ... | LexicalError | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'InvalidYaml' + return 'LexicalError' @staticmethod def to_json() -> Any: - return 'Invalid YAML' + return 'Lexical error' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True, order=True) -class MatchingError: - """Original type: error_type = [ ... | MatchingError | ... ]""" +class ParseError: + """Original type: error_type = [ ... | ParseError | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'MatchingError' + return 'ParseError' @staticmethod def to_json() -> Any: - return 'Internal matching error' + return 'Syntax error' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True, order=True) -class SemgrepMatchFound: - """Original type: error_type = [ ... | SemgrepMatchFound | ... ]""" +class OtherParseError: + """Original type: error_type = [ ... | OtherParseError | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'SemgrepMatchFound' + return 'OtherParseError' @staticmethod def to_json() -> Any: - return 'Semgrep match found' + return 'Other syntax error' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True, order=True) -class TooManyMatches_: - """Original type: error_type = [ ... | TooManyMatches | ... ]""" +class AstBuilderError: + """Original type: error_type = [ ... | AstBuilderError | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'TooManyMatches_' + return 'AstBuilderError' @staticmethod def to_json() -> Any: - return 'Too many matches' + return 'AST builder error' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True, order=True) -class FatalError: - """Original type: error_type = [ ... | FatalError | ... ]""" +class RuleParseError: + """Original type: error_type = [ ... | RuleParseError | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'FatalError' + return 'RuleParseError' @staticmethod def to_json() -> Any: - return 'Fatal error' + return 'Rule parse error' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True, order=True) -class Timeout: - """Original type: error_type = [ ... | Timeout | ... ]""" - +class SemgrepWarning: + """Original type: error_type = [ ... | SemgrepWarning | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'SemgrepWarning' + + @staticmethod + def to_json() -> Any: + return 'SemgrepWarning' + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass(frozen=True, order=True) +class SemgrepError: + """Original type: error_type = [ ... | SemgrepError | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'SemgrepError' + + @staticmethod + def to_json() -> Any: + return 'SemgrepError' + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass(frozen=True, order=True) +class InvalidRuleSchemaError: + """Original type: error_type = [ ... | InvalidRuleSchemaError | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'InvalidRuleSchemaError' + + @staticmethod + def to_json() -> Any: + return 'InvalidRuleSchemaError' + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass(frozen=True, order=True) +class UnknownLanguageError: + """Original type: error_type = [ ... | UnknownLanguageError | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'UnknownLanguageError' + + @staticmethod + def to_json() -> Any: + return 'UnknownLanguageError' + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass(frozen=True, order=True) +class InvalidYaml: + """Original type: error_type = [ ... | InvalidYaml | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'InvalidYaml' + + @staticmethod + def to_json() -> Any: + return 'Invalid YAML' + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass(frozen=True, order=True) +class MatchingError: + """Original type: error_type = [ ... | MatchingError | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'MatchingError' + + @staticmethod + def to_json() -> Any: + return 'Internal matching error' + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass(frozen=True, order=True) +class SemgrepMatchFound: + """Original type: error_type = [ ... | SemgrepMatchFound | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'SemgrepMatchFound' + + @staticmethod + def to_json() -> Any: + return 'Semgrep match found' + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass(frozen=True, order=True) +class TooManyMatches_: + """Original type: error_type = [ ... | TooManyMatches | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'TooManyMatches_' + + @staticmethod + def to_json() -> Any: + return 'Too many matches' + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass(frozen=True, order=True) +class FatalError: + """Original type: error_type = [ ... | FatalError | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'FatalError' + + @staticmethod + def to_json() -> Any: + return 'Fatal error' + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass(frozen=True, order=True) +class Timeout: + """Original type: error_type = [ ... | Timeout | ... ]""" + @property def kind(self) -> str: """Name of the class representing this variant.""" @@ -6776,612 +7149,17 @@ def from_json(cls, x: Any) -> 'ErrorSeverity': if x == 'error': return cls(Error_()) if x == 'warn': - return cls(Warning_()) - if x == 'info': - return cls(Info_()) - _atd_bad_json('ErrorSeverity', x) - _atd_bad_json('ErrorSeverity', x) - - def to_json(self) -> Any: - return self.value.to_json() - - @classmethod - def from_json_string(cls, x: str) -> 'ErrorSeverity': - return cls.from_json(json.loads(x)) - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - -@dataclass -class CliMatchExtra: - """Original type: cli_match_extra = { ... }""" - - message: str - metadata: RawJson - severity: MatchSeverity - fingerprint: str - lines: str - metavars: Optional[Metavars] = None - fix: Optional[str] = None - fixed_lines: Optional[List[str]] = None - is_ignored: Optional[bool] = None - sca_info: Optional[ScaMatch] = None - validation_state: Optional[ValidationState] = None - historical_info: Optional[HistoricalInfo] = None - dataflow_trace: Optional[MatchDataflowTrace] = None - engine_kind: Optional[EngineOfFinding] = None - extra_extra: Optional[RawJson] = None - - @classmethod - def from_json(cls, x: Any) -> 'CliMatchExtra': - if isinstance(x, dict): - return cls( - message=_atd_read_string(x['message']) if 'message' in x else _atd_missing_json_field('CliMatchExtra', 'message'), - metadata=RawJson.from_json(x['metadata']) if 'metadata' in x else _atd_missing_json_field('CliMatchExtra', 'metadata'), - severity=MatchSeverity.from_json(x['severity']) if 'severity' in x else _atd_missing_json_field('CliMatchExtra', 'severity'), - fingerprint=_atd_read_string(x['fingerprint']) if 'fingerprint' in x else _atd_missing_json_field('CliMatchExtra', 'fingerprint'), - lines=_atd_read_string(x['lines']) if 'lines' in x else _atd_missing_json_field('CliMatchExtra', 'lines'), - metavars=Metavars.from_json(x['metavars']) if 'metavars' in x else None, - fix=_atd_read_string(x['fix']) if 'fix' in x else None, - fixed_lines=_atd_read_list(_atd_read_string)(x['fixed_lines']) if 'fixed_lines' in x else None, - is_ignored=_atd_read_bool(x['is_ignored']) if 'is_ignored' in x else None, - sca_info=ScaMatch.from_json(x['sca_info']) if 'sca_info' in x else None, - validation_state=ValidationState.from_json(x['validation_state']) if 'validation_state' in x else None, - historical_info=HistoricalInfo.from_json(x['historical_info']) if 'historical_info' in x else None, - dataflow_trace=MatchDataflowTrace.from_json(x['dataflow_trace']) if 'dataflow_trace' in x else None, - engine_kind=EngineOfFinding.from_json(x['engine_kind']) if 'engine_kind' in x else None, - extra_extra=RawJson.from_json(x['extra_extra']) if 'extra_extra' in x else None, - ) - else: - _atd_bad_json('CliMatchExtra', x) - - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['message'] = _atd_write_string(self.message) - res['metadata'] = (lambda x: x.to_json())(self.metadata) - res['severity'] = (lambda x: x.to_json())(self.severity) - res['fingerprint'] = _atd_write_string(self.fingerprint) - res['lines'] = _atd_write_string(self.lines) - if self.metavars is not None: - res['metavars'] = (lambda x: x.to_json())(self.metavars) - if self.fix is not None: - res['fix'] = _atd_write_string(self.fix) - if self.fixed_lines is not None: - res['fixed_lines'] = _atd_write_list(_atd_write_string)(self.fixed_lines) - if self.is_ignored is not None: - res['is_ignored'] = _atd_write_bool(self.is_ignored) - if self.sca_info is not None: - res['sca_info'] = (lambda x: x.to_json())(self.sca_info) - if self.validation_state is not None: - res['validation_state'] = (lambda x: x.to_json())(self.validation_state) - if self.historical_info is not None: - res['historical_info'] = (lambda x: x.to_json())(self.historical_info) - if self.dataflow_trace is not None: - res['dataflow_trace'] = (lambda x: x.to_json())(self.dataflow_trace) - if self.engine_kind is not None: - res['engine_kind'] = (lambda x: x.to_json())(self.engine_kind) - if self.extra_extra is not None: - res['extra_extra'] = (lambda x: x.to_json())(self.extra_extra) - return res - - @classmethod - def from_json_string(cls, x: str) -> 'CliMatchExtra': - return cls.from_json(json.loads(x)) - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - -@dataclass -class CliMatch: - """Original type: cli_match = { ... }""" - - check_id: RuleId - path: Fpath - start: Position - end: Position - extra: CliMatchExtra - - @classmethod - def from_json(cls, x: Any) -> 'CliMatch': - if isinstance(x, dict): - return cls( - check_id=RuleId.from_json(x['check_id']) if 'check_id' in x else _atd_missing_json_field('CliMatch', 'check_id'), - path=Fpath.from_json(x['path']) if 'path' in x else _atd_missing_json_field('CliMatch', 'path'), - start=Position.from_json(x['start']) if 'start' in x else _atd_missing_json_field('CliMatch', 'start'), - end=Position.from_json(x['end']) if 'end' in x else _atd_missing_json_field('CliMatch', 'end'), - extra=CliMatchExtra.from_json(x['extra']) if 'extra' in x else _atd_missing_json_field('CliMatch', 'extra'), - ) - else: - _atd_bad_json('CliMatch', x) - - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['check_id'] = (lambda x: x.to_json())(self.check_id) - res['path'] = (lambda x: x.to_json())(self.path) - res['start'] = (lambda x: x.to_json())(self.start) - res['end'] = (lambda x: x.to_json())(self.end) - res['extra'] = (lambda x: x.to_json())(self.extra) - return res - - @classmethod - def from_json_string(cls, x: str) -> 'CliMatch': - return cls.from_json(json.loads(x)) - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - -@dataclass -class CliError: - """Original type: cli_error = { ... }""" - - code: int - level: ErrorSeverity - type_: ErrorType - rule_id: Optional[RuleId] = None - message: Optional[str] = None - path: Optional[Fpath] = None - long_msg: Optional[str] = None - short_msg: Optional[str] = None - spans: Optional[List[ErrorSpan]] = None - help: Optional[str] = None - - @classmethod - def from_json(cls, x: Any) -> 'CliError': - if isinstance(x, dict): - return cls( - code=_atd_read_int(x['code']) if 'code' in x else _atd_missing_json_field('CliError', 'code'), - level=ErrorSeverity.from_json(x['level']) if 'level' in x else _atd_missing_json_field('CliError', 'level'), - type_=ErrorType.from_json(x['type']) if 'type' in x else _atd_missing_json_field('CliError', 'type'), - rule_id=RuleId.from_json(x['rule_id']) if 'rule_id' in x else None, - message=_atd_read_string(x['message']) if 'message' in x else None, - path=Fpath.from_json(x['path']) if 'path' in x else None, - long_msg=_atd_read_string(x['long_msg']) if 'long_msg' in x else None, - short_msg=_atd_read_string(x['short_msg']) if 'short_msg' in x else None, - spans=_atd_read_list(ErrorSpan.from_json)(x['spans']) if 'spans' in x else None, - help=_atd_read_string(x['help']) if 'help' in x else None, - ) - else: - _atd_bad_json('CliError', x) - - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['code'] = _atd_write_int(self.code) - res['level'] = (lambda x: x.to_json())(self.level) - res['type'] = (lambda x: x.to_json())(self.type_) - if self.rule_id is not None: - res['rule_id'] = (lambda x: x.to_json())(self.rule_id) - if self.message is not None: - res['message'] = _atd_write_string(self.message) - if self.path is not None: - res['path'] = (lambda x: x.to_json())(self.path) - if self.long_msg is not None: - res['long_msg'] = _atd_write_string(self.long_msg) - if self.short_msg is not None: - res['short_msg'] = _atd_write_string(self.short_msg) - if self.spans is not None: - res['spans'] = _atd_write_list((lambda x: x.to_json()))(self.spans) - if self.help is not None: - res['help'] = _atd_write_string(self.help) - return res - - @classmethod - def from_json_string(cls, x: str) -> 'CliError': - return cls.from_json(json.loads(x)) - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - -@dataclass(frozen=True) -class SarifFormatParams: - """Original type: sarif_format_params = { ... }""" - - rules: Fpath - cli_matches: List[CliMatch] - cli_errors: List[CliError] - hide_nudge: bool - engine_label: str - show_dataflow_traces: bool - - @classmethod - def from_json(cls, x: Any) -> 'SarifFormatParams': - if isinstance(x, dict): - return cls( - 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'), - 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['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) - 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 - def from_json_string(cls, x: str) -> 'SarifFormatParams': - return cls.from_json(json.loads(x)) - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - -@dataclass(frozen=True) -class OSS_: - """Original type: engine_kind = [ ... | OSS | ... ]""" - - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'OSS_' - - @staticmethod - def to_json() -> Any: - return 'OSS' - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - -@dataclass(frozen=True) -class PRO_: - """Original type: engine_kind = [ ... | PRO | ... ]""" - - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'PRO_' - - @staticmethod - def to_json() -> Any: - return 'PRO' - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - -@dataclass(frozen=True) -class EngineKind: - """Original type: engine_kind = [ ... ]""" - - value: Union[OSS_, PRO_] - - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return self.value.kind - - @classmethod - def from_json(cls, x: Any) -> 'EngineKind': - if isinstance(x, str): - if x == 'OSS': - return cls(OSS_()) - if x == 'PRO': - return cls(PRO_()) - _atd_bad_json('EngineKind', x) - _atd_bad_json('EngineKind', x) - - def to_json(self) -> Any: - return self.value.to_json() - - @classmethod - def from_json_string(cls, x: str) -> 'EngineKind': - return cls.from_json(json.loads(x)) - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - -@dataclass(frozen=True) -class RuleIdAndEngineKind: - """Original type: rule_id_and_engine_kind""" - - value: Tuple[RuleId, EngineKind] - - @classmethod - def from_json(cls, x: Any) -> 'RuleIdAndEngineKind': - return cls((lambda x: (RuleId.from_json(x[0]), EngineKind.from_json(x[1])) if isinstance(x, list) and len(x) == 2 else _atd_bad_json('array of length 2', x))(x)) - - def to_json(self) -> Any: - return (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) - - @classmethod - def from_json_string(cls, x: str) -> 'RuleIdAndEngineKind': - return cls.from_json(json.loads(x)) - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - -@dataclass -class ResolutionOk: - """Original type: resolution_result = [ ... | ResolutionOk of ... | ... ]""" - - value: Tuple[List[FoundDependency], List[ResolutionError]] - - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'ResolutionOk' - - def to_json(self) -> Any: - return ['ResolutionOk', (lambda x: [_atd_write_list((lambda x: x.to_json()))(x[0]), _atd_write_list((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) - - -@dataclass -class ResolutionError_: - """Original type: resolution_result = [ ... | ResolutionError of ... | ... ]""" - - value: List[ResolutionError] - - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'ResolutionError_' - - def to_json(self) -> Any: - return ['ResolutionError', _atd_write_list((lambda x: x.to_json()))(self.value)] - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - -@dataclass -class ResolutionResult: - """Original type: resolution_result = [ ... ]""" - - value: Union[ResolutionOk, ResolutionError_] - - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return self.value.kind - - @classmethod - def from_json(cls, x: Any) -> 'ResolutionResult': - if isinstance(x, List) and len(x) == 2: - cons = x[0] - if cons == 'ResolutionOk': - return cls(ResolutionOk((lambda x: (_atd_read_list(FoundDependency.from_json)(x[0]), _atd_read_list(ResolutionError.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 == 'ResolutionError': - return cls(ResolutionError_(_atd_read_list(ResolutionError.from_json)(x[1]))) - _atd_bad_json('ResolutionResult', x) - _atd_bad_json('ResolutionResult', x) - - def to_json(self) -> Any: - return self.value.to_json() - - @classmethod - def from_json_string(cls, x: str) -> 'ResolutionResult': - return cls.from_json(json.loads(x)) - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - -@dataclass -class Profile: - """Original type: profile = { ... }""" - - rules: List[RuleId] - rules_parse_time: float - profiling_times: Dict[str, float] - targets: List[TargetTimes] - total_bytes: int - max_memory_bytes: Optional[int] = None - - @classmethod - def from_json(cls, x: Any) -> 'Profile': - if isinstance(x, dict): - return cls( - rules=_atd_read_list(RuleId.from_json)(x['rules']) if 'rules' in x else _atd_missing_json_field('Profile', 'rules'), - rules_parse_time=_atd_read_float(x['rules_parse_time']) if 'rules_parse_time' in x else _atd_missing_json_field('Profile', 'rules_parse_time'), - profiling_times=_atd_read_assoc_object_into_dict(_atd_read_float)(x['profiling_times']) if 'profiling_times' in x else _atd_missing_json_field('Profile', 'profiling_times'), - targets=_atd_read_list(TargetTimes.from_json)(x['targets']) if 'targets' in x else _atd_missing_json_field('Profile', 'targets'), - total_bytes=_atd_read_int(x['total_bytes']) if 'total_bytes' in x else _atd_missing_json_field('Profile', 'total_bytes'), - max_memory_bytes=_atd_read_int(x['max_memory_bytes']) if 'max_memory_bytes' in x else None, - ) - else: - _atd_bad_json('Profile', x) - - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['rules'] = _atd_write_list((lambda x: x.to_json()))(self.rules) - res['rules_parse_time'] = _atd_write_float(self.rules_parse_time) - res['profiling_times'] = _atd_write_assoc_dict_to_object(_atd_write_float)(self.profiling_times) - res['targets'] = _atd_write_list((lambda x: x.to_json()))(self.targets) - res['total_bytes'] = _atd_write_int(self.total_bytes) - if self.max_memory_bytes is not None: - res['max_memory_bytes'] = _atd_write_int(self.max_memory_bytes) - return res - - @classmethod - def from_json_string(cls, x: str) -> 'Profile': - return cls.from_json(json.loads(x)) - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - -@dataclass -class ParsingStats: - """Original type: parsing_stats = { ... }""" - - targets_parsed: int - num_targets: int - bytes_parsed: int - num_bytes: int - - @classmethod - def from_json(cls, x: Any) -> 'ParsingStats': - if isinstance(x, dict): - return cls( - targets_parsed=_atd_read_int(x['targets_parsed']) if 'targets_parsed' in x else _atd_missing_json_field('ParsingStats', 'targets_parsed'), - num_targets=_atd_read_int(x['num_targets']) if 'num_targets' in x else _atd_missing_json_field('ParsingStats', 'num_targets'), - bytes_parsed=_atd_read_int(x['bytes_parsed']) if 'bytes_parsed' in x else _atd_missing_json_field('ParsingStats', 'bytes_parsed'), - num_bytes=_atd_read_int(x['num_bytes']) if 'num_bytes' in x else _atd_missing_json_field('ParsingStats', 'num_bytes'), - ) - else: - _atd_bad_json('ParsingStats', x) - - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['targets_parsed'] = _atd_write_int(self.targets_parsed) - res['num_targets'] = _atd_write_int(self.num_targets) - res['bytes_parsed'] = _atd_write_int(self.bytes_parsed) - res['num_bytes'] = _atd_write_int(self.num_bytes) - return res - - @classmethod - def from_json_string(cls, x: str) -> 'ParsingStats': - return cls.from_json(json.loads(x)) - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - -@dataclass -class FindingHashes: - """Original type: finding_hashes = { ... }""" - - start_line_hash: str - end_line_hash: str - code_hash: str - pattern_hash: str - - @classmethod - def from_json(cls, x: Any) -> 'FindingHashes': - if isinstance(x, dict): - return cls( - start_line_hash=_atd_read_string(x['start_line_hash']) if 'start_line_hash' in x else _atd_missing_json_field('FindingHashes', 'start_line_hash'), - end_line_hash=_atd_read_string(x['end_line_hash']) if 'end_line_hash' in x else _atd_missing_json_field('FindingHashes', 'end_line_hash'), - code_hash=_atd_read_string(x['code_hash']) if 'code_hash' in x else _atd_missing_json_field('FindingHashes', 'code_hash'), - pattern_hash=_atd_read_string(x['pattern_hash']) if 'pattern_hash' in x else _atd_missing_json_field('FindingHashes', 'pattern_hash'), - ) - else: - _atd_bad_json('FindingHashes', x) - - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['start_line_hash'] = _atd_write_string(self.start_line_hash) - res['end_line_hash'] = _atd_write_string(self.end_line_hash) - res['code_hash'] = _atd_write_string(self.code_hash) - res['pattern_hash'] = _atd_write_string(self.pattern_hash) - return res - - @classmethod - def from_json_string(cls, x: str) -> 'FindingHashes': - return cls.from_json(json.loads(x)) - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - -@dataclass -class Finding: - """Original type: finding = { ... }""" - - check_id: RuleId - path: Fpath - line: int - column: int - end_line: int - end_column: int - message: str - severity: Any - index: int - commit_date: str - syntactic_id: str - metadata: RawJson - is_blocking: bool - match_based_id: Optional[str] = None - hashes: Optional[FindingHashes] = None - fixed_lines: Optional[List[str]] = None - sca_info: Optional[ScaMatch] = None - dataflow_trace: Optional[MatchDataflowTrace] = None - validation_state: Optional[ValidationState] = None - historical_info: Optional[HistoricalInfo] = None - engine_kind: Optional[EngineOfFinding] = None - - @classmethod - def from_json(cls, x: Any) -> 'Finding': - if isinstance(x, dict): - return cls( - check_id=RuleId.from_json(x['check_id']) if 'check_id' in x else _atd_missing_json_field('Finding', 'check_id'), - path=Fpath.from_json(x['path']) if 'path' in x else _atd_missing_json_field('Finding', 'path'), - line=_atd_read_int(x['line']) if 'line' in x else _atd_missing_json_field('Finding', 'line'), - column=_atd_read_int(x['column']) if 'column' in x else _atd_missing_json_field('Finding', 'column'), - end_line=_atd_read_int(x['end_line']) if 'end_line' in x else _atd_missing_json_field('Finding', 'end_line'), - end_column=_atd_read_int(x['end_column']) if 'end_column' in x else _atd_missing_json_field('Finding', 'end_column'), - message=_atd_read_string(x['message']) if 'message' in x else _atd_missing_json_field('Finding', 'message'), - severity=(lambda x: x)(x['severity']) if 'severity' in x else _atd_missing_json_field('Finding', 'severity'), - index=_atd_read_int(x['index']) if 'index' in x else _atd_missing_json_field('Finding', 'index'), - commit_date=_atd_read_string(x['commit_date']) if 'commit_date' in x else _atd_missing_json_field('Finding', 'commit_date'), - syntactic_id=_atd_read_string(x['syntactic_id']) if 'syntactic_id' in x else _atd_missing_json_field('Finding', 'syntactic_id'), - metadata=RawJson.from_json(x['metadata']) if 'metadata' in x else _atd_missing_json_field('Finding', 'metadata'), - is_blocking=_atd_read_bool(x['is_blocking']) if 'is_blocking' in x else _atd_missing_json_field('Finding', 'is_blocking'), - match_based_id=_atd_read_string(x['match_based_id']) if 'match_based_id' in x else None, - hashes=FindingHashes.from_json(x['hashes']) if 'hashes' in x else None, - fixed_lines=_atd_read_list(_atd_read_string)(x['fixed_lines']) if 'fixed_lines' in x else None, - sca_info=ScaMatch.from_json(x['sca_info']) if 'sca_info' in x else None, - dataflow_trace=MatchDataflowTrace.from_json(x['dataflow_trace']) if 'dataflow_trace' in x else None, - validation_state=ValidationState.from_json(x['validation_state']) if 'validation_state' in x else None, - historical_info=HistoricalInfo.from_json(x['historical_info']) if 'historical_info' in x else None, - engine_kind=EngineOfFinding.from_json(x['engine_kind']) if 'engine_kind' in x else None, - ) - else: - _atd_bad_json('Finding', x) + return cls(Warning_()) + if x == 'info': + return cls(Info_()) + _atd_bad_json('ErrorSeverity', x) + _atd_bad_json('ErrorSeverity', x) def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['check_id'] = (lambda x: x.to_json())(self.check_id) - res['path'] = (lambda x: x.to_json())(self.path) - res['line'] = _atd_write_int(self.line) - res['column'] = _atd_write_int(self.column) - res['end_line'] = _atd_write_int(self.end_line) - res['end_column'] = _atd_write_int(self.end_column) - res['message'] = _atd_write_string(self.message) - res['severity'] = (lambda x: x)(self.severity) - res['index'] = _atd_write_int(self.index) - res['commit_date'] = _atd_write_string(self.commit_date) - res['syntactic_id'] = _atd_write_string(self.syntactic_id) - res['metadata'] = (lambda x: x.to_json())(self.metadata) - res['is_blocking'] = _atd_write_bool(self.is_blocking) - if self.match_based_id is not None: - res['match_based_id'] = _atd_write_string(self.match_based_id) - if self.hashes is not None: - res['hashes'] = (lambda x: x.to_json())(self.hashes) - if self.fixed_lines is not None: - res['fixed_lines'] = _atd_write_list(_atd_write_string)(self.fixed_lines) - if self.sca_info is not None: - res['sca_info'] = (lambda x: x.to_json())(self.sca_info) - if self.dataflow_trace is not None: - res['dataflow_trace'] = (lambda x: x.to_json())(self.dataflow_trace) - if self.validation_state is not None: - res['validation_state'] = (lambda x: x.to_json())(self.validation_state) - if self.historical_info is not None: - res['historical_info'] = (lambda x: x.to_json())(self.historical_info) - if self.engine_kind is not None: - res['engine_kind'] = (lambda x: x.to_json())(self.engine_kind) - return res + return self.value.to_json() @classmethod - def from_json_string(cls, x: str) -> 'Finding': + def from_json_string(cls, x: str) -> 'ErrorSeverity': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: @@ -7520,6 +7298,68 @@ def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) +@dataclass +class CliError: + """Original type: cli_error = { ... }""" + + code: int + level: ErrorSeverity + type_: ErrorType + rule_id: Optional[RuleId] = None + message: Optional[str] = None + path: Optional[Fpath] = None + long_msg: Optional[str] = None + short_msg: Optional[str] = None + spans: Optional[List[ErrorSpan]] = None + help: Optional[str] = None + + @classmethod + def from_json(cls, x: Any) -> 'CliError': + if isinstance(x, dict): + return cls( + code=_atd_read_int(x['code']) if 'code' in x else _atd_missing_json_field('CliError', 'code'), + level=ErrorSeverity.from_json(x['level']) if 'level' in x else _atd_missing_json_field('CliError', 'level'), + type_=ErrorType.from_json(x['type']) if 'type' in x else _atd_missing_json_field('CliError', 'type'), + rule_id=RuleId.from_json(x['rule_id']) if 'rule_id' in x else None, + message=_atd_read_string(x['message']) if 'message' in x else None, + path=Fpath.from_json(x['path']) if 'path' in x else None, + long_msg=_atd_read_string(x['long_msg']) if 'long_msg' in x else None, + short_msg=_atd_read_string(x['short_msg']) if 'short_msg' in x else None, + spans=_atd_read_list(ErrorSpan.from_json)(x['spans']) if 'spans' in x else None, + help=_atd_read_string(x['help']) if 'help' in x else None, + ) + else: + _atd_bad_json('CliError', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['code'] = _atd_write_int(self.code) + res['level'] = (lambda x: x.to_json())(self.level) + res['type'] = (lambda x: x.to_json())(self.type_) + if self.rule_id is not None: + res['rule_id'] = (lambda x: x.to_json())(self.rule_id) + if self.message is not None: + res['message'] = _atd_write_string(self.message) + if self.path is not None: + res['path'] = (lambda x: x.to_json())(self.path) + if self.long_msg is not None: + res['long_msg'] = _atd_write_string(self.long_msg) + if self.short_msg is not None: + res['short_msg'] = _atd_write_string(self.short_msg) + if self.spans is not None: + res['spans'] = _atd_write_list((lambda x: x.to_json()))(self.spans) + if self.help is not None: + res['help'] = _atd_write_string(self.help) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'CliError': + return cls.from_json(json.loads(x)) + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + @dataclass class CiScanDependencies: """Original type: ci_scan_dependencies""" @@ -8276,36 +8116,36 @@ def to_json_string(self, **kw: Any) -> str: @dataclass(frozen=True) -class RetSarifFormat: - """Original type: function_return = [ ... | RetSarifFormat of ... | ... ]""" +class RetFormatter: + """Original type: function_return = [ ... | RetFormatter of ... | ... ]""" - value: SarifFormatReturn + value: str @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'RetSarifFormat' + return 'RetFormatter' def to_json(self) -> Any: - return ['RetSarifFormat', (lambda x: x.to_json())(self.value)] + return ['RetFormatter', _atd_write_string(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class RetFormatter: - """Original type: function_return = [ ... | RetFormatter of ... | ... ]""" +class RetSarifFormat: + """Original type: function_return = [ ... | RetSarifFormat of ... | ... ]""" value: str @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'RetFormatter' + return 'RetSarifFormat' def to_json(self) -> Any: - return ['RetFormatter', _atd_write_string(self.value)] + return ['RetSarifFormat', _atd_write_string(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @@ -8369,7 +8209,7 @@ def to_json_string(self, **kw: Any) -> str: class FunctionReturn: """Original type: function_return = [ ... ]""" - value: Union[RetError, RetApplyFixes, RetContributions, RetSarifFormat, RetFormatter, RetValidate, RetResolveDependencies, RetDumpRulePartitions] + value: Union[RetError, RetApplyFixes, RetContributions, RetFormatter, RetSarifFormat, RetValidate, RetResolveDependencies, RetDumpRulePartitions] @property def kind(self) -> str: @@ -8386,10 +8226,10 @@ def from_json(cls, x: Any) -> 'FunctionReturn': return cls(RetApplyFixes(ApplyFixesReturn.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 == 'RetSarifFormat': + return cls(RetSarifFormat(_atd_read_string(x[1]))) if cons == 'RetValidate': return cls(RetValidate(_atd_read_bool(x[1]))) if cons == 'RetResolveDependencies': @@ -8515,6 +8355,126 @@ def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) +@dataclass +class CliMatchExtra: + """Original type: cli_match_extra = { ... }""" + + message: str + metadata: RawJson + severity: MatchSeverity + fingerprint: str + lines: str + metavars: Optional[Metavars] = None + fix: Optional[str] = None + fixed_lines: Optional[List[str]] = None + is_ignored: Optional[bool] = None + sca_info: Optional[ScaMatch] = None + validation_state: Optional[ValidationState] = None + historical_info: Optional[HistoricalInfo] = None + dataflow_trace: Optional[MatchDataflowTrace] = None + engine_kind: Optional[EngineOfFinding] = None + extra_extra: Optional[RawJson] = None + + @classmethod + def from_json(cls, x: Any) -> 'CliMatchExtra': + if isinstance(x, dict): + return cls( + message=_atd_read_string(x['message']) if 'message' in x else _atd_missing_json_field('CliMatchExtra', 'message'), + metadata=RawJson.from_json(x['metadata']) if 'metadata' in x else _atd_missing_json_field('CliMatchExtra', 'metadata'), + severity=MatchSeverity.from_json(x['severity']) if 'severity' in x else _atd_missing_json_field('CliMatchExtra', 'severity'), + fingerprint=_atd_read_string(x['fingerprint']) if 'fingerprint' in x else _atd_missing_json_field('CliMatchExtra', 'fingerprint'), + lines=_atd_read_string(x['lines']) if 'lines' in x else _atd_missing_json_field('CliMatchExtra', 'lines'), + metavars=Metavars.from_json(x['metavars']) if 'metavars' in x else None, + fix=_atd_read_string(x['fix']) if 'fix' in x else None, + fixed_lines=_atd_read_list(_atd_read_string)(x['fixed_lines']) if 'fixed_lines' in x else None, + is_ignored=_atd_read_bool(x['is_ignored']) if 'is_ignored' in x else None, + sca_info=ScaMatch.from_json(x['sca_info']) if 'sca_info' in x else None, + validation_state=ValidationState.from_json(x['validation_state']) if 'validation_state' in x else None, + historical_info=HistoricalInfo.from_json(x['historical_info']) if 'historical_info' in x else None, + dataflow_trace=MatchDataflowTrace.from_json(x['dataflow_trace']) if 'dataflow_trace' in x else None, + engine_kind=EngineOfFinding.from_json(x['engine_kind']) if 'engine_kind' in x else None, + extra_extra=RawJson.from_json(x['extra_extra']) if 'extra_extra' in x else None, + ) + else: + _atd_bad_json('CliMatchExtra', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['message'] = _atd_write_string(self.message) + res['metadata'] = (lambda x: x.to_json())(self.metadata) + res['severity'] = (lambda x: x.to_json())(self.severity) + res['fingerprint'] = _atd_write_string(self.fingerprint) + res['lines'] = _atd_write_string(self.lines) + if self.metavars is not None: + res['metavars'] = (lambda x: x.to_json())(self.metavars) + if self.fix is not None: + res['fix'] = _atd_write_string(self.fix) + if self.fixed_lines is not None: + res['fixed_lines'] = _atd_write_list(_atd_write_string)(self.fixed_lines) + if self.is_ignored is not None: + res['is_ignored'] = _atd_write_bool(self.is_ignored) + if self.sca_info is not None: + res['sca_info'] = (lambda x: x.to_json())(self.sca_info) + if self.validation_state is not None: + res['validation_state'] = (lambda x: x.to_json())(self.validation_state) + if self.historical_info is not None: + res['historical_info'] = (lambda x: x.to_json())(self.historical_info) + if self.dataflow_trace is not None: + res['dataflow_trace'] = (lambda x: x.to_json())(self.dataflow_trace) + if self.engine_kind is not None: + res['engine_kind'] = (lambda x: x.to_json())(self.engine_kind) + if self.extra_extra is not None: + res['extra_extra'] = (lambda x: x.to_json())(self.extra_extra) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'CliMatchExtra': + return cls.from_json(json.loads(x)) + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass +class CliMatch: + """Original type: cli_match = { ... }""" + + check_id: RuleId + path: Fpath + start: Position + end: Position + extra: CliMatchExtra + + @classmethod + def from_json(cls, x: Any) -> 'CliMatch': + if isinstance(x, dict): + return cls( + check_id=RuleId.from_json(x['check_id']) if 'check_id' in x else _atd_missing_json_field('CliMatch', 'check_id'), + path=Fpath.from_json(x['path']) if 'path' in x else _atd_missing_json_field('CliMatch', 'path'), + start=Position.from_json(x['start']) if 'start' in x else _atd_missing_json_field('CliMatch', 'start'), + end=Position.from_json(x['end']) if 'end' in x else _atd_missing_json_field('CliMatch', 'end'), + extra=CliMatchExtra.from_json(x['extra']) if 'extra' in x else _atd_missing_json_field('CliMatch', 'extra'), + ) + else: + _atd_bad_json('CliMatch', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['check_id'] = (lambda x: x.to_json())(self.check_id) + res['path'] = (lambda x: x.to_json())(self.path) + res['start'] = (lambda x: x.to_json())(self.start) + res['end'] = (lambda x: x.to_json())(self.end) + res['extra'] = (lambda x: x.to_json())(self.extra) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'CliMatch': + return cls.from_json(json.loads(x)) + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + @dataclass class CliOutput: """Original type: cli_output = { ... }""" @@ -8643,36 +8603,36 @@ def to_json_string(self, **kw: Any) -> str: @dataclass(frozen=True) -class CallSarifFormat: - """Original type: function_call = [ ... | CallSarifFormat of ... | ... ]""" +class CallFormatter: + """Original type: function_call = [ ... | CallFormatter of ... | ... ]""" - value: Tuple[FormatContext, SarifFormatParams] + value: Tuple[OutputFormat, FormatContext, CliOutput] @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'CallSarifFormat' + return 'CallFormatter' def to_json(self) -> Any: - 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)] + return ['CallFormatter', (lambda x: [(lambda x: x.to_json())(x[0]), (lambda x: x.to_json())(x[1]), (lambda x: x.to_json())(x[2])] if isinstance(x, tuple) and len(x) == 3 else _atd_bad_python('tuple of length 3', x))(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class CallFormatter: - """Original type: function_call = [ ... | CallFormatter of ... | ... ]""" +class CallSarifFormat: + """Original type: function_call = [ ... | CallSarifFormat of ... | ... ]""" - value: Tuple[OutputFormat, FormatContext, CliOutput] + value: Tuple[SarifFormat, FormatContext, CliOutput] @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'CallFormatter' + return 'CallSarifFormat' def to_json(self) -> Any: - return ['CallFormatter', (lambda x: [(lambda x: x.to_json())(x[0]), (lambda x: x.to_json())(x[1]), (lambda x: x.to_json())(x[2])] if isinstance(x, tuple) and len(x) == 3 else _atd_bad_python('tuple of length 3', x))(self.value)] + return ['CallSarifFormat', (lambda x: [(lambda x: x.to_json())(x[0]), (lambda x: x.to_json())(x[1]), (lambda x: x.to_json())(x[2])] if isinstance(x, tuple) and len(x) == 3 else _atd_bad_python('tuple of length 3', x))(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @@ -8736,7 +8696,7 @@ def to_json_string(self, **kw: Any) -> str: class FunctionCall: """Original type: function_call = [ ... ]""" - value: Union[CallContributions, CallApplyFixes, CallSarifFormat, CallFormatter, CallValidate, CallResolveDependencies, CallDumpRulePartitions] + value: Union[CallContributions, CallApplyFixes, CallFormatter, CallSarifFormat, CallValidate, CallResolveDependencies, CallDumpRulePartitions] @property def kind(self) -> str: @@ -8753,10 +8713,10 @@ def from_json(cls, x: Any) -> 'FunctionCall': cons = x[0] if cons == 'CallApplyFixes': return cls(CallApplyFixes(ApplyFixesParams.from_json(x[1]))) - if cons == 'CallSarifFormat': - 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 == 'CallSarifFormat': + return cls(CallSarifFormat((lambda x: (SarifFormat.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': return cls(CallValidate(Fpath.from_json(x[1]))) if cons == 'CallResolveDependencies': diff --git a/semgrep_output_v1.ts b/semgrep_output_v1.ts index 64cf645..161a1cc 100644 --- a/semgrep_output_v1.ts +++ b/semgrep_output_v1.ts @@ -870,20 +870,12 @@ export type ApplyFixesReturn = { fixed_lines: [number /*int*/, string[]][]; } -export type SarifFormatParams = { +export type SarifFormat = { rules: Fpath; - cli_matches: CliMatch[]; - cli_errors: CliError[]; - hide_nudge: boolean; - engine_label: string; + is_pro: boolean; show_dataflow_traces: boolean; } -export type SarifFormatReturn = { - output: string; - format_time_seconds: number; -} - export type OutputFormat = | { kind: 'Text' } | { kind: 'Json' } @@ -983,8 +975,8 @@ export type ResolutionResult = export type FunctionCall = | { kind: 'CallContributions' } | { kind: 'CallApplyFixes'; value: ApplyFixesParams } -| { kind: 'CallSarifFormat'; value: [FormatContext, SarifFormatParams] } | { kind: 'CallFormatter'; value: [OutputFormat, FormatContext, CliOutput] } +| { kind: 'CallSarifFormat'; value: [SarifFormat, FormatContext, CliOutput] } | { kind: 'CallValidate'; value: Fpath } | { kind: 'CallResolveDependencies'; value: DependencySource[] } | { kind: 'CallDumpRulePartitions'; value: DumpRulePartitionsParams } @@ -993,8 +985,8 @@ export type FunctionReturn = | { kind: 'RetError'; value: string } | { kind: 'RetApplyFixes'; value: ApplyFixesReturn } | { kind: 'RetContributions'; value: Contributions } -| { kind: 'RetSarifFormat'; value: SarifFormatReturn } | { kind: 'RetFormatter'; value: string } +| { kind: 'RetSarifFormat'; value: string } | { kind: 'RetValidate'; value: boolean } | { kind: 'RetResolveDependencies'; value: [DependencySource, ResolutionResult][] } | { kind: 'RetDumpRulePartitions'; value: boolean } @@ -3646,39 +3638,19 @@ export function readApplyFixesReturn(x: any, context: any = x): ApplyFixesReturn }; } -export function writeSarifFormatParams(x: SarifFormatParams, context: any = x): any { - return { - '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), - '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 { - 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), - 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), - }; -} - -export function writeSarifFormatReturn(x: SarifFormatReturn, context: any = x): any { +export function writeSarifFormat(x: SarifFormat, context: any = x): any { return { - 'output': _atd_write_required_field('SarifFormatReturn', 'output', _atd_write_string, x.output, x), - 'format_time_seconds': _atd_write_required_field('SarifFormatReturn', 'format_time_seconds', _atd_write_float, x.format_time_seconds, x), + 'rules': _atd_write_required_field('SarifFormat', 'rules', writeFpath, x.rules, x), + 'is_pro': _atd_write_required_field('SarifFormat', 'is_pro', _atd_write_bool, x.is_pro, x), + 'show_dataflow_traces': _atd_write_required_field('SarifFormat', 'show_dataflow_traces', _atd_write_bool, x.show_dataflow_traces, x), }; } -export function readSarifFormatReturn(x: any, context: any = x): SarifFormatReturn { +export function readSarifFormat(x: any, context: any = x): SarifFormat { return { - output: _atd_read_required_field('SarifFormatReturn', 'output', _atd_read_string, x['output'], x), - format_time_seconds: _atd_read_required_field('SarifFormatReturn', 'format_time_seconds', _atd_read_float, x['format_time_seconds'], x), + rules: _atd_read_required_field('SarifFormat', 'rules', readFpath, x['rules'], x), + is_pro: _atd_read_required_field('SarifFormat', 'is_pro', _atd_read_bool, x['is_pro'], x), + show_dataflow_traces: _atd_read_required_field('SarifFormat', 'show_dataflow_traces', _atd_read_bool, x['show_dataflow_traces'], x), }; } @@ -4080,10 +4052,10 @@ export function writeFunctionCall(x: FunctionCall, context: any = x): any { return 'CallContributions' case 'CallApplyFixes': return ['CallApplyFixes', writeApplyFixesParams(x.value, x)] - case 'CallSarifFormat': - 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 'CallSarifFormat': + return ['CallSarifFormat', ((x, context) => [writeSarifFormat(x[0], x), writeFormatContext(x[1], x), writeCliOutput(x[2], x)])(x.value, x)] case 'CallValidate': return ['CallValidate', writeFpath(x.value, x)] case 'CallResolveDependencies': @@ -4108,10 +4080,10 @@ export function readFunctionCall(x: any, context: any = x): FunctionCall { switch (x[0]) { case 'CallApplyFixes': return { kind: 'CallApplyFixes', value: readApplyFixesParams(x[1], x) } - case 'CallSarifFormat': - 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 'CallSarifFormat': + return { kind: 'CallSarifFormat', value: ((x, context): [SarifFormat, FormatContext, CliOutput] => { _atd_check_json_tuple(3, x, context); return [readSarifFormat(x[0], x), readFormatContext(x[1], x), readCliOutput(x[2], x)] })(x[1], x) } case 'CallValidate': return { kind: 'CallValidate', value: readFpath(x[1], x) } case 'CallResolveDependencies': @@ -4133,10 +4105,10 @@ export function writeFunctionReturn(x: FunctionReturn, context: any = x): any { return ['RetApplyFixes', writeApplyFixesReturn(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 'RetSarifFormat': + return ['RetSarifFormat', _atd_write_string(x.value, x)] case 'RetValidate': return ['RetValidate', _atd_write_bool(x.value, x)] case 'RetResolveDependencies': @@ -4155,10 +4127,10 @@ export function readFunctionReturn(x: any, context: any = x): FunctionReturn { return { kind: 'RetApplyFixes', value: readApplyFixesReturn(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 'RetSarifFormat': + return { kind: 'RetSarifFormat', value: _atd_read_string(x[1], x) } case 'RetValidate': return { kind: 'RetValidate', value: _atd_read_bool(x[1], x) } case 'RetResolveDependencies': diff --git a/semgrep_output_v1_j.ml b/semgrep_output_v1_j.ml index 89bc7df..e70c9eb 100644 --- a/semgrep_output_v1_j.ml +++ b/semgrep_output_v1_j.ml @@ -489,11 +489,16 @@ type scan_config = Semgrep_output_v1_t.scan_config = { type sca_parser_name = Semgrep_output_v1_t.sca_parser_name -type sarif_format_return = Semgrep_output_v1_t.sarif_format_return = { - output: string; - format_time_seconds: float +type sarif_format = Semgrep_output_v1_t.sarif_format = { + rules: fpath; + is_pro: bool; + show_dataflow_traces: bool } +type engine_kind = Semgrep_output_v1_t.engine_kind [@@deriving show] + +type rule_id_and_engine_kind = Semgrep_output_v1_t.rule_id_and_engine_kind + type resolution_cmd_failed = Semgrep_output_v1_t.resolution_cmd_failed = { command: string; message: string @@ -503,6 +508,24 @@ type resolution_cmd_failed = Semgrep_output_v1_t.resolution_cmd_failed = { type resolution_error = Semgrep_output_v1_t.resolution_error [@@deriving show] +type resolution_result = Semgrep_output_v1_t.resolution_result + +type profile = Semgrep_output_v1_t.profile = { + rules: rule_id list; + rules_parse_time: float; + profiling_times: (string * float) list; + targets: target_times list; + total_bytes: int; + max_memory_bytes: int option +} + +type parsing_stats = Semgrep_output_v1_t.parsing_stats = { + targets_parsed: int; + num_targets: int; + bytes_parsed: int; + num_bytes: int +} + type incompatible_rule = Semgrep_output_v1_t.incompatible_rule = { rule_id: rule_id; this_version: version; @@ -511,6 +534,37 @@ type incompatible_rule = Semgrep_output_v1_t.incompatible_rule = { } [@@deriving show] +type finding_hashes = Semgrep_output_v1_t.finding_hashes = { + start_line_hash: string; + end_line_hash: string; + code_hash: string; + pattern_hash: string +} + +type finding = Semgrep_output_v1_t.finding = { + check_id: rule_id; + path: fpath; + line: int; + column: int; + end_line: int; + end_column: int; + message: string; + severity: Yojson.Safe.t; + index: int; + commit_date: string; + syntactic_id: string; + match_based_id: string option; + hashes: finding_hashes option; + metadata: raw_json; + is_blocking: bool; + fixed_lines: string list option; + sca_info: sca_match option; + dataflow_trace: match_dataflow_trace option; + validation_state: validation_state option; + historical_info: historical_info option; + engine_kind: engine_of_finding option +} + type error_type = Semgrep_output_v1_t.error_type = LexicalError | ParseError @@ -556,107 +610,6 @@ type error_span = Semgrep_output_v1_t.error_span = { type error_severity = Semgrep_output_v1_t.error_severity [@@deriving show, eq] -type cli_match_extra = Semgrep_output_v1_t.cli_match_extra = { - metavars: metavars option; - message: string; - fix: string option; - fixed_lines: string list option; - metadata: raw_json; - severity: match_severity; - fingerprint: string; - lines: string; - is_ignored: bool option; - sca_info: sca_match option; - validation_state: validation_state option; - historical_info: historical_info option; - dataflow_trace: match_dataflow_trace option; - engine_kind: engine_of_finding option; - extra_extra: raw_json option -} - -type cli_match = Semgrep_output_v1_t.cli_match = { - check_id: rule_id; - path: fpath; - start: position; - end_ (*atd end *): position; - extra: cli_match_extra -} - -type cli_error = Semgrep_output_v1_t.cli_error = { - code: int; - level: error_severity; - type_: error_type; - rule_id: rule_id option; - message: string option; - path: fpath option; - long_msg: string option; - short_msg: string option; - spans: error_span list option; - help: string option -} - -type sarif_format_params = Semgrep_output_v1_t.sarif_format_params = { - rules: fpath; - cli_matches: cli_match list; - cli_errors: cli_error list; - hide_nudge: bool; - engine_label: string; - show_dataflow_traces: bool -} - -type engine_kind = Semgrep_output_v1_t.engine_kind [@@deriving show] - -type rule_id_and_engine_kind = Semgrep_output_v1_t.rule_id_and_engine_kind - -type resolution_result = Semgrep_output_v1_t.resolution_result - -type profile = Semgrep_output_v1_t.profile = { - rules: rule_id list; - rules_parse_time: float; - profiling_times: (string * float) list; - targets: target_times list; - total_bytes: int; - max_memory_bytes: int option -} - -type parsing_stats = Semgrep_output_v1_t.parsing_stats = { - targets_parsed: int; - num_targets: int; - bytes_parsed: int; - num_bytes: int -} - -type finding_hashes = Semgrep_output_v1_t.finding_hashes = { - start_line_hash: string; - end_line_hash: string; - code_hash: string; - pattern_hash: string -} - -type finding = Semgrep_output_v1_t.finding = { - check_id: rule_id; - path: fpath; - line: int; - column: int; - end_line: int; - end_column: int; - message: string; - severity: Yojson.Safe.t; - index: int; - commit_date: string; - syntactic_id: string; - match_based_id: string option; - hashes: finding_hashes option; - metadata: raw_json; - is_blocking: bool; - fixed_lines: string list option; - sca_info: sca_match option; - dataflow_trace: match_dataflow_trace option; - validation_state: validation_state option; - historical_info: historical_info option; - engine_kind: engine_of_finding option -} - type dependency_parser_error = Semgrep_output_v1_t.dependency_parser_error = { path: fpath; parser: sca_parser_name; @@ -679,6 +632,19 @@ type contribution = Semgrep_output_v1_t.contribution = { type contributions = Semgrep_output_v1_t.contributions +type cli_error = Semgrep_output_v1_t.cli_error = { + code: int; + level: error_severity; + type_: error_type; + rule_id: rule_id option; + message: string option; + path: fpath option; + long_msg: string option; + short_msg: string option; + spans: error_span list option; + help: string option +} + type ci_scan_dependencies = Semgrep_output_v1_t.ci_scan_dependencies type ci_scan_results = Semgrep_output_v1_t.ci_scan_results = { @@ -777,6 +743,32 @@ type dump_rule_partitions_params = output_dir: fpath } +type cli_match_extra = Semgrep_output_v1_t.cli_match_extra = { + metavars: metavars option; + message: string; + fix: string option; + fixed_lines: string list option; + metadata: raw_json; + severity: match_severity; + fingerprint: string; + lines: string; + is_ignored: bool option; + sca_info: sca_match option; + validation_state: validation_state option; + historical_info: historical_info option; + dataflow_trace: match_dataflow_trace option; + engine_kind: engine_of_finding option; + extra_extra: raw_json option +} + +type cli_match = Semgrep_output_v1_t.cli_match = { + check_id: rule_id; + path: fpath; + start: position; + end_ (*atd end *): position; + extra: cli_match_extra +} + type cli_output = Semgrep_output_v1_t.cli_output = { version: version option; results: cli_match list; @@ -19172,40 +19164,50 @@ let read_sca_parser_name = ( ) let sca_parser_name_of_string s = read_sca_parser_name (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_sarif_format_return : _ -> sarif_format_return -> _ = ( - fun ob (x : sarif_format_return) -> +let write_sarif_format : _ -> sarif_format -> _ = ( + fun ob (x : sarif_format) -> Buffer.add_char ob '{'; let is_first = ref true in if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"output\":"; + Buffer.add_string ob "\"rules\":"; ( - Yojson.Safe.write_string + write_fpath ) - ob x.output; + ob x.rules; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"format_time_seconds\":"; + Buffer.add_string ob "\"is_pro\":"; ( - Yojson.Safe.write_std_float + Yojson.Safe.write_bool + ) + ob x.is_pro; + 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.format_time_seconds; + ob x.show_dataflow_traces; Buffer.add_char ob '}'; ) -let string_of_sarif_format_return ?(len = 1024) x = +let string_of_sarif_format ?(len = 1024) x = let ob = Buffer.create len in - write_sarif_format_return ob x; + write_sarif_format ob x; Buffer.contents ob -let read_sarif_format_return = ( +let read_sarif_format = ( fun p lb -> Yojson.Safe.read_space p lb; Yojson.Safe.read_lcurl p lb; - let field_output = ref (None) in - let field_format_time_seconds = ref (None) in + let field_rules = ref (None) in + let field_is_pro = ref (None) in + let field_show_dataflow_traces = ref (None) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; @@ -19215,22 +19217,30 @@ let read_sarif_format_return = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); match len with - | 6 -> ( - if String.unsafe_get s pos = 'o' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 't' then ( + | 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 ( 0 ) else ( -1 ) ) - | 19 -> ( - if String.unsafe_get s pos = 'f' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'm' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 's' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 'c' && String.unsafe_get s (pos+15) = 'o' && String.unsafe_get s (pos+16) = 'n' && String.unsafe_get s (pos+17) = 'd' && String.unsafe_get s (pos+18) = 's' then ( + | 6 -> ( + if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'o' then ( 1 ) else ( -1 ) ) + | 20 -> ( + if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'w' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'f' && String.unsafe_get s (pos+10) = 'l' && String.unsafe_get s (pos+11) = 'o' && String.unsafe_get s (pos+12) = 'w' && String.unsafe_get s (pos+13) = '_' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'r' && String.unsafe_get s (pos+16) = 'a' && String.unsafe_get s (pos+17) = 'c' && String.unsafe_get s (pos+18) = 'e' && String.unsafe_get s (pos+19) = 's' then ( + 2 + ) + else ( + -1 + ) + ) | _ -> ( -1 ) @@ -19240,18 +19250,26 @@ let read_sarif_format_return = ( ( match i with | 0 -> - field_output := ( + field_rules := ( Some ( ( - Atdgen_runtime.Oj_run.read_string + read_fpath ) p lb ) ); | 1 -> - field_format_time_seconds := ( + field_is_pro := ( Some ( ( - Atdgen_runtime.Oj_run.read_number + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | 2 -> + field_show_dataflow_traces := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool ) p lb ) ); @@ -19268,22 +19286,30 @@ let read_sarif_format_return = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); match len with - | 6 -> ( - if String.unsafe_get s pos = 'o' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 't' then ( + | 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 ( 0 ) else ( -1 ) ) - | 19 -> ( - if String.unsafe_get s pos = 'f' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'm' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 's' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 'c' && String.unsafe_get s (pos+15) = 'o' && String.unsafe_get s (pos+16) = 'n' && String.unsafe_get s (pos+17) = 'd' && String.unsafe_get s (pos+18) = 's' then ( + | 6 -> ( + if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'o' then ( 1 ) else ( -1 ) ) + | 20 -> ( + if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'w' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'f' && String.unsafe_get s (pos+10) = 'l' && String.unsafe_get s (pos+11) = 'o' && String.unsafe_get s (pos+12) = 'w' && String.unsafe_get s (pos+13) = '_' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'r' && String.unsafe_get s (pos+16) = 'a' && String.unsafe_get s (pos+17) = 'c' && String.unsafe_get s (pos+18) = 'e' && String.unsafe_get s (pos+19) = 's' then ( + 2 + ) + else ( + -1 + ) + ) | _ -> ( -1 ) @@ -19293,38 +19319,157 @@ let read_sarif_format_return = ( ( match i with | 0 -> - field_output := ( + field_rules := ( Some ( ( - Atdgen_runtime.Oj_run.read_string + read_fpath ) p lb ) ); | 1 -> - field_format_time_seconds := ( + field_is_pro := ( Some ( ( - Atdgen_runtime.Oj_run.read_number + Atdgen_runtime.Oj_run.read_bool ) p lb ) ); - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; + | 2 -> + field_show_dataflow_traces := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + done; assert false; with Yojson.End_of_object -> ( ( { - output = (match !field_output with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "output"); - format_time_seconds = (match !field_format_time_seconds with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "format_time_seconds"); + rules = (match !field_rules with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "rules"); + is_pro = (match !field_is_pro with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "is_pro"); + 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_return) + : sarif_format) ) ) -let sarif_format_return_of_string s = - read_sarif_format_return (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let sarif_format_of_string s = + read_sarif_format (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_engine_kind = ( + fun ob x -> + match x with + | `OSS -> Buffer.add_string ob "\"OSS\"" + | `PRO -> Buffer.add_string ob "\"PRO\"" +) +let string_of_engine_kind ?(len = 1024) x = + let ob = Buffer.create len in + write_engine_kind ob x; + Buffer.contents ob +let read_engine_kind = ( + 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 + | "OSS" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `OSS + | "PRO" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `PRO + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Double_quote -> ( + match Yojson.Safe.finish_string p lb with + | "OSS" -> + `OSS + | "PRO" -> + `PRO + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Square_bracket -> ( + match Atdgen_runtime.Oj_run.read_string p lb with + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) +) +let engine_kind_of_string s = + read_engine_kind (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_rule_id_and_engine_kind = ( + fun ob x -> + Buffer.add_char ob '['; + (let x, _ = x in + ( + write_rule_id + ) ob x + ); + Buffer.add_char ob ','; + (let _, x = x in + ( + write_engine_kind + ) ob x + ); + Buffer.add_char ob ']'; +) +let string_of_rule_id_and_engine_kind ?(len = 1024) x = + let ob = Buffer.create len in + write_rule_id_and_engine_kind ob x; + Buffer.contents ob +let read_rule_id_and_engine_kind = ( + 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_rule_id + ) 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_engine_kind + ) 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 ]); +) +let rule_id_and_engine_kind_of_string s = + read_rule_id_and_engine_kind (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_resolution_cmd_failed : _ -> resolution_cmd_failed -> _ = ( fun ob (x : resolution_cmd_failed) -> Buffer.add_char ob '{'; @@ -19603,121 +19748,343 @@ let read_resolution_error = ( ) let resolution_error_of_string s = read_resolution_error (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__version_option = ( - Atdgen_runtime.Oj_run.write_std_option ( - write_version +let write__resolution_error_list = ( + Atdgen_runtime.Oj_run.write_list ( + write_resolution_error ) ) -let string_of__version_option ?(len = 1024) x = +let string_of__resolution_error_list ?(len = 1024) x = let ob = Buffer.create len in - write__version_option ob x; + write__resolution_error_list ob x; Buffer.contents ob -let read__version_option = ( +let read__resolution_error_list = ( + Atdgen_runtime.Oj_run.read_list ( + read_resolution_error + ) +) +let _resolution_error_list_of_string s = + read__resolution_error_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__found_dependency_list = ( + Atdgen_runtime.Oj_run.write_list ( + write_found_dependency + ) +) +let string_of__found_dependency_list ?(len = 1024) x = + let ob = Buffer.create len in + write__found_dependency_list ob x; + Buffer.contents ob +let read__found_dependency_list = ( + Atdgen_runtime.Oj_run.read_list ( + read_found_dependency + ) +) +let _found_dependency_list_of_string s = + read__found_dependency_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_resolution_result = ( + fun ob x -> + match x with + | `ResolutionOk x -> + Buffer.add_string ob "[\"ResolutionOk\","; + ( + fun ob x -> + Buffer.add_char ob '['; + (let x, _ = x in + ( + write__found_dependency_list + ) ob x + ); + Buffer.add_char ob ','; + (let _, x = x in + ( + write__resolution_error_list + ) ob x + ); + Buffer.add_char ob ']'; + ) ob x; + Buffer.add_char ob ']' + | `ResolutionError x -> + Buffer.add_string ob "[\"ResolutionError\","; + ( + write__resolution_error_list + ) ob x; + Buffer.add_char ob ']' +) +let string_of_resolution_result ?(len = 1024) x = + let ob = Buffer.create len in + write_resolution_result ob x; + Buffer.contents ob +let read_resolution_result = ( 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" -> + | "ResolutionOk" -> + Atdgen_runtime.Oj_run.read_until_field_value p lb; + let x = ( + 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__found_dependency_list + ) 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__resolution_error_list + ) 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; Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> + `ResolutionOk x + | "ResolutionError" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( - read_version + read__resolution_error_list ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (Some x : _ option) + `ResolutionError x | 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" -> + | "ResolutionOk" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; let x = ( - read_version - ) p lb - in + 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__found_dependency_list + ) 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__resolution_error_list + ) 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; Yojson.Safe.read_rbr p lb; - (Some x : _ option) + `ResolutionOk x + | "ResolutionError" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; + let x = ( + read__resolution_error_list + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_rbr p lb; + `ResolutionError x | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) -let _version_option_of_string s = - read__version_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_incompatible_rule : _ -> incompatible_rule -> _ = ( - fun ob (x : incompatible_rule) -> +let resolution_result_of_string s = + read_resolution_result (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__x_d81b58a = ( + Atdgen_runtime.Oj_run.write_assoc_list ( + Yojson.Safe.write_string + ) ( + Yojson.Safe.write_std_float + ) +) +let string_of__x_d81b58a ?(len = 1024) x = + let ob = Buffer.create len in + write__x_d81b58a ob x; + Buffer.contents ob +let read__x_d81b58a = ( + Atdgen_runtime.Oj_run.read_assoc_list ( + Atdgen_runtime.Oj_run.read_string + ) ( + Atdgen_runtime.Oj_run.read_number + ) +) +let _x_d81b58a_of_string s = + read__x_d81b58a (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__target_times_list = ( + Atdgen_runtime.Oj_run.write_list ( + write_target_times + ) +) +let string_of__target_times_list ?(len = 1024) x = + let ob = Buffer.create len in + write__target_times_list ob x; + Buffer.contents ob +let read__target_times_list = ( + Atdgen_runtime.Oj_run.read_list ( + read_target_times + ) +) +let _target_times_list_of_string s = + read__target_times_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__rule_id_list = ( + Atdgen_runtime.Oj_run.write_list ( + write_rule_id + ) +) +let string_of__rule_id_list ?(len = 1024) x = + let ob = Buffer.create len in + write__rule_id_list ob x; + Buffer.contents ob +let read__rule_id_list = ( + Atdgen_runtime.Oj_run.read_list ( + read_rule_id + ) +) +let _rule_id_list_of_string s = + read__rule_id_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_profile : _ -> profile -> _ = ( + fun ob (x : profile) -> Buffer.add_char ob '{'; let is_first = ref true in if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"rule_id\":"; + Buffer.add_string ob "\"rules\":"; ( - write_rule_id + write__rule_id_list ) - ob x.rule_id; + ob x.rules; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"this_version\":"; + Buffer.add_string ob "\"rules_parse_time\":"; ( - write_version + Yojson.Safe.write_std_float ) - ob x.this_version; - (match x.min_version with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"min_version\":"; - ( - write_version - ) - ob x; - ); - (match x.max_version with None -> () | Some x -> + ob x.rules_parse_time; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"profiling_times\":"; + ( + write__x_d81b58a + ) + ob x.profiling_times; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"targets\":"; + ( + write__target_times_list + ) + ob x.targets; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"total_bytes\":"; + ( + Yojson.Safe.write_int + ) + ob x.total_bytes; + (match x.max_memory_bytes with None -> () | Some x -> if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"max_version\":"; + Buffer.add_string ob "\"max_memory_bytes\":"; ( - write_version + Yojson.Safe.write_int ) ob x; ); Buffer.add_char ob '}'; ) -let string_of_incompatible_rule ?(len = 1024) x = +let string_of_profile ?(len = 1024) x = let ob = Buffer.create len in - write_incompatible_rule ob x; + write_profile ob x; Buffer.contents ob -let read_incompatible_rule = ( +let read_profile = ( fun p lb -> Yojson.Safe.read_space p lb; Yojson.Safe.read_lcurl p lb; - let field_rule_id = ref (None) in - let field_this_version = ref (None) in - let field_min_version = ref (None) in - let field_max_version = ref (None) in + let field_rules = ref (None) in + let field_rules_parse_time = ref (None) in + let field_profiling_times = ref (None) in + let field_targets = ref (None) in + let field_total_bytes = ref (None) in + let field_max_memory_bytes = ref (None) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; @@ -19727,49 +20094,60 @@ let read_incompatible_rule = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); match len with - | 7 -> ( - 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) = '_' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'd' then ( + | 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 ( 0 ) else ( -1 ) ) + | 7 -> ( + if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 's' then ( + 3 + ) + else ( + -1 + ) + ) | 11 -> ( - if String.unsafe_get s pos = 'm' then ( - match String.unsafe_get s (pos+1) with - | 'a' -> ( - if String.unsafe_get s (pos+2) = 'x' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'v' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' then ( - 3 - ) - else ( - -1 - ) - ) - | 'i' -> ( - if String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'v' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' then ( - 2 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) + if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'b' && String.unsafe_get s (pos+7) = 'y' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 's' then ( + 4 ) else ( -1 ) ) - | 12 -> ( - if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'v' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 's' && String.unsafe_get s (pos+9) = 'i' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'n' then ( - 1 + | 15 -> ( + 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) = 'f' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'l' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'g' && String.unsafe_get s (pos+9) = '_' && String.unsafe_get s (pos+10) = 't' && String.unsafe_get s (pos+11) = 'i' && String.unsafe_get s (pos+12) = 'm' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 's' then ( + 2 ) else ( -1 ) ) + | 16 -> ( + match String.unsafe_get s pos with + | 'm' -> ( + if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'x' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'm' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'o' && String.unsafe_get s (pos+8) = 'r' && String.unsafe_get s (pos+9) = 'y' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'b' && String.unsafe_get s (pos+12) = 'y' && String.unsafe_get s (pos+13) = 't' && String.unsafe_get s (pos+14) = 'e' && String.unsafe_get s (pos+15) = 's' then ( + 5 + ) + else ( + -1 + ) + ) + | 'r' -> ( + if 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' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'p' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 'r' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'i' && String.unsafe_get s (pos+14) = 'm' && String.unsafe_get s (pos+15) = 'e' then ( + 1 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) | _ -> ( -1 ) @@ -19779,37 +20157,51 @@ let read_incompatible_rule = ( ( match i with | 0 -> - field_rule_id := ( + field_rules := ( Some ( ( - read_rule_id + read__rule_id_list ) p lb ) ); | 1 -> - field_this_version := ( + field_rules_parse_time := ( Some ( ( - read_version + Atdgen_runtime.Oj_run.read_number ) p lb ) ); | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_min_version := ( - Some ( - ( - read_version - ) p lb - ) - ); - ) + field_profiling_times := ( + Some ( + ( + read__x_d81b58a + ) p lb + ) + ); | 3 -> + field_targets := ( + Some ( + ( + read__target_times_list + ) p lb + ) + ); + | 4 -> + field_total_bytes := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_max_version := ( + field_max_memory_bytes := ( Some ( ( - read_version + Atdgen_runtime.Oj_run.read_int ) p lb ) ); @@ -19827,49 +20219,60 @@ let read_incompatible_rule = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); match len with - | 7 -> ( - 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) = '_' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'd' then ( + | 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 ( 0 ) else ( -1 ) ) + | 7 -> ( + if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 's' then ( + 3 + ) + else ( + -1 + ) + ) | 11 -> ( - if String.unsafe_get s pos = 'm' then ( - match String.unsafe_get s (pos+1) with - | 'a' -> ( - if String.unsafe_get s (pos+2) = 'x' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'v' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' then ( - 3 - ) - else ( - -1 - ) - ) - | 'i' -> ( - if String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'v' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' then ( - 2 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) + if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'b' && String.unsafe_get s (pos+7) = 'y' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 's' then ( + 4 ) else ( -1 ) ) - | 12 -> ( - if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'v' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 's' && String.unsafe_get s (pos+9) = 'i' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'n' then ( - 1 + | 15 -> ( + 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) = 'f' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'l' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'g' && String.unsafe_get s (pos+9) = '_' && String.unsafe_get s (pos+10) = 't' && String.unsafe_get s (pos+11) = 'i' && String.unsafe_get s (pos+12) = 'm' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 's' then ( + 2 ) else ( -1 ) ) + | 16 -> ( + match String.unsafe_get s pos with + | 'm' -> ( + if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'x' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'm' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'o' && String.unsafe_get s (pos+8) = 'r' && String.unsafe_get s (pos+9) = 'y' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'b' && String.unsafe_get s (pos+12) = 'y' && String.unsafe_get s (pos+13) = 't' && String.unsafe_get s (pos+14) = 'e' && String.unsafe_get s (pos+15) = 's' then ( + 5 + ) + else ( + -1 + ) + ) + | 'r' -> ( + if 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' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'p' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 'r' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'i' && String.unsafe_get s (pos+14) = 'm' && String.unsafe_get s (pos+15) = 'e' then ( + 1 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) | _ -> ( -1 ) @@ -19879,37 +20282,51 @@ let read_incompatible_rule = ( ( match i with | 0 -> - field_rule_id := ( + field_rules := ( Some ( ( - read_rule_id + read__rule_id_list ) p lb ) ); | 1 -> - field_this_version := ( + field_rules_parse_time := ( Some ( ( - read_version + Atdgen_runtime.Oj_run.read_number ) p lb ) ); | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_min_version := ( - Some ( - ( - read_version - ) p lb - ) - ); - ) + field_profiling_times := ( + Some ( + ( + read__x_d81b58a + ) p lb + ) + ); | 3 -> + field_targets := ( + Some ( + ( + read__target_times_list + ) p lb + ) + ); + | 4 -> + field_total_bytes := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_max_version := ( + field_max_memory_bytes := ( Some ( ( - read_version + Atdgen_runtime.Oj_run.read_int ) p lb ) ); @@ -19923,2679 +20340,419 @@ let read_incompatible_rule = ( with Yojson.End_of_object -> ( ( { - rule_id = (match !field_rule_id with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "rule_id"); - this_version = (match !field_this_version with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "this_version"); - min_version = !field_min_version; - max_version = !field_max_version; + rules = (match !field_rules with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "rules"); + rules_parse_time = (match !field_rules_parse_time with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "rules_parse_time"); + profiling_times = (match !field_profiling_times with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "profiling_times"); + targets = (match !field_targets with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "targets"); + total_bytes = (match !field_total_bytes with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "total_bytes"); + max_memory_bytes = !field_max_memory_bytes; } - : incompatible_rule) + : profile) ) ) -let incompatible_rule_of_string s = - read_incompatible_rule (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__location_list = ( - Atdgen_runtime.Oj_run.write_list ( - write_location - ) +let profile_of_string s = + read_profile (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_parsing_stats : _ -> parsing_stats -> _ = ( + fun ob (x : parsing_stats) -> + Buffer.add_char ob '{'; + let is_first = ref true in + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"targets_parsed\":"; + ( + Yojson.Safe.write_int + ) + ob x.targets_parsed; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"num_targets\":"; + ( + Yojson.Safe.write_int + ) + ob x.num_targets; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"bytes_parsed\":"; + ( + Yojson.Safe.write_int + ) + ob x.bytes_parsed; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"num_bytes\":"; + ( + Yojson.Safe.write_int + ) + ob x.num_bytes; + Buffer.add_char ob '}'; ) -let string_of__location_list ?(len = 1024) x = +let string_of_parsing_stats ?(len = 1024) x = let ob = Buffer.create len in - write__location_list ob x; + write_parsing_stats ob x; Buffer.contents ob -let read__location_list = ( - Atdgen_runtime.Oj_run.read_list ( - read_location - ) -) -let _location_list_of_string s = - read__location_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_error_type : _ -> error_type -> _ = ( - fun ob (x : error_type) -> - match x with - | LexicalError -> Buffer.add_string ob "\"Lexical error\"" - | ParseError -> Buffer.add_string ob "\"Syntax error\"" - | OtherParseError -> Buffer.add_string ob "\"Other syntax error\"" - | AstBuilderError -> Buffer.add_string ob "\"AST builder error\"" - | RuleParseError -> Buffer.add_string ob "\"Rule parse error\"" - | SemgrepWarning -> Buffer.add_string ob "\"SemgrepWarning\"" - | SemgrepError -> Buffer.add_string ob "\"SemgrepError\"" - | InvalidRuleSchemaError -> Buffer.add_string ob "\"InvalidRuleSchemaError\"" - | UnknownLanguageError -> Buffer.add_string ob "\"UnknownLanguageError\"" - | InvalidYaml -> Buffer.add_string ob "\"Invalid YAML\"" - | MatchingError -> Buffer.add_string ob "\"Internal matching error\"" - | SemgrepMatchFound -> Buffer.add_string ob "\"Semgrep match found\"" - | TooManyMatches -> Buffer.add_string ob "\"Too many matches\"" - | FatalError -> Buffer.add_string ob "\"Fatal error\"" - | Timeout -> Buffer.add_string ob "\"Timeout\"" - | OutOfMemory -> Buffer.add_string ob "\"Out of memory\"" - | StackOverflow -> Buffer.add_string ob "\"Stack overflow\"" - | TimeoutDuringInterfile -> Buffer.add_string ob "\"Timeout during interfile analysis\"" - | OutOfMemoryDuringInterfile -> Buffer.add_string ob "\"OOM during interfile analysis\"" - | MissingPlugin -> Buffer.add_string ob "\"Missing plugin\"" - | PatternParseError x -> - Buffer.add_string ob "[\"PatternParseError\","; - ( - write__string_list - ) ob x; - Buffer.add_char ob ']' - | PartialParsing x -> - Buffer.add_string ob "[\"PartialParsing\","; - ( - write__location_list - ) ob x; - Buffer.add_char ob ']' - | IncompatibleRule x -> - Buffer.add_string ob "[\"IncompatibleRule\","; +let read_parsing_stats = ( + fun p lb -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_lcurl p lb; + let field_targets_parsed = ref (None) in + let field_num_targets = ref (None) in + let field_bytes_parsed = ref (None) in + let field_num_bytes = ref (None) in + try + Yojson.Safe.read_space p lb; + Yojson.Safe.read_object_end lb; + Yojson.Safe.read_space p lb; + let f = + fun s pos len -> + if pos < 0 || len < 0 || pos + len > String.length s then + invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); + match len with + | 9 -> ( + if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'b' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 's' then ( + 3 + ) + else ( + -1 + ) + ) + | 11 -> ( + if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 'g' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 's' then ( + 1 + ) + else ( + -1 + ) + ) + | 12 -> ( + if String.unsafe_get s pos = 'b' && String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'p' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 'r' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 'd' then ( + 2 + ) + else ( + -1 + ) + ) + | 14 -> ( + if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 's' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'p' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 'r' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'd' then ( + 0 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + in + let i = Yojson.Safe.map_ident p f lb in + Atdgen_runtime.Oj_run.read_until_field_value p lb; + ( + match i with + | 0 -> + field_targets_parsed := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 1 -> + field_num_targets := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 2 -> + field_bytes_parsed := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 3 -> + field_num_bytes := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + while true do + Yojson.Safe.read_space p lb; + Yojson.Safe.read_object_sep p lb; + Yojson.Safe.read_space p lb; + let f = + fun s pos len -> + if pos < 0 || len < 0 || pos + len > String.length s then + invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); + match len with + | 9 -> ( + if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'b' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 's' then ( + 3 + ) + else ( + -1 + ) + ) + | 11 -> ( + if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 'g' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 's' then ( + 1 + ) + else ( + -1 + ) + ) + | 12 -> ( + if String.unsafe_get s pos = 'b' && String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'p' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 'r' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 'd' then ( + 2 + ) + else ( + -1 + ) + ) + | 14 -> ( + if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 's' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'p' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 'r' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'd' then ( + 0 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + in + let i = Yojson.Safe.map_ident p f lb in + Atdgen_runtime.Oj_run.read_until_field_value p lb; ( - write_incompatible_rule - ) ob x; - Buffer.add_char ob ']' - | PatternParseError0 -> Buffer.add_string ob "\"Pattern parse error\"" - | IncompatibleRule0 -> Buffer.add_string ob "\"Incompatible rule\"" - | DependencyResolutionError x -> - Buffer.add_string ob "[\"DependencyResolutionError\","; + match i with + | 0 -> + field_targets_parsed := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 1 -> + field_num_targets := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 2 -> + field_bytes_parsed := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 3 -> + field_num_bytes := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + done; + assert false; + with Yojson.End_of_object -> ( ( - write_resolution_error - ) ob x; - Buffer.add_char ob ']' + { + targets_parsed = (match !field_targets_parsed with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "targets_parsed"); + num_targets = (match !field_num_targets with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "num_targets"); + bytes_parsed = (match !field_bytes_parsed with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "bytes_parsed"); + num_bytes = (match !field_num_bytes with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "num_bytes"); + } + : parsing_stats) + ) ) -let string_of_error_type ?(len = 1024) x = +let parsing_stats_of_string s = + read_parsing_stats (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__version_option = ( + Atdgen_runtime.Oj_run.write_std_option ( + write_version + ) +) +let string_of__version_option ?(len = 1024) x = let ob = Buffer.create len in - write_error_type ob x; + write__version_option ob x; Buffer.contents ob -let read_error_type = ( +let read__version_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 - | "Lexical error" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (LexicalError : error_type) - | "Syntax error" -> + | "None" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (ParseError : error_type) - | "Other syntax error" -> + (None : _ option) + | "Some" -> + Atdgen_runtime.Oj_run.read_until_field_value p lb; + let x = ( + read_version + ) p lb + in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (OtherParseError : error_type) - | "AST builder error" -> + (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_gt p lb; - (AstBuilderError : error_type) - | "Rule parse error" -> + Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (RuleParseError : error_type) - | "SemgrepWarning" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (SemgrepWarning : error_type) - | "SemgrepError" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (SemgrepError : error_type) - | "InvalidRuleSchemaError" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (InvalidRuleSchemaError : error_type) - | "UnknownLanguageError" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (UnknownLanguageError : error_type) - | "Invalid YAML" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (InvalidYaml : error_type) - | "Internal matching error" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (MatchingError : error_type) - | "Semgrep match found" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (SemgrepMatchFound : error_type) - | "Too many matches" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (TooManyMatches : error_type) - | "Fatal error" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (FatalError : error_type) - | "Timeout" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Timeout : error_type) - | "Out of memory" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (OutOfMemory : error_type) - | "Stack overflow" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (StackOverflow : error_type) - | "Timeout during interfile analysis" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (TimeoutDuringInterfile : error_type) - | "OOM during interfile analysis" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (OutOfMemoryDuringInterfile : error_type) - | "Missing plugin" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (MissingPlugin : error_type) - | "PatternParseError" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read__string_list - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (PatternParseError x : error_type) - | "PartialParsing" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read__location_list - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (PartialParsing x : error_type) - | "IncompatibleRule" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read_incompatible_rule - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (IncompatibleRule x : error_type) - | "Pattern parse error" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (PatternParseError0 : error_type) - | "Incompatible rule" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (IncompatibleRule0 : error_type) - | "DependencyResolutionError" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read_resolution_error - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (DependencyResolutionError x : error_type) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "Lexical error" -> - (LexicalError : error_type) - | "Syntax error" -> - (ParseError : error_type) - | "Other syntax error" -> - (OtherParseError : error_type) - | "AST builder error" -> - (AstBuilderError : error_type) - | "Rule parse error" -> - (RuleParseError : error_type) - | "SemgrepWarning" -> - (SemgrepWarning : error_type) - | "SemgrepError" -> - (SemgrepError : error_type) - | "InvalidRuleSchemaError" -> - (InvalidRuleSchemaError : error_type) - | "UnknownLanguageError" -> - (UnknownLanguageError : error_type) - | "Invalid YAML" -> - (InvalidYaml : error_type) - | "Internal matching error" -> - (MatchingError : error_type) - | "Semgrep match found" -> - (SemgrepMatchFound : error_type) - | "Too many matches" -> - (TooManyMatches : error_type) - | "Fatal error" -> - (FatalError : error_type) - | "Timeout" -> - (Timeout : error_type) - | "Out of memory" -> - (OutOfMemory : error_type) - | "Stack overflow" -> - (StackOverflow : error_type) - | "Timeout during interfile analysis" -> - (TimeoutDuringInterfile : error_type) - | "OOM during interfile analysis" -> - (OutOfMemoryDuringInterfile : error_type) - | "Missing plugin" -> - (MissingPlugin : error_type) - | "Pattern parse error" -> - (PatternParseError0 : error_type) - | "Incompatible rule" -> - (IncompatibleRule0 : error_type) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "PatternParseError" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read__string_list - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (PatternParseError x : error_type) - | "PartialParsing" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read__location_list - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (PartialParsing x : error_type) - | "IncompatibleRule" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_incompatible_rule - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (IncompatibleRule x : error_type) - | "DependencyResolutionError" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_resolution_error - ) p lb - in + let x = ( + read_version + ) p lb + in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; - (DependencyResolutionError x : error_type) + (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) -let error_type_of_string s = - read_error_type (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__string_list_nullable = ( - Atdgen_runtime.Oj_run.write_nullable ( - write__string_list - ) +let _version_option_of_string s = + read__version_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_incompatible_rule : _ -> incompatible_rule -> _ = ( + fun ob (x : incompatible_rule) -> + Buffer.add_char ob '{'; + let is_first = ref true in + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"rule_id\":"; + ( + write_rule_id + ) + ob x.rule_id; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"this_version\":"; + ( + write_version + ) + ob x.this_version; + (match x.min_version with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"min_version\":"; + ( + write_version + ) + ob x; + ); + (match x.max_version with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"max_version\":"; + ( + write_version + ) + ob x; + ); + Buffer.add_char ob '}'; ) -let string_of__string_list_nullable ?(len = 1024) x = +let string_of_incompatible_rule ?(len = 1024) x = let ob = Buffer.create len in - write__string_list_nullable ob x; + write_incompatible_rule ob x; Buffer.contents ob -let read__string_list_nullable = ( +let read_incompatible_rule = ( fun p lb -> Yojson.Safe.read_space p lb; - (if Yojson.Safe.read_null_if_possible p lb then None - else Some (( - read__string_list - ) p lb) : _ option) -) -let _string_list_nullable_of_string s = - read__string_list_nullable (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__string_list_nullable_option = ( - Atdgen_runtime.Oj_run.write_std_option ( - write__string_list_nullable - ) -) -let string_of__string_list_nullable_option ?(len = 1024) x = - let ob = Buffer.create len in - write__string_list_nullable_option ob x; - Buffer.contents ob -let read__string_list_nullable_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__string_list_nullable - ) 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__string_list_nullable - ) 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 _string_list_nullable_option_of_string s = - read__string_list_nullable_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__position_nullable = ( - Atdgen_runtime.Oj_run.write_nullable ( - write_position - ) -) -let string_of__position_nullable ?(len = 1024) x = - let ob = Buffer.create len in - write__position_nullable ob x; - Buffer.contents ob -let read__position_nullable = ( - fun p lb -> - Yojson.Safe.read_space p lb; - (if Yojson.Safe.read_null_if_possible p lb then None - else Some (( - read_position - ) p lb) : _ option) -) -let _position_nullable_of_string s = - read__position_nullable (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__position_nullable_option = ( - Atdgen_runtime.Oj_run.write_std_option ( - write__position_nullable - ) -) -let string_of__position_nullable_option ?(len = 1024) x = - let ob = Buffer.create len in - write__position_nullable_option ob x; - Buffer.contents ob -let read__position_nullable_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__position_nullable - ) 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__position_nullable - ) 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 _position_nullable_option_of_string s = - read__position_nullable_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_error_span : _ -> error_span -> _ = ( - fun ob (x : error_span) -> - Buffer.add_char ob '{'; - let is_first = ref true in - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"file\":"; - ( - write_fpath - ) - ob x.file; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"start\":"; - ( - write_position - ) - ob x.start; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"end\":"; - ( - write_position - ) - ob x.end_; - (match x.source_hash with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"source_hash\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.config_start with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"config_start\":"; - ( - write__position_nullable - ) - ob x; - ); - (match x.config_end with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"config_end\":"; - ( - write__position_nullable - ) - ob x; - ); - (match x.config_path with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"config_path\":"; - ( - write__string_list_nullable - ) - ob x; - ); - (match x.context_start with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"context_start\":"; - ( - write__position_nullable - ) - ob x; - ); - (match x.context_end with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"context_end\":"; - ( - write__position_nullable - ) - ob x; - ); - Buffer.add_char ob '}'; -) -let string_of_error_span ?(len = 1024) x = - let ob = Buffer.create len in - write_error_span ob x; - Buffer.contents ob -let read_error_span = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_file = ref (None) in - let field_start = ref (None) in - let field_end_ = ref (None) in - let field_source_hash = ref (None) in - let field_config_start = ref (None) in - let field_config_end = ref (None) in - let field_config_path = ref (None) in - let field_context_start = ref (None) in - let field_context_end = ref (None) in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); - match len with - | 3 -> ( - if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' then ( - 2 - ) - else ( - -1 - ) - ) - | 4 -> ( - if String.unsafe_get s pos = 'f' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' then ( - 0 - ) - else ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' then ( - 1 - ) - else ( - -1 - ) - ) - | 10 -> ( - if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'f' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'd' then ( - 5 - ) - else ( - -1 - ) - ) - | 11 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' then ( - match String.unsafe_get s (pos+3) with - | 'f' -> ( - if String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'p' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'h' then ( - 6 - ) - else ( - -1 - ) - ) - | 't' -> ( - if String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'x' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'd' then ( - 8 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - else ( - -1 - ) - ) - | 's' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'u' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 'c' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'h' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'h' then ( - 3 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 12 -> ( - if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'f' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 'r' && String.unsafe_get s (pos+11) = 't' then ( - 4 - ) - else ( - -1 - ) - ) - | 13 -> ( - if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'x' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 's' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'a' && String.unsafe_get s (pos+11) = 'r' && String.unsafe_get s (pos+12) = 't' then ( - 7 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_file := ( - Some ( - ( - read_fpath - ) p lb - ) - ); - | 1 -> - field_start := ( - Some ( - ( - read_position - ) p lb - ) - ); - | 2 -> - field_end_ := ( - Some ( - ( - read_position - ) p lb - ) - ); - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_source_hash := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 4 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_config_start := ( - Some ( - ( - read__position_nullable - ) p lb - ) - ); - ) - | 5 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_config_end := ( - Some ( - ( - read__position_nullable - ) p lb - ) - ); - ) - | 6 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_config_path := ( - Some ( - ( - read__string_list_nullable - ) p lb - ) - ); - ) - | 7 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_context_start := ( - Some ( - ( - read__position_nullable - ) p lb - ) - ); - ) - | 8 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_context_end := ( - Some ( - ( - read__position_nullable - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); - match len with - | 3 -> ( - if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' then ( - 2 - ) - else ( - -1 - ) - ) - | 4 -> ( - if String.unsafe_get s pos = 'f' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' then ( - 0 - ) - else ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' then ( - 1 - ) - else ( - -1 - ) - ) - | 10 -> ( - if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'f' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'd' then ( - 5 - ) - else ( - -1 - ) - ) - | 11 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' then ( - match String.unsafe_get s (pos+3) with - | 'f' -> ( - if String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'p' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'h' then ( - 6 - ) - else ( - -1 - ) - ) - | 't' -> ( - if String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'x' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'd' then ( - 8 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - else ( - -1 - ) - ) - | 's' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'u' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 'c' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'h' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'h' then ( - 3 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 12 -> ( - if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'f' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 'r' && String.unsafe_get s (pos+11) = 't' then ( - 4 - ) - else ( - -1 - ) - ) - | 13 -> ( - if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'x' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 's' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'a' && String.unsafe_get s (pos+11) = 'r' && String.unsafe_get s (pos+12) = 't' then ( - 7 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_file := ( - Some ( - ( - read_fpath - ) p lb - ) - ); - | 1 -> - field_start := ( - Some ( - ( - read_position - ) p lb - ) - ); - | 2 -> - field_end_ := ( - Some ( - ( - read_position - ) p lb - ) - ); - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_source_hash := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 4 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_config_start := ( - Some ( - ( - read__position_nullable - ) p lb - ) - ); - ) - | 5 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_config_end := ( - Some ( - ( - read__position_nullable - ) p lb - ) - ); - ) - | 6 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_config_path := ( - Some ( - ( - read__string_list_nullable - ) p lb - ) - ); - ) - | 7 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_context_start := ( - Some ( - ( - read__position_nullable - ) p lb - ) - ); - ) - | 8 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_context_end := ( - Some ( - ( - read__position_nullable - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - ( - { - file = (match !field_file with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "file"); - start = (match !field_start with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "start"); - end_ = (match !field_end_ with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "end_"); - source_hash = !field_source_hash; - config_start = !field_config_start; - config_end = !field_config_end; - config_path = !field_config_path; - context_start = !field_context_start; - context_end = !field_context_end; - } - : error_span) - ) -) -let error_span_of_string s = - read_error_span (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_error_severity = ( - fun ob x -> - match x with - | `Error -> Buffer.add_string ob "\"error\"" - | `Warning -> Buffer.add_string ob "\"warn\"" - | `Info -> Buffer.add_string ob "\"info\"" -) -let string_of_error_severity ?(len = 1024) x = - let ob = Buffer.create len in - write_error_severity ob x; - Buffer.contents ob -let read_error_severity = ( - 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 - | "error" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `Error - | "warn" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `Warning - | "info" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `Info - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "error" -> - `Error - | "warn" -> - `Warning - | "info" -> - `Info - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let error_severity_of_string s = - read_error_severity (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__string_list_option = ( - Atdgen_runtime.Oj_run.write_std_option ( - write__string_list - ) -) -let string_of__string_list_option ?(len = 1024) x = - let ob = Buffer.create len in - write__string_list_option ob x; - Buffer.contents ob -let read__string_list_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__string_list - ) 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__string_list - ) 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 _string_list_option_of_string s = - read__string_list_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__metavars_option = ( - Atdgen_runtime.Oj_run.write_std_option ( - write_metavars - ) -) -let string_of__metavars_option ?(len = 1024) x = - let ob = Buffer.create len in - write__metavars_option ob x; - Buffer.contents ob -let read__metavars_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_metavars - ) 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_metavars - ) 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 _metavars_option_of_string s = - read__metavars_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__engine_of_finding_option = ( - Atdgen_runtime.Oj_run.write_std_option ( - write_engine_of_finding - ) -) -let string_of__engine_of_finding_option ?(len = 1024) x = - let ob = Buffer.create len in - write__engine_of_finding_option ob x; - Buffer.contents ob -let read__engine_of_finding_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_engine_of_finding - ) 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_engine_of_finding - ) 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 _engine_of_finding_option_of_string s = - read__engine_of_finding_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_cli_match_extra : _ -> cli_match_extra -> _ = ( - fun ob (x : cli_match_extra) -> - Buffer.add_char ob '{'; - let is_first = ref true in - (match x.metavars with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"metavars\":"; - ( - write_metavars - ) - ob x; - ); - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"message\":"; - ( - Yojson.Safe.write_string - ) - ob x.message; - (match x.fix with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"fix\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.fixed_lines with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"fixed_lines\":"; - ( - write__string_list - ) - ob x; - ); - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"metadata\":"; - ( - write_raw_json - ) - ob x.metadata; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"severity\":"; - ( - write_match_severity - ) - ob x.severity; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"fingerprint\":"; - ( - Yojson.Safe.write_string - ) - ob x.fingerprint; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"lines\":"; - ( - Yojson.Safe.write_string - ) - ob x.lines; - (match x.is_ignored with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"is_ignored\":"; - ( - Yojson.Safe.write_bool - ) - ob x; - ); - (match x.sca_info with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"sca_info\":"; - ( - write_sca_match - ) - ob x; - ); - (match x.validation_state with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"validation_state\":"; - ( - write_validation_state - ) - ob x; - ); - (match x.historical_info with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"historical_info\":"; - ( - write_historical_info - ) - ob x; - ); - (match x.dataflow_trace with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"dataflow_trace\":"; - ( - write_match_dataflow_trace - ) - ob x; - ); - (match x.engine_kind with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"engine_kind\":"; - ( - write_engine_of_finding - ) - ob x; - ); - (match x.extra_extra with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"extra_extra\":"; - ( - write_raw_json - ) - ob x; - ); - Buffer.add_char ob '}'; -) -let string_of_cli_match_extra ?(len = 1024) x = - let ob = Buffer.create len in - write_cli_match_extra ob x; - Buffer.contents ob -let read_cli_match_extra = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_metavars = ref (None) in - let field_message = ref (None) in - let field_fix = ref (None) in - let field_fixed_lines = ref (None) in - let field_metadata = ref (None) in - let field_severity = ref (None) in - let field_fingerprint = ref (None) in - let field_lines = ref (None) in - let field_is_ignored = ref (None) in - let field_sca_info = ref (None) in - let field_validation_state = ref (None) in - let field_historical_info = ref (None) in - let field_dataflow_trace = ref (None) in - let field_engine_kind = ref (None) in - let field_extra_extra = ref (None) in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); - match len with - | 3 -> ( - if String.unsafe_get s pos = 'f' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'x' then ( - 2 - ) - else ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'l' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' then ( - 7 - ) - else ( - -1 - ) - ) - | 7 -> ( - if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = 'e' then ( - 1 - ) - else ( - -1 - ) - ) - | 8 -> ( - match String.unsafe_get s pos with - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' then ( - match String.unsafe_get s (pos+4) with - | 'd' -> ( - if String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'a' then ( - 4 - ) - else ( - -1 - ) - ) - | 'v' -> ( - if String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 's' then ( - 0 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - else ( - -1 - ) - ) - | 's' -> ( - match String.unsafe_get s (pos+1) with - | 'c' -> ( - if String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'f' && String.unsafe_get s (pos+7) = 'o' then ( - 9 - ) - else ( - -1 - ) - ) - | 'e' -> ( - if String.unsafe_get s (pos+2) = 'v' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'y' then ( - 5 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 10 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'g' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 'd' then ( - 8 - ) - else ( - -1 - ) - ) - | 11 -> ( - match String.unsafe_get s pos with - | 'e' -> ( - match String.unsafe_get s (pos+1) with - | 'n' -> ( - if 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) = 'k' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'd' then ( - 13 - ) - else ( - -1 - ) - ) - | 'x' -> ( - if String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'x' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'r' && String.unsafe_get s (pos+10) = 'a' then ( - 14 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 'f' -> ( - if String.unsafe_get s (pos+1) = 'i' then ( - match String.unsafe_get s (pos+2) with - | 'n' -> ( - if String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'p' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 't' then ( - 6 - ) - else ( - -1 - ) - ) - | 'x' -> ( - if String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 's' then ( - 3 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 14 -> ( - if String.unsafe_get s pos = 'd' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'f' && String.unsafe_get s (pos+5) = 'l' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'w' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'r' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 'c' && String.unsafe_get s (pos+13) = 'e' then ( - 12 - ) - else ( - -1 - ) - ) - | 15 -> ( - if String.unsafe_get s pos = 'h' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'i' && String.unsafe_get s (pos+12) = 'n' && String.unsafe_get s (pos+13) = 'f' && String.unsafe_get s (pos+14) = 'o' then ( - 11 - ) - else ( - -1 - ) - ) - | 16 -> ( - if String.unsafe_get s pos = 'v' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'e' then ( - 10 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_metavars := ( - Some ( - ( - read_metavars - ) p lb - ) - ); - ) - | 1 -> - field_message := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_fix := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_fixed_lines := ( - Some ( - ( - read__string_list - ) p lb - ) - ); - ) - | 4 -> - field_metadata := ( - Some ( - ( - read_raw_json - ) p lb - ) - ); - | 5 -> - field_severity := ( - Some ( - ( - read_match_severity - ) p lb - ) - ); - | 6 -> - field_fingerprint := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - | 7 -> - field_lines := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - | 8 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_is_ignored := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | 9 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_sca_info := ( - Some ( - ( - read_sca_match - ) p lb - ) - ); - ) - | 10 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_validation_state := ( - Some ( - ( - read_validation_state - ) p lb - ) - ); - ) - | 11 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_historical_info := ( - Some ( - ( - read_historical_info - ) p lb - ) - ); - ) - | 12 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_dataflow_trace := ( - Some ( - ( - read_match_dataflow_trace - ) p lb - ) - ); - ) - | 13 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_engine_kind := ( - Some ( - ( - read_engine_of_finding - ) p lb - ) - ); - ) - | 14 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_extra_extra := ( - Some ( - ( - read_raw_json - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); - match len with - | 3 -> ( - if String.unsafe_get s pos = 'f' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'x' then ( - 2 - ) - else ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'l' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' then ( - 7 - ) - else ( - -1 - ) - ) - | 7 -> ( - if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = 'e' then ( - 1 - ) - else ( - -1 - ) - ) - | 8 -> ( - match String.unsafe_get s pos with - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' then ( - match String.unsafe_get s (pos+4) with - | 'd' -> ( - if String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'a' then ( - 4 - ) - else ( - -1 - ) - ) - | 'v' -> ( - if String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 's' then ( - 0 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - else ( - -1 - ) - ) - | 's' -> ( - match String.unsafe_get s (pos+1) with - | 'c' -> ( - if String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'f' && String.unsafe_get s (pos+7) = 'o' then ( - 9 - ) - else ( - -1 - ) - ) - | 'e' -> ( - if String.unsafe_get s (pos+2) = 'v' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'y' then ( - 5 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 10 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'g' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 'd' then ( - 8 - ) - else ( - -1 - ) - ) - | 11 -> ( - match String.unsafe_get s pos with - | 'e' -> ( - match String.unsafe_get s (pos+1) with - | 'n' -> ( - if 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) = 'k' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'd' then ( - 13 - ) - else ( - -1 - ) - ) - | 'x' -> ( - if String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'x' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'r' && String.unsafe_get s (pos+10) = 'a' then ( - 14 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 'f' -> ( - if String.unsafe_get s (pos+1) = 'i' then ( - match String.unsafe_get s (pos+2) with - | 'n' -> ( - if String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'p' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 't' then ( - 6 - ) - else ( - -1 - ) - ) - | 'x' -> ( - if String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 's' then ( - 3 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 14 -> ( - if String.unsafe_get s pos = 'd' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'f' && String.unsafe_get s (pos+5) = 'l' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'w' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'r' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 'c' && String.unsafe_get s (pos+13) = 'e' then ( - 12 - ) - else ( - -1 - ) - ) - | 15 -> ( - if String.unsafe_get s pos = 'h' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'i' && String.unsafe_get s (pos+12) = 'n' && String.unsafe_get s (pos+13) = 'f' && String.unsafe_get s (pos+14) = 'o' then ( - 11 - ) - else ( - -1 - ) - ) - | 16 -> ( - if String.unsafe_get s pos = 'v' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'e' then ( - 10 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_metavars := ( - Some ( - ( - read_metavars - ) p lb - ) - ); - ) - | 1 -> - field_message := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_fix := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_fixed_lines := ( - Some ( - ( - read__string_list - ) p lb - ) - ); - ) - | 4 -> - field_metadata := ( - Some ( - ( - read_raw_json - ) p lb - ) - ); - | 5 -> - field_severity := ( - Some ( - ( - read_match_severity - ) p lb - ) - ); - | 6 -> - field_fingerprint := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - | 7 -> - field_lines := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - | 8 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_is_ignored := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | 9 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_sca_info := ( - Some ( - ( - read_sca_match - ) p lb - ) - ); - ) - | 10 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_validation_state := ( - Some ( - ( - read_validation_state - ) p lb - ) - ); - ) - | 11 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_historical_info := ( - Some ( - ( - read_historical_info - ) p lb - ) - ); - ) - | 12 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_dataflow_trace := ( - Some ( - ( - read_match_dataflow_trace - ) p lb - ) - ); - ) - | 13 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_engine_kind := ( - Some ( - ( - read_engine_of_finding - ) p lb - ) - ); - ) - | 14 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_extra_extra := ( - Some ( - ( - read_raw_json - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - ( - { - metavars = !field_metavars; - message = (match !field_message with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "message"); - fix = !field_fix; - fixed_lines = !field_fixed_lines; - metadata = (match !field_metadata with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "metadata"); - severity = (match !field_severity with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "severity"); - fingerprint = (match !field_fingerprint with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "fingerprint"); - lines = (match !field_lines with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "lines"); - is_ignored = !field_is_ignored; - sca_info = !field_sca_info; - validation_state = !field_validation_state; - historical_info = !field_historical_info; - dataflow_trace = !field_dataflow_trace; - engine_kind = !field_engine_kind; - extra_extra = !field_extra_extra; - } - : cli_match_extra) - ) -) -let cli_match_extra_of_string s = - read_cli_match_extra (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_cli_match : _ -> cli_match -> _ = ( - fun ob (x : cli_match) -> - Buffer.add_char ob '{'; - let is_first = ref true in - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"check_id\":"; - ( - write_rule_id - ) - ob x.check_id; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"path\":"; - ( - write_fpath - ) - ob x.path; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"start\":"; - ( - write_position - ) - ob x.start; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"end\":"; - ( - write_position - ) - ob x.end_; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"extra\":"; - ( - write_cli_match_extra - ) - ob x.extra; - Buffer.add_char ob '}'; -) -let string_of_cli_match ?(len = 1024) x = - let ob = Buffer.create len in - write_cli_match ob x; - Buffer.contents ob -let read_cli_match = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_check_id = ref (None) in - let field_path = ref (None) in - let field_start = ref (None) in - let field_end_ = ref (None) in - let field_extra = ref (None) in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); - match len with - | 3 -> ( - if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' then ( - 3 - ) - else ( - -1 - ) - ) - | 4 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' then ( - 1 - ) - else ( - -1 - ) - ) - | 5 -> ( - match String.unsafe_get s pos with - | 'e' -> ( - if String.unsafe_get s (pos+1) = 'x' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 'a' then ( - 4 - ) - else ( - -1 - ) - ) - | 's' -> ( - if String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' then ( - 2 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'k' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_check_id := ( - Some ( - ( - read_rule_id - ) p lb - ) - ); - | 1 -> - field_path := ( - Some ( - ( - read_fpath - ) p lb - ) - ); - | 2 -> - field_start := ( - Some ( - ( - read_position - ) p lb - ) - ); - | 3 -> - field_end_ := ( - Some ( - ( - read_position - ) p lb - ) - ); - | 4 -> - field_extra := ( - Some ( - ( - read_cli_match_extra - ) p lb - ) - ); - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); - match len with - | 3 -> ( - if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' then ( - 3 - ) - else ( - -1 - ) - ) - | 4 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' then ( - 1 - ) - else ( - -1 - ) - ) - | 5 -> ( - match String.unsafe_get s pos with - | 'e' -> ( - if String.unsafe_get s (pos+1) = 'x' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 'a' then ( - 4 - ) - else ( - -1 - ) - ) - | 's' -> ( - if String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' then ( - 2 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'k' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_check_id := ( - Some ( - ( - read_rule_id - ) p lb - ) - ); - | 1 -> - field_path := ( - Some ( - ( - read_fpath - ) p lb - ) - ); - | 2 -> - field_start := ( - Some ( - ( - read_position - ) p lb - ) - ); - | 3 -> - field_end_ := ( - Some ( - ( - read_position - ) p lb - ) - ); - | 4 -> - field_extra := ( - Some ( - ( - read_cli_match_extra - ) p lb - ) - ); - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - ( - { - check_id = (match !field_check_id with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "check_id"); - path = (match !field_path with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "path"); - start = (match !field_start with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "start"); - end_ = (match !field_end_ with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "end_"); - extra = (match !field_extra with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "extra"); - } - : cli_match) - ) -) -let cli_match_of_string s = - read_cli_match (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__error_span_list = ( - Atdgen_runtime.Oj_run.write_list ( - write_error_span - ) -) -let string_of__error_span_list ?(len = 1024) x = - let ob = Buffer.create len in - write__error_span_list ob x; - Buffer.contents ob -let read__error_span_list = ( - Atdgen_runtime.Oj_run.read_list ( - read_error_span - ) -) -let _error_span_list_of_string s = - read__error_span_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__error_span_list_option = ( - Atdgen_runtime.Oj_run.write_std_option ( - write__error_span_list - ) -) -let string_of__error_span_list_option ?(len = 1024) x = - let ob = Buffer.create len in - write__error_span_list_option ob x; - Buffer.contents ob -let read__error_span_list_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__error_span_list - ) 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__error_span_list - ) 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 _error_span_list_option_of_string s = - read__error_span_list_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_cli_error : _ -> cli_error -> _ = ( - fun ob (x : cli_error) -> - Buffer.add_char ob '{'; - let is_first = ref true in - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"code\":"; - ( - Yojson.Safe.write_int - ) - ob x.code; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"level\":"; - ( - write_error_severity - ) - ob x.level; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"type\":"; - ( - write_error_type - ) - ob x.type_; - (match x.rule_id with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"rule_id\":"; - ( - write_rule_id - ) - ob x; - ); - (match x.message with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"message\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.path with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"path\":"; - ( - write_fpath - ) - ob x; - ); - (match x.long_msg with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"long_msg\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.short_msg with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"short_msg\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.spans with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"spans\":"; - ( - write__error_span_list - ) - ob x; - ); - (match x.help with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"help\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - Buffer.add_char ob '}'; -) -let string_of_cli_error ?(len = 1024) x = - let ob = Buffer.create len in - write_cli_error ob x; - Buffer.contents ob -let read_cli_error = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_code = ref (None) in - let field_level = ref (None) in - let field_type_ = ref (None) in - let field_rule_id = ref (None) in - let field_message = ref (None) in - let field_path = ref (None) in - let field_long_msg = ref (None) in - let field_short_msg = ref (None) in - let field_spans = ref (None) in - let field_help = ref (None) in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); - match len with - | 4 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 'e' then ( - 0 - ) - else ( - -1 - ) - ) - | 'h' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'p' then ( - 9 - ) - else ( - -1 - ) - ) - | 'p' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' then ( - 5 - ) - else ( - -1 - ) - ) - | 't' -> ( - if String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'e' then ( - 2 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 5 -> ( - match String.unsafe_get s pos with - | 'l' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'v' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'l' then ( - 1 - ) - else ( - -1 - ) - ) - | 's' -> ( - if String.unsafe_get s (pos+1) = 'p' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = 's' then ( - 8 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) + Yojson.Safe.read_lcurl p lb; + let field_rule_id = ref (None) in + let field_this_version = ref (None) in + let field_min_version = ref (None) in + let field_max_version = ref (None) in + try + Yojson.Safe.read_space p lb; + Yojson.Safe.read_object_end lb; + Yojson.Safe.read_space p lb; + let f = + fun s pos len -> + if pos < 0 || len < 0 || pos + len > String.length s then + invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); + match len with | 7 -> ( - match String.unsafe_get s pos with - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = 'e' then ( - 4 - ) - else ( - -1 + 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) = '_' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'd' then ( + 0 + ) + else ( + -1 + ) + ) + | 11 -> ( + if String.unsafe_get s pos = 'm' then ( + match String.unsafe_get s (pos+1) with + | 'a' -> ( + if String.unsafe_get s (pos+2) = 'x' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'v' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' then ( + 3 + ) + else ( + -1 + ) ) - ) - | 'r' -> ( - if 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) = '_' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'd' then ( - 3 + | 'i' -> ( + if String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'v' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' then ( + 2 + ) + else ( + -1 + ) ) - else ( + | _ -> ( -1 ) - ) - | _ -> ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'l' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'm' && String.unsafe_get s (pos+6) = 's' && String.unsafe_get s (pos+7) = 'g' then ( - 6 ) else ( -1 ) ) - | 9 -> ( - if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'g' then ( - 7 + | 12 -> ( + if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'v' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 's' && String.unsafe_get s (pos+9) = 'i' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'n' then ( + 1 ) else ( -1 @@ -22610,95 +20767,37 @@ let read_cli_error = ( ( match i with | 0 -> - field_code := ( + field_rule_id := ( Some ( ( - Atdgen_runtime.Oj_run.read_int + read_rule_id ) p lb ) ); | 1 -> - field_level := ( + field_this_version := ( Some ( ( - read_error_severity + read_version ) p lb ) ); | 2 -> - field_type_ := ( - Some ( - ( - read_error_type - ) p lb - ) - ); - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_rule_id := ( - Some ( - ( - read_rule_id - ) p lb - ) - ); - ) - | 4 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_message := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_path := ( - Some ( - ( - read_fpath - ) p lb - ) - ); - ) - | 6 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_long_msg := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 7 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_short_msg := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 8 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_spans := ( + field_min_version := ( Some ( ( - read__error_span_list + read_version ) p lb ) ); ) - | 9 -> + | 3 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_help := ( + field_max_version := ( Some ( ( - Atdgen_runtime.Oj_run.read_string + read_version ) p lb ) ); @@ -22716,99 +20815,44 @@ let read_cli_error = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); match len with - | 4 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 'e' then ( - 0 - ) - else ( - -1 - ) - ) - | 'h' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'p' then ( - 9 - ) - else ( - -1 - ) - ) - | 'p' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' then ( - 5 - ) - else ( - -1 - ) - ) - | 't' -> ( - if String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'e' then ( - 2 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 5 -> ( - match String.unsafe_get s pos with - | 'l' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'v' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'l' then ( - 1 - ) - else ( - -1 - ) - ) - | 's' -> ( - if String.unsafe_get s (pos+1) = 'p' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = 's' then ( - 8 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) | 7 -> ( - match String.unsafe_get s pos with - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = 'e' then ( - 4 - ) - else ( - -1 + 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) = '_' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'd' then ( + 0 + ) + else ( + -1 + ) + ) + | 11 -> ( + if String.unsafe_get s pos = 'm' then ( + match String.unsafe_get s (pos+1) with + | 'a' -> ( + if String.unsafe_get s (pos+2) = 'x' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'v' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' then ( + 3 + ) + else ( + -1 + ) ) - ) - | 'r' -> ( - if 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) = '_' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'd' then ( - 3 + | 'i' -> ( + if String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'v' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' then ( + 2 + ) + else ( + -1 + ) ) - else ( + | _ -> ( -1 ) - ) - | _ -> ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'l' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'm' && String.unsafe_get s (pos+6) = 's' && String.unsafe_get s (pos+7) = 'g' then ( - 6 ) else ( -1 ) ) - | 9 -> ( - if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'g' then ( - 7 + | 12 -> ( + if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'v' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 's' && String.unsafe_get s (pos+9) = 'i' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'n' then ( + 1 ) else ( -1 @@ -22823,95 +20867,37 @@ let read_cli_error = ( ( match i with | 0 -> - field_code := ( + field_rule_id := ( Some ( ( - Atdgen_runtime.Oj_run.read_int + read_rule_id ) p lb ) ); | 1 -> - field_level := ( + field_this_version := ( Some ( ( - read_error_severity + read_version ) p lb ) ); | 2 -> - field_type_ := ( - Some ( - ( - read_error_type - ) p lb - ) - ); - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_rule_id := ( - Some ( - ( - read_rule_id - ) p lb - ) - ); - ) - | 4 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_message := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 5 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_path := ( - Some ( - ( - read_fpath - ) p lb - ) - ); - ) - | 6 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_long_msg := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 7 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_short_msg := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 8 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_spans := ( + field_min_version := ( Some ( ( - read__error_span_list + read_version ) p lb ) ); ) - | 9 -> + | 3 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_help := ( + field_max_version := ( Some ( ( - Atdgen_runtime.Oj_run.read_string + read_version ) p lb ) ); @@ -22925,128 +20911,70 @@ let read_cli_error = ( with Yojson.End_of_object -> ( ( { - code = (match !field_code with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "code"); - level = (match !field_level with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "level"); - type_ = (match !field_type_ with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "type_"); - rule_id = !field_rule_id; - message = !field_message; - path = !field_path; - long_msg = !field_long_msg; - short_msg = !field_short_msg; - spans = !field_spans; - help = !field_help; + rule_id = (match !field_rule_id with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "rule_id"); + this_version = (match !field_this_version with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "this_version"); + min_version = !field_min_version; + max_version = !field_max_version; } - : cli_error) + : incompatible_rule) ) ) -let cli_error_of_string s = - read_cli_error (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__cli_match_list = ( - Atdgen_runtime.Oj_run.write_list ( - write_cli_match - ) -) -let string_of__cli_match_list ?(len = 1024) x = - let ob = Buffer.create len in - write__cli_match_list ob x; - Buffer.contents ob -let read__cli_match_list = ( - Atdgen_runtime.Oj_run.read_list ( - read_cli_match - ) -) -let _cli_match_list_of_string s = - read__cli_match_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__cli_error_list = ( - Atdgen_runtime.Oj_run.write_list ( - write_cli_error - ) -) -let string_of__cli_error_list ?(len = 1024) x = - let ob = Buffer.create len in - write__cli_error_list ob x; - Buffer.contents ob -let read__cli_error_list = ( - Atdgen_runtime.Oj_run.read_list ( - read_cli_error - ) -) -let _cli_error_list_of_string s = - read__cli_error_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_sarif_format_params : _ -> sarif_format_params -> _ = ( - fun ob (x : sarif_format_params) -> +let incompatible_rule_of_string s = + read_incompatible_rule (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_finding_hashes : _ -> finding_hashes -> _ = ( + fun ob (x : finding_hashes) -> Buffer.add_char ob '{'; let is_first = ref true in if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"rules\":"; - ( - write_fpath - ) - ob x.rules; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"cli_matches\":"; - ( - write__cli_match_list - ) - ob x.cli_matches; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"cli_errors\":"; + Buffer.add_string ob "\"start_line_hash\":"; ( - write__cli_error_list + Yojson.Safe.write_string ) - ob x.cli_errors; + ob x.start_line_hash; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"hide_nudge\":"; + Buffer.add_string ob "\"end_line_hash\":"; ( - Yojson.Safe.write_bool + Yojson.Safe.write_string ) - ob x.hide_nudge; + ob x.end_line_hash; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"engine_label\":"; + Buffer.add_string ob "\"code_hash\":"; ( Yojson.Safe.write_string ) - ob x.engine_label; + ob x.code_hash; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"show_dataflow_traces\":"; + Buffer.add_string ob "\"pattern_hash\":"; ( - Yojson.Safe.write_bool + Yojson.Safe.write_string ) - ob x.show_dataflow_traces; + ob x.pattern_hash; Buffer.add_char ob '}'; ) -let string_of_sarif_format_params ?(len = 1024) x = +let string_of_finding_hashes ?(len = 1024) x = let ob = Buffer.create len in - write_sarif_format_params ob x; + write_finding_hashes ob x; Buffer.contents ob -let read_sarif_format_params = ( +let read_finding_hashes = ( fun p lb -> Yojson.Safe.read_space p lb; Yojson.Safe.read_lcurl p lb; - 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 + let field_start_line_hash = ref (None) in + let field_end_line_hash = ref (None) in + let field_code_hash = ref (None) in + let field_pattern_hash = ref (None) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; @@ -23056,55 +20984,33 @@ let read_sarif_format_params = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); 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 ( - 0 + | 9 -> ( + if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && 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) = 'h' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'h' then ( + 2 ) else ( -1 ) ) - | 10 -> ( - 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 ( - 2 - ) - else ( - -1 - ) - ) - | '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 ( - 3 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 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 ( - 1 + | 12 -> ( + if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'h' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 's' && String.unsafe_get s (pos+11) = 'h' then ( + 3 ) else ( -1 ) ) - | 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 ( - 4 + | 13 -> ( + if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 'h' && String.unsafe_get s (pos+10) = 'a' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 'h' then ( + 1 ) else ( -1 ) ) - | 20 -> ( - if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'w' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'f' && String.unsafe_get s (pos+10) = 'l' && String.unsafe_get s (pos+11) = 'o' && String.unsafe_get s (pos+12) = 'w' && String.unsafe_get s (pos+13) = '_' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'r' && String.unsafe_get s (pos+16) = 'a' && String.unsafe_get s (pos+17) = 'c' && String.unsafe_get s (pos+18) = 'e' && String.unsafe_get s (pos+19) = 's' then ( - 5 + | 15 -> ( + if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'h' && String.unsafe_get s (pos+12) = 'a' && String.unsafe_get s (pos+13) = 's' && String.unsafe_get s (pos+14) = 'h' then ( + 0 ) else ( -1 @@ -23119,50 +21025,34 @@ let read_sarif_format_params = ( ( match i with | 0 -> - field_rules := ( + field_start_line_hash := ( Some ( ( - read_fpath + Atdgen_runtime.Oj_run.read_string ) p lb ) ); | 1 -> - field_cli_matches := ( - Some ( - ( - read__cli_match_list - ) p lb - ) - ); - | 2 -> - field_cli_errors := ( - Some ( - ( - read__cli_error_list - ) p lb - ) - ); - | 3 -> - field_hide_nudge := ( + field_end_line_hash := ( Some ( ( - Atdgen_runtime.Oj_run.read_bool + Atdgen_runtime.Oj_run.read_string ) p lb ) ); - | 4 -> - field_engine_label := ( + | 2 -> + field_code_hash := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); - | 5 -> - field_show_dataflow_traces := ( + | 3 -> + field_pattern_hash := ( Some ( ( - Atdgen_runtime.Oj_run.read_bool + Atdgen_runtime.Oj_run.read_string ) p lb ) ); @@ -23179,55 +21069,33 @@ let read_sarif_format_params = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); 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 ( - 0 + | 9 -> ( + if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && 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) = 'h' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'h' then ( + 2 ) else ( -1 ) ) - | 10 -> ( - 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 ( - 2 - ) - else ( - -1 - ) - ) - | '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 ( - 3 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 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 ( - 1 + | 12 -> ( + if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'h' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 's' && String.unsafe_get s (pos+11) = 'h' then ( + 3 ) else ( -1 ) ) - | 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 ( - 4 + | 13 -> ( + if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 'h' && String.unsafe_get s (pos+10) = 'a' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 'h' then ( + 1 ) else ( -1 ) ) - | 20 -> ( - if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'w' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'f' && String.unsafe_get s (pos+10) = 'l' && String.unsafe_get s (pos+11) = 'o' && String.unsafe_get s (pos+12) = 'w' && String.unsafe_get s (pos+13) = '_' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'r' && String.unsafe_get s (pos+16) = 'a' && String.unsafe_get s (pos+17) = 'c' && String.unsafe_get s (pos+18) = 'e' && String.unsafe_get s (pos+19) = 's' then ( - 5 + | 15 -> ( + if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'h' && String.unsafe_get s (pos+12) = 'a' && String.unsafe_get s (pos+13) = 's' && String.unsafe_get s (pos+14) = 'h' then ( + 0 ) else ( -1 @@ -23242,53 +21110,37 @@ let read_sarif_format_params = ( ( match i with | 0 -> - field_rules := ( + field_start_line_hash := ( Some ( ( - read_fpath + Atdgen_runtime.Oj_run.read_string ) p lb ) ); | 1 -> - field_cli_matches := ( + field_end_line_hash := ( Some ( ( - read__cli_match_list + Atdgen_runtime.Oj_run.read_string ) p lb ) ); | 2 -> - field_cli_errors := ( + field_code_hash := ( Some ( ( - read__cli_error_list + Atdgen_runtime.Oj_run.read_string ) p lb ) ); | 3 -> - field_hide_nudge := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - | 4 -> - field_engine_label := ( + field_pattern_hash := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); - | 5 -> - field_show_dataflow_traces := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); | _ -> ( Yojson.Safe.skip_json p lb ) @@ -23298,465 +21150,427 @@ let read_sarif_format_params = ( with Yojson.End_of_object -> ( ( { - 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"); - 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"); + start_line_hash = (match !field_start_line_hash with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "start_line_hash"); + end_line_hash = (match !field_end_line_hash with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "end_line_hash"); + code_hash = (match !field_code_hash with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "code_hash"); + pattern_hash = (match !field_pattern_hash with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "pattern_hash"); } - : sarif_format_params) + : finding_hashes) ) ) -let sarif_format_params_of_string s = - read_sarif_format_params (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_engine_kind = ( - fun ob x -> - match x with - | `OSS -> Buffer.add_string ob "\"OSS\"" - | `PRO -> Buffer.add_string ob "\"PRO\"" -) -let string_of_engine_kind ?(len = 1024) x = - let ob = Buffer.create len in - write_engine_kind ob x; - Buffer.contents ob -let read_engine_kind = ( - 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 - | "OSS" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `OSS - | "PRO" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `PRO - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "OSS" -> - `OSS - | "PRO" -> - `PRO - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let engine_kind_of_string s = - read_engine_kind (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_rule_id_and_engine_kind = ( - fun ob x -> - Buffer.add_char ob '['; - (let x, _ = x in - ( - write_rule_id - ) ob x - ); - Buffer.add_char ob ','; - (let _, x = x in - ( - write_engine_kind - ) ob x - ); - Buffer.add_char ob ']'; -) -let string_of_rule_id_and_engine_kind ?(len = 1024) x = - let ob = Buffer.create len in - write_rule_id_and_engine_kind ob x; - Buffer.contents ob -let read_rule_id_and_engine_kind = ( - 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_rule_id - ) 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_engine_kind - ) 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 ]); -) -let rule_id_and_engine_kind_of_string s = - read_rule_id_and_engine_kind (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__resolution_error_list = ( - Atdgen_runtime.Oj_run.write_list ( - write_resolution_error - ) -) -let string_of__resolution_error_list ?(len = 1024) x = - let ob = Buffer.create len in - write__resolution_error_list ob x; - Buffer.contents ob -let read__resolution_error_list = ( - Atdgen_runtime.Oj_run.read_list ( - read_resolution_error - ) -) -let _resolution_error_list_of_string s = - read__resolution_error_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__found_dependency_list = ( - Atdgen_runtime.Oj_run.write_list ( - write_found_dependency - ) -) -let string_of__found_dependency_list ?(len = 1024) x = - let ob = Buffer.create len in - write__found_dependency_list ob x; - Buffer.contents ob -let read__found_dependency_list = ( - Atdgen_runtime.Oj_run.read_list ( - read_found_dependency - ) -) -let _found_dependency_list_of_string s = - read__found_dependency_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_resolution_result = ( - fun ob x -> - match x with - | `ResolutionOk x -> - Buffer.add_string ob "[\"ResolutionOk\","; - ( - fun ob x -> - Buffer.add_char ob '['; - (let x, _ = x in - ( - write__found_dependency_list - ) ob x - ); - Buffer.add_char ob ','; - (let _, x = x in - ( - write__resolution_error_list - ) ob x - ); - Buffer.add_char ob ']'; - ) ob x; - Buffer.add_char ob ']' - | `ResolutionError x -> - Buffer.add_string ob "[\"ResolutionError\","; - ( - write__resolution_error_list - ) ob x; - Buffer.add_char ob ']' -) -let string_of_resolution_result ?(len = 1024) x = +let finding_hashes_of_string s = + read_finding_hashes (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__string_list_option = ( + Atdgen_runtime.Oj_run.write_std_option ( + write__string_list + ) +) +let string_of__string_list_option ?(len = 1024) x = let ob = Buffer.create len in - write_resolution_result ob x; + write__string_list_option ob x; Buffer.contents ob -let read_resolution_result = ( +let read__string_list_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 - | "ResolutionOk" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - 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__found_dependency_list - ) 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__resolution_error_list - ) 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 + | "None" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - `ResolutionOk x - | "ResolutionError" -> + (None : _ option) + | "Some" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( - read__resolution_error_list + read__string_list ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - `ResolutionError x + (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 - | "ResolutionOk" -> + | "Some" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; let x = ( - 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__found_dependency_list - ) 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__resolution_error_list - ) 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 ]); + read__string_list ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; - `ResolutionOk x - | "ResolutionError" -> + (Some x : _ option) + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) +) +let _string_list_option_of_string s = + read__string_list_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__finding_hashes_option = ( + Atdgen_runtime.Oj_run.write_std_option ( + write_finding_hashes + ) +) +let string_of__finding_hashes_option ?(len = 1024) x = + let ob = Buffer.create len in + write__finding_hashes_option ob x; + Buffer.contents ob +let read__finding_hashes_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_finding_hashes + ) 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__resolution_error_list + read_finding_hashes ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; - `ResolutionError x + (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) -let resolution_result_of_string s = - read_resolution_result (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__x_d81b58a = ( - Atdgen_runtime.Oj_run.write_assoc_list ( - Yojson.Safe.write_string - ) ( - Yojson.Safe.write_std_float - ) -) -let string_of__x_d81b58a ?(len = 1024) x = - let ob = Buffer.create len in - write__x_d81b58a ob x; - Buffer.contents ob -let read__x_d81b58a = ( - Atdgen_runtime.Oj_run.read_assoc_list ( - Atdgen_runtime.Oj_run.read_string - ) ( - Atdgen_runtime.Oj_run.read_number - ) -) -let _x_d81b58a_of_string s = - read__x_d81b58a (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__target_times_list = ( - Atdgen_runtime.Oj_run.write_list ( - write_target_times - ) -) -let string_of__target_times_list ?(len = 1024) x = - let ob = Buffer.create len in - write__target_times_list ob x; - Buffer.contents ob -let read__target_times_list = ( - Atdgen_runtime.Oj_run.read_list ( - read_target_times - ) -) -let _target_times_list_of_string s = - read__target_times_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__rule_id_list = ( - Atdgen_runtime.Oj_run.write_list ( - write_rule_id +let _finding_hashes_option_of_string s = + read__finding_hashes_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__engine_of_finding_option = ( + Atdgen_runtime.Oj_run.write_std_option ( + write_engine_of_finding ) ) -let string_of__rule_id_list ?(len = 1024) x = +let string_of__engine_of_finding_option ?(len = 1024) x = let ob = Buffer.create len in - write__rule_id_list ob x; + write__engine_of_finding_option ob x; Buffer.contents ob -let read__rule_id_list = ( - Atdgen_runtime.Oj_run.read_list ( - read_rule_id - ) +let read__engine_of_finding_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_engine_of_finding + ) 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_engine_of_finding + ) 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 _rule_id_list_of_string s = - read__rule_id_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_profile : _ -> profile -> _ = ( - fun ob (x : profile) -> +let _engine_of_finding_option_of_string s = + read__engine_of_finding_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_finding : _ -> finding -> _ = ( + fun ob (x : finding) -> Buffer.add_char ob '{'; let is_first = ref true in if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"rules\":"; + Buffer.add_string ob "\"check_id\":"; ( - write__rule_id_list + write_rule_id ) - ob x.rules; + ob x.check_id; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"rules_parse_time\":"; + Buffer.add_string ob "\"path\":"; ( - Yojson.Safe.write_std_float + write_fpath ) - ob x.rules_parse_time; + ob x.path; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"profiling_times\":"; + Buffer.add_string ob "\"line\":"; ( - write__x_d81b58a + Yojson.Safe.write_int ) - ob x.profiling_times; + ob x.line; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"targets\":"; + Buffer.add_string ob "\"column\":"; ( - write__target_times_list + Yojson.Safe.write_int ) - ob x.targets; + ob x.column; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"total_bytes\":"; + Buffer.add_string ob "\"end_line\":"; ( Yojson.Safe.write_int ) - ob x.total_bytes; - (match x.max_memory_bytes with None -> () | Some x -> + ob x.end_line; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"end_column\":"; + ( + Yojson.Safe.write_int + ) + ob x.end_column; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"message\":"; + ( + Yojson.Safe.write_string + ) + ob x.message; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"severity\":"; + ( + Yojson.Safe.write_json + ) + ob x.severity; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"index\":"; + ( + Yojson.Safe.write_int + ) + ob x.index; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"commit_date\":"; + ( + Yojson.Safe.write_string + ) + ob x.commit_date; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"syntactic_id\":"; + ( + Yojson.Safe.write_string + ) + ob x.syntactic_id; + (match x.match_based_id with None -> () | Some x -> if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"max_memory_bytes\":"; + Buffer.add_string ob "\"match_based_id\":"; ( - Yojson.Safe.write_int + Yojson.Safe.write_string + ) + ob x; + ); + (match x.hashes with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"hashes\":"; + ( + write_finding_hashes + ) + ob x; + ); + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"metadata\":"; + ( + write_raw_json + ) + ob x.metadata; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"is_blocking\":"; + ( + Yojson.Safe.write_bool + ) + ob x.is_blocking; + (match x.fixed_lines with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"fixed_lines\":"; + ( + write__string_list + ) + ob x; + ); + (match x.sca_info with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"sca_info\":"; + ( + write_sca_match + ) + ob x; + ); + (match x.dataflow_trace with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"dataflow_trace\":"; + ( + write_match_dataflow_trace + ) + ob x; + ); + (match x.validation_state with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"validation_state\":"; + ( + write_validation_state + ) + ob x; + ); + (match x.historical_info with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"historical_info\":"; + ( + write_historical_info + ) + ob x; + ); + (match x.engine_kind with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"engine_kind\":"; + ( + write_engine_of_finding ) ob x; ); Buffer.add_char ob '}'; ) -let string_of_profile ?(len = 1024) x = +let string_of_finding ?(len = 1024) x = let ob = Buffer.create len in - write_profile ob x; + write_finding ob x; Buffer.contents ob -let read_profile = ( +let read_finding = ( fun p lb -> Yojson.Safe.read_space p lb; Yojson.Safe.read_lcurl p lb; - let field_rules = ref (None) in - let field_rules_parse_time = ref (None) in - let field_profiling_times = ref (None) in - let field_targets = ref (None) in - let field_total_bytes = ref (None) in - let field_max_memory_bytes = ref (None) in + let field_check_id = ref (None) in + let field_path = ref (None) in + let field_line = ref (None) in + let field_column = ref (None) in + let field_end_line = ref (None) in + let field_end_column = ref (None) in + let field_message = ref (None) in + let field_severity = ref (None) in + let field_index = ref (None) in + let field_commit_date = ref (None) in + let field_syntactic_id = ref (None) in + let field_match_based_id = ref (None) in + let field_hashes = ref (None) in + let field_metadata = ref (None) in + let field_is_blocking = ref (None) in + let field_fixed_lines = ref (None) in + let field_sca_info = ref (None) in + let field_dataflow_trace = ref (None) in + let field_validation_state = ref (None) in + let field_historical_info = ref (None) in + let field_engine_kind = ref (None) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; @@ -23766,51 +21580,185 @@ let read_profile = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); match len with + | 4 -> ( + match String.unsafe_get s pos with + | 'l' -> ( + if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'e' then ( + 2 + ) + else ( + -1 + ) + ) + | 'p' -> ( + if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' then ( + 1 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) | 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 ( - 0 + if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'x' then ( + 8 ) else ( -1 ) ) + | 6 -> ( + match String.unsafe_get s pos with + | 'c' -> ( + if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'u' && String.unsafe_get s (pos+4) = 'm' && String.unsafe_get s (pos+5) = 'n' then ( + 3 + ) + else ( + -1 + ) + ) + | 'h' -> ( + if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'h' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 's' then ( + 12 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) | 7 -> ( - if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 's' then ( - 3 + if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = 'e' then ( + 6 ) else ( -1 ) ) - | 11 -> ( - if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'b' && String.unsafe_get s (pos+7) = 'y' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 's' then ( - 4 + | 8 -> ( + match String.unsafe_get s pos with + | 'c' -> ( + if String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'k' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( + 0 + ) + else ( + -1 + ) + ) + | 'e' -> ( + if String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'e' then ( + 4 + ) + else ( + -1 + ) + ) + | 'm' -> ( + if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'a' then ( + 13 + ) + else ( + -1 + ) + ) + | 's' -> ( + match String.unsafe_get s (pos+1) with + | 'c' -> ( + if String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'f' && String.unsafe_get s (pos+7) = 'o' then ( + 16 + ) + else ( + -1 + ) + ) + | 'e' -> ( + if String.unsafe_get s (pos+2) = 'v' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'y' then ( + 7 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | 10 -> ( + if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'c' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'u' && String.unsafe_get s (pos+8) = 'm' && String.unsafe_get s (pos+9) = 'n' then ( + 5 ) else ( -1 ) ) - | 15 -> ( - 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) = 'f' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'l' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'g' && String.unsafe_get s (pos+9) = '_' && String.unsafe_get s (pos+10) = 't' && String.unsafe_get s (pos+11) = 'i' && String.unsafe_get s (pos+12) = 'm' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 's' then ( - 2 + | 11 -> ( + match String.unsafe_get s pos with + | 'c' -> ( + if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'd' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'e' then ( + 9 + ) + else ( + -1 + ) + ) + | 'e' -> ( + if 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) = 'k' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'd' then ( + 20 + ) + else ( + -1 + ) + ) + | 'f' -> ( + if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'x' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 's' then ( + 15 + ) + else ( + -1 + ) + ) + | 'i' -> ( + if String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'b' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'c' && String.unsafe_get s (pos+7) = 'k' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'g' then ( + 14 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | 12 -> ( + if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'c' && String.unsafe_get s (pos+9) = '_' && String.unsafe_get s (pos+10) = 'i' && String.unsafe_get s (pos+11) = 'd' then ( + 10 ) else ( -1 ) ) - | 16 -> ( + | 14 -> ( match String.unsafe_get s pos with - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'x' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'm' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'o' && String.unsafe_get s (pos+8) = 'r' && String.unsafe_get s (pos+9) = 'y' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'b' && String.unsafe_get s (pos+12) = 'y' && String.unsafe_get s (pos+13) = 't' && String.unsafe_get s (pos+14) = 'e' && String.unsafe_get s (pos+15) = 's' then ( - 5 + | 'd' -> ( + if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'f' && String.unsafe_get s (pos+5) = 'l' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'w' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'r' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 'c' && String.unsafe_get s (pos+13) = 'e' then ( + 17 ) else ( -1 ) ) - | 'r' -> ( - if 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' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'p' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 'r' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'i' && String.unsafe_get s (pos+14) = 'm' && String.unsafe_get s (pos+15) = 'e' then ( - 1 + | 'm' -> ( + if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'h' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'b' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 's' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 'd' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 'i' && String.unsafe_get s (pos+13) = 'd' then ( + 11 ) else ( -1 @@ -23820,6 +21768,22 @@ let read_profile = ( -1 ) ) + | 15 -> ( + if String.unsafe_get s pos = 'h' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'i' && String.unsafe_get s (pos+12) = 'n' && String.unsafe_get s (pos+13) = 'f' && String.unsafe_get s (pos+14) = 'o' then ( + 19 + ) + else ( + -1 + ) + ) + | 16 -> ( + if String.unsafe_get s pos = 'v' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'e' then ( + 18 + ) + else ( + -1 + ) + ) | _ -> ( -1 ) @@ -23829,51 +21793,185 @@ let read_profile = ( ( match i with | 0 -> - field_rules := ( + field_check_id := ( Some ( ( - read__rule_id_list + read_rule_id ) p lb ) ); | 1 -> - field_rules_parse_time := ( + field_path := ( Some ( ( - Atdgen_runtime.Oj_run.read_number + read_fpath ) p lb ) ); | 2 -> - field_profiling_times := ( + field_line := ( Some ( ( - read__x_d81b58a + Atdgen_runtime.Oj_run.read_int ) p lb ) ); | 3 -> - field_targets := ( + field_column := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 4 -> + field_end_line := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 5 -> + field_end_column := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 6 -> + field_message := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + | 7 -> + field_severity := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_json + ) p lb + ) + ); + | 8 -> + field_index := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 9 -> + field_commit_date := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + | 10 -> + field_syntactic_id := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + | 11 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_match_based_id := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + ) + | 12 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_hashes := ( + Some ( + ( + read_finding_hashes + ) p lb + ) + ); + ) + | 13 -> + field_metadata := ( Some ( ( - read__target_times_list + read_raw_json ) p lb ) ); - | 4 -> - field_total_bytes := ( + | 14 -> + field_is_blocking := ( Some ( ( - Atdgen_runtime.Oj_run.read_int + Atdgen_runtime.Oj_run.read_bool ) p lb ) ); - | 5 -> + | 15 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_max_memory_bytes := ( + field_fixed_lines := ( Some ( ( - Atdgen_runtime.Oj_run.read_int + read__string_list + ) p lb + ) + ); + ) + | 16 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_sca_info := ( + Some ( + ( + read_sca_match + ) p lb + ) + ); + ) + | 17 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_dataflow_trace := ( + Some ( + ( + read_match_dataflow_trace + ) p lb + ) + ); + ) + | 18 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_validation_state := ( + Some ( + ( + read_validation_state + ) p lb + ) + ); + ) + | 19 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_historical_info := ( + Some ( + ( + read_historical_info + ) p lb + ) + ); + ) + | 20 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_engine_kind := ( + Some ( + ( + read_engine_of_finding ) p lb ) ); @@ -23891,51 +21989,185 @@ let read_profile = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); match len with + | 4 -> ( + match String.unsafe_get s pos with + | 'l' -> ( + if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'e' then ( + 2 + ) + else ( + -1 + ) + ) + | 'p' -> ( + if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' then ( + 1 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) | 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 ( - 0 + if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'x' then ( + 8 ) else ( -1 ) ) + | 6 -> ( + match String.unsafe_get s pos with + | 'c' -> ( + if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'u' && String.unsafe_get s (pos+4) = 'm' && String.unsafe_get s (pos+5) = 'n' then ( + 3 + ) + else ( + -1 + ) + ) + | 'h' -> ( + if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'h' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 's' then ( + 12 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) | 7 -> ( - if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 's' then ( - 3 + if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = 'e' then ( + 6 ) else ( -1 ) ) - | 11 -> ( - if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'b' && String.unsafe_get s (pos+7) = 'y' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 's' then ( - 4 + | 8 -> ( + match String.unsafe_get s pos with + | 'c' -> ( + if String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'k' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( + 0 + ) + else ( + -1 + ) + ) + | 'e' -> ( + if String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'e' then ( + 4 + ) + else ( + -1 + ) + ) + | 'm' -> ( + if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'a' then ( + 13 + ) + else ( + -1 + ) + ) + | 's' -> ( + match String.unsafe_get s (pos+1) with + | 'c' -> ( + if String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'f' && String.unsafe_get s (pos+7) = 'o' then ( + 16 + ) + else ( + -1 + ) + ) + | 'e' -> ( + if String.unsafe_get s (pos+2) = 'v' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'y' then ( + 7 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | 10 -> ( + if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'c' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'u' && String.unsafe_get s (pos+8) = 'm' && String.unsafe_get s (pos+9) = 'n' then ( + 5 ) else ( -1 ) ) - | 15 -> ( - 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) = 'f' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'l' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'g' && String.unsafe_get s (pos+9) = '_' && String.unsafe_get s (pos+10) = 't' && String.unsafe_get s (pos+11) = 'i' && String.unsafe_get s (pos+12) = 'm' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 's' then ( - 2 + | 11 -> ( + match String.unsafe_get s pos with + | 'c' -> ( + if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'd' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'e' then ( + 9 + ) + else ( + -1 + ) + ) + | 'e' -> ( + if 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) = 'k' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'd' then ( + 20 + ) + else ( + -1 + ) + ) + | 'f' -> ( + if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'x' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 's' then ( + 15 + ) + else ( + -1 + ) + ) + | 'i' -> ( + if String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'b' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'c' && String.unsafe_get s (pos+7) = 'k' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'g' then ( + 14 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | 12 -> ( + if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'c' && String.unsafe_get s (pos+9) = '_' && String.unsafe_get s (pos+10) = 'i' && String.unsafe_get s (pos+11) = 'd' then ( + 10 ) else ( -1 ) ) - | 16 -> ( + | 14 -> ( match String.unsafe_get s pos with - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'x' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'm' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'o' && String.unsafe_get s (pos+8) = 'r' && String.unsafe_get s (pos+9) = 'y' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'b' && String.unsafe_get s (pos+12) = 'y' && String.unsafe_get s (pos+13) = 't' && String.unsafe_get s (pos+14) = 'e' && String.unsafe_get s (pos+15) = 's' then ( - 5 + | 'd' -> ( + if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'f' && String.unsafe_get s (pos+5) = 'l' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'w' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'r' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 'c' && String.unsafe_get s (pos+13) = 'e' then ( + 17 ) else ( -1 ) ) - | 'r' -> ( - if 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' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'p' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 'r' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'i' && String.unsafe_get s (pos+14) = 'm' && String.unsafe_get s (pos+15) = 'e' then ( - 1 + | 'm' -> ( + if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'h' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'b' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 's' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 'd' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 'i' && String.unsafe_get s (pos+13) = 'd' then ( + 11 ) else ( -1 @@ -23945,6 +22177,22 @@ let read_profile = ( -1 ) ) + | 15 -> ( + if String.unsafe_get s pos = 'h' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'i' && String.unsafe_get s (pos+12) = 'n' && String.unsafe_get s (pos+13) = 'f' && String.unsafe_get s (pos+14) = 'o' then ( + 19 + ) + else ( + -1 + ) + ) + | 16 -> ( + if String.unsafe_get s pos = 'v' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'e' then ( + 18 + ) + else ( + -1 + ) + ) | _ -> ( -1 ) @@ -23954,39 +22202,39 @@ let read_profile = ( ( match i with | 0 -> - field_rules := ( + field_check_id := ( Some ( ( - read__rule_id_list + read_rule_id ) p lb ) ); | 1 -> - field_rules_parse_time := ( + field_path := ( Some ( ( - Atdgen_runtime.Oj_run.read_number + read_fpath ) p lb ) ); | 2 -> - field_profiling_times := ( + field_line := ( Some ( ( - read__x_d81b58a + Atdgen_runtime.Oj_run.read_int ) p lb ) ); | 3 -> - field_targets := ( + field_column := ( Some ( ( - read__target_times_list + Atdgen_runtime.Oj_run.read_int ) p lb ) ); | 4 -> - field_total_bytes := ( + field_end_line := ( Some ( ( Atdgen_runtime.Oj_run.read_int @@ -23994,11 +22242,145 @@ let read_profile = ( ) ); | 5 -> + field_end_column := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 6 -> + field_message := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + | 7 -> + field_severity := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_json + ) p lb + ) + ); + | 8 -> + field_index := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 9 -> + field_commit_date := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + | 10 -> + field_syntactic_id := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + | 11 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_max_memory_bytes := ( + field_match_based_id := ( Some ( ( - Atdgen_runtime.Oj_run.read_int + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + ) + | 12 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_hashes := ( + Some ( + ( + read_finding_hashes + ) p lb + ) + ); + ) + | 13 -> + field_metadata := ( + Some ( + ( + read_raw_json + ) p lb + ) + ); + | 14 -> + field_is_blocking := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | 15 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_fixed_lines := ( + Some ( + ( + read__string_list + ) p lb + ) + ); + ) + | 16 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_sca_info := ( + Some ( + ( + read_sca_match + ) p lb + ) + ); + ) + | 17 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_dataflow_trace := ( + Some ( + ( + read_match_dataflow_trace + ) p lb + ) + ); + ) + | 18 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_validation_state := ( + Some ( + ( + read_validation_state + ) p lb + ) + ); + ) + | 19 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_historical_info := ( + Some ( + ( + read_historical_info + ) p lb + ) + ); + ) + | 20 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_engine_kind := ( + Some ( + ( + read_engine_of_finding ) p lb ) ); @@ -24012,506 +22394,442 @@ let read_profile = ( with Yojson.End_of_object -> ( ( { - rules = (match !field_rules with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "rules"); - rules_parse_time = (match !field_rules_parse_time with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "rules_parse_time"); - profiling_times = (match !field_profiling_times with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "profiling_times"); - targets = (match !field_targets with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "targets"); - total_bytes = (match !field_total_bytes with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "total_bytes"); - max_memory_bytes = !field_max_memory_bytes; + check_id = (match !field_check_id with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "check_id"); + path = (match !field_path with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "path"); + line = (match !field_line with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "line"); + column = (match !field_column with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "column"); + end_line = (match !field_end_line with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "end_line"); + end_column = (match !field_end_column with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "end_column"); + message = (match !field_message with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "message"); + severity = (match !field_severity with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "severity"); + index = (match !field_index with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "index"); + commit_date = (match !field_commit_date with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "commit_date"); + syntactic_id = (match !field_syntactic_id with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "syntactic_id"); + match_based_id = !field_match_based_id; + hashes = !field_hashes; + metadata = (match !field_metadata with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "metadata"); + is_blocking = (match !field_is_blocking with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "is_blocking"); + fixed_lines = !field_fixed_lines; + sca_info = !field_sca_info; + dataflow_trace = !field_dataflow_trace; + validation_state = !field_validation_state; + historical_info = !field_historical_info; + engine_kind = !field_engine_kind; } - : profile) + : finding) ) ) -let profile_of_string s = - read_profile (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_parsing_stats : _ -> parsing_stats -> _ = ( - fun ob (x : parsing_stats) -> - Buffer.add_char ob '{'; - let is_first = ref true in - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"targets_parsed\":"; - ( - Yojson.Safe.write_int - ) - ob x.targets_parsed; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"num_targets\":"; - ( - Yojson.Safe.write_int - ) - ob x.num_targets; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"bytes_parsed\":"; - ( - Yojson.Safe.write_int - ) - ob x.bytes_parsed; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"num_bytes\":"; - ( - Yojson.Safe.write_int - ) - ob x.num_bytes; - Buffer.add_char ob '}'; +let finding_of_string s = + read_finding (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__location_list = ( + Atdgen_runtime.Oj_run.write_list ( + write_location + ) +) +let string_of__location_list ?(len = 1024) x = + let ob = Buffer.create len in + write__location_list ob x; + Buffer.contents ob +let read__location_list = ( + Atdgen_runtime.Oj_run.read_list ( + read_location + ) +) +let _location_list_of_string s = + read__location_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_error_type : _ -> error_type -> _ = ( + fun ob (x : error_type) -> + match x with + | LexicalError -> Buffer.add_string ob "\"Lexical error\"" + | ParseError -> Buffer.add_string ob "\"Syntax error\"" + | OtherParseError -> Buffer.add_string ob "\"Other syntax error\"" + | AstBuilderError -> Buffer.add_string ob "\"AST builder error\"" + | RuleParseError -> Buffer.add_string ob "\"Rule parse error\"" + | SemgrepWarning -> Buffer.add_string ob "\"SemgrepWarning\"" + | SemgrepError -> Buffer.add_string ob "\"SemgrepError\"" + | InvalidRuleSchemaError -> Buffer.add_string ob "\"InvalidRuleSchemaError\"" + | UnknownLanguageError -> Buffer.add_string ob "\"UnknownLanguageError\"" + | InvalidYaml -> Buffer.add_string ob "\"Invalid YAML\"" + | MatchingError -> Buffer.add_string ob "\"Internal matching error\"" + | SemgrepMatchFound -> Buffer.add_string ob "\"Semgrep match found\"" + | TooManyMatches -> Buffer.add_string ob "\"Too many matches\"" + | FatalError -> Buffer.add_string ob "\"Fatal error\"" + | Timeout -> Buffer.add_string ob "\"Timeout\"" + | OutOfMemory -> Buffer.add_string ob "\"Out of memory\"" + | StackOverflow -> Buffer.add_string ob "\"Stack overflow\"" + | TimeoutDuringInterfile -> Buffer.add_string ob "\"Timeout during interfile analysis\"" + | OutOfMemoryDuringInterfile -> Buffer.add_string ob "\"OOM during interfile analysis\"" + | MissingPlugin -> Buffer.add_string ob "\"Missing plugin\"" + | PatternParseError x -> + Buffer.add_string ob "[\"PatternParseError\","; + ( + write__string_list + ) ob x; + Buffer.add_char ob ']' + | PartialParsing x -> + Buffer.add_string ob "[\"PartialParsing\","; + ( + write__location_list + ) ob x; + Buffer.add_char ob ']' + | IncompatibleRule x -> + Buffer.add_string ob "[\"IncompatibleRule\","; + ( + write_incompatible_rule + ) ob x; + Buffer.add_char ob ']' + | PatternParseError0 -> Buffer.add_string ob "\"Pattern parse error\"" + | IncompatibleRule0 -> Buffer.add_string ob "\"Incompatible rule\"" + | DependencyResolutionError x -> + Buffer.add_string ob "[\"DependencyResolutionError\","; + ( + write_resolution_error + ) ob x; + Buffer.add_char ob ']' ) -let string_of_parsing_stats ?(len = 1024) x = +let string_of_error_type ?(len = 1024) x = let ob = Buffer.create len in - write_parsing_stats ob x; + write_error_type ob x; Buffer.contents ob -let read_parsing_stats = ( +let read_error_type = ( fun p lb -> Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_targets_parsed = ref (None) in - let field_num_targets = ref (None) in - let field_bytes_parsed = ref (None) in - let field_num_bytes = ref (None) in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); - match len with - | 9 -> ( - if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'b' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 's' then ( - 3 - ) - else ( - -1 - ) - ) - | 11 -> ( - if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 'g' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 's' then ( - 1 - ) - else ( - -1 - ) - ) - | 12 -> ( - if String.unsafe_get s pos = 'b' && String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'p' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 'r' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 'd' then ( - 2 - ) - else ( - -1 - ) - ) - | 14 -> ( - if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 's' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'p' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 'r' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_targets_parsed := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int + match Yojson.Safe.start_any_variant p lb with + | `Edgy_bracket -> ( + match Yojson.Safe.read_ident p lb with + | "Lexical error" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (LexicalError : error_type) + | "Syntax error" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (ParseError : error_type) + | "Other syntax error" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (OtherParseError : error_type) + | "AST builder error" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (AstBuilderError : error_type) + | "Rule parse error" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (RuleParseError : error_type) + | "SemgrepWarning" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (SemgrepWarning : error_type) + | "SemgrepError" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (SemgrepError : error_type) + | "InvalidRuleSchemaError" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (InvalidRuleSchemaError : error_type) + | "UnknownLanguageError" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (UnknownLanguageError : error_type) + | "Invalid YAML" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (InvalidYaml : error_type) + | "Internal matching error" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (MatchingError : error_type) + | "Semgrep match found" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (SemgrepMatchFound : error_type) + | "Too many matches" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (TooManyMatches : error_type) + | "Fatal error" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (FatalError : error_type) + | "Timeout" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Timeout : error_type) + | "Out of memory" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (OutOfMemory : error_type) + | "Stack overflow" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (StackOverflow : error_type) + | "Timeout during interfile analysis" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (TimeoutDuringInterfile : error_type) + | "OOM during interfile analysis" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (OutOfMemoryDuringInterfile : error_type) + | "Missing plugin" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (MissingPlugin : error_type) + | "PatternParseError" -> + Atdgen_runtime.Oj_run.read_until_field_value p lb; + let x = ( + read__string_list + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (PatternParseError x : error_type) + | "PartialParsing" -> + Atdgen_runtime.Oj_run.read_until_field_value p lb; + let x = ( + read__location_list + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (PartialParsing x : error_type) + | "IncompatibleRule" -> + Atdgen_runtime.Oj_run.read_until_field_value p lb; + let x = ( + read_incompatible_rule + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (IncompatibleRule x : error_type) + | "Pattern parse error" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (PatternParseError0 : error_type) + | "Incompatible rule" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (IncompatibleRule0 : error_type) + | "DependencyResolutionError" -> + Atdgen_runtime.Oj_run.read_until_field_value p lb; + let x = ( + read_resolution_error + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (DependencyResolutionError x : error_type) + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Double_quote -> ( + match Yojson.Safe.finish_string p lb with + | "Lexical error" -> + (LexicalError : error_type) + | "Syntax error" -> + (ParseError : error_type) + | "Other syntax error" -> + (OtherParseError : error_type) + | "AST builder error" -> + (AstBuilderError : error_type) + | "Rule parse error" -> + (RuleParseError : error_type) + | "SemgrepWarning" -> + (SemgrepWarning : error_type) + | "SemgrepError" -> + (SemgrepError : error_type) + | "InvalidRuleSchemaError" -> + (InvalidRuleSchemaError : error_type) + | "UnknownLanguageError" -> + (UnknownLanguageError : error_type) + | "Invalid YAML" -> + (InvalidYaml : error_type) + | "Internal matching error" -> + (MatchingError : error_type) + | "Semgrep match found" -> + (SemgrepMatchFound : error_type) + | "Too many matches" -> + (TooManyMatches : error_type) + | "Fatal error" -> + (FatalError : error_type) + | "Timeout" -> + (Timeout : error_type) + | "Out of memory" -> + (OutOfMemory : error_type) + | "Stack overflow" -> + (StackOverflow : error_type) + | "Timeout during interfile analysis" -> + (TimeoutDuringInterfile : error_type) + | "OOM during interfile analysis" -> + (OutOfMemoryDuringInterfile : error_type) + | "Missing plugin" -> + (MissingPlugin : error_type) + | "Pattern parse error" -> + (PatternParseError0 : error_type) + | "Incompatible rule" -> + (IncompatibleRule0 : error_type) + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Square_bracket -> ( + match Atdgen_runtime.Oj_run.read_string p lb with + | "PatternParseError" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; + let x = ( + read__string_list ) p lb - ) - ); - | 1 -> - field_num_targets := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_rbr p lb; + (PatternParseError x : error_type) + | "PartialParsing" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; + let x = ( + read__location_list ) p lb - ) - ); - | 2 -> - field_bytes_parsed := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_rbr p lb; + (PartialParsing x : error_type) + | "IncompatibleRule" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; + let x = ( + read_incompatible_rule ) p lb - ) - ); - | 3 -> - field_num_bytes := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_rbr p lb; + (IncompatibleRule x : error_type) + | "DependencyResolutionError" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; + let x = ( + read_resolution_error ) p lb - ) - ); - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); - match len with - | 9 -> ( - if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'b' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 's' then ( - 3 - ) - else ( - -1 - ) - ) - | 11 -> ( - if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 'g' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 's' then ( - 1 - ) - else ( - -1 - ) - ) - | 12 -> ( - if String.unsafe_get s pos = 'b' && String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'p' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 'r' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 'd' then ( - 2 - ) - else ( - -1 - ) - ) - | 14 -> ( - if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 's' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'p' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 'r' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_targets_parsed := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - | 1 -> - field_num_targets := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - | 2 -> - field_bytes_parsed := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - | 3 -> - field_num_bytes := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - ( - { - targets_parsed = (match !field_targets_parsed with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "targets_parsed"); - num_targets = (match !field_num_targets with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "num_targets"); - bytes_parsed = (match !field_bytes_parsed with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "bytes_parsed"); - num_bytes = (match !field_num_bytes with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "num_bytes"); - } - : parsing_stats) - ) + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_rbr p lb; + (DependencyResolutionError x : error_type) + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) ) -let parsing_stats_of_string s = - read_parsing_stats (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_finding_hashes : _ -> finding_hashes -> _ = ( - fun ob (x : finding_hashes) -> - Buffer.add_char ob '{'; - let is_first = ref true in - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"start_line_hash\":"; - ( - Yojson.Safe.write_string - ) - ob x.start_line_hash; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"end_line_hash\":"; - ( - Yojson.Safe.write_string - ) - ob x.end_line_hash; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"code_hash\":"; - ( - Yojson.Safe.write_string - ) - ob x.code_hash; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"pattern_hash\":"; - ( - Yojson.Safe.write_string - ) - ob x.pattern_hash; - Buffer.add_char ob '}'; +let error_type_of_string s = + read_error_type (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__string_list_nullable = ( + Atdgen_runtime.Oj_run.write_nullable ( + write__string_list + ) +) +let string_of__string_list_nullable ?(len = 1024) x = + let ob = Buffer.create len in + write__string_list_nullable ob x; + Buffer.contents ob +let read__string_list_nullable = ( + fun p lb -> + Yojson.Safe.read_space p lb; + (if Yojson.Safe.read_null_if_possible p lb then None + else Some (( + read__string_list + ) p lb) : _ option) ) -let string_of_finding_hashes ?(len = 1024) x = +let _string_list_nullable_of_string s = + read__string_list_nullable (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__string_list_nullable_option = ( + Atdgen_runtime.Oj_run.write_std_option ( + write__string_list_nullable + ) +) +let string_of__string_list_nullable_option ?(len = 1024) x = let ob = Buffer.create len in - write_finding_hashes ob x; + write__string_list_nullable_option ob x; Buffer.contents ob -let read_finding_hashes = ( +let read__string_list_nullable_option = ( fun p lb -> Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_start_line_hash = ref (None) in - let field_end_line_hash = ref (None) in - let field_code_hash = ref (None) in - let field_pattern_hash = ref (None) in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); - match len with - | 9 -> ( - if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && 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) = 'h' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'h' then ( - 2 - ) - else ( - -1 - ) - ) - | 12 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'h' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 's' && String.unsafe_get s (pos+11) = 'h' then ( - 3 - ) - else ( - -1 - ) - ) - | 13 -> ( - if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 'h' && String.unsafe_get s (pos+10) = 'a' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 'h' then ( - 1 - ) - else ( - -1 - ) - ) - | 15 -> ( - if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'h' && String.unsafe_get s (pos+12) = 'a' && String.unsafe_get s (pos+13) = 's' && String.unsafe_get s (pos+14) = 'h' then ( - 0 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_start_line_hash := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - | 1 -> - field_end_line_hash := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - | 2 -> - field_code_hash := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string + 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__string_list_nullable ) p lb - ) - ); - | 3 -> - field_pattern_hash := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string + 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__string_list_nullable ) p lb - ) - ); - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); - match len with - | 9 -> ( - if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && 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) = 'h' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'h' then ( - 2 - ) - else ( - -1 - ) - ) - | 12 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'h' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 's' && String.unsafe_get s (pos+11) = 'h' then ( - 3 - ) - else ( - -1 - ) - ) - | 13 -> ( - if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 'h' && String.unsafe_get s (pos+10) = 'a' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 'h' then ( - 1 - ) - else ( - -1 - ) - ) - | 15 -> ( - if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'h' && String.unsafe_get s (pos+12) = 'a' && String.unsafe_get s (pos+13) = 's' && String.unsafe_get s (pos+14) = 'h' then ( - 0 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_start_line_hash := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - | 1 -> - field_end_line_hash := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - | 2 -> - field_code_hash := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - | 3 -> - field_pattern_hash := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - ( - { - start_line_hash = (match !field_start_line_hash with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "start_line_hash"); - end_line_hash = (match !field_end_line_hash with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "end_line_hash"); - code_hash = (match !field_code_hash with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "code_hash"); - pattern_hash = (match !field_pattern_hash with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "pattern_hash"); - } - : finding_hashes) - ) + 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 _string_list_nullable_option_of_string s = + read__string_list_nullable_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__position_nullable = ( + Atdgen_runtime.Oj_run.write_nullable ( + write_position + ) +) +let string_of__position_nullable ?(len = 1024) x = + let ob = Buffer.create len in + write__position_nullable ob x; + Buffer.contents ob +let read__position_nullable = ( + fun p lb -> + Yojson.Safe.read_space p lb; + (if Yojson.Safe.read_null_if_possible p lb then None + else Some (( + read_position + ) p lb) : _ option) ) -let finding_hashes_of_string s = - read_finding_hashes (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__finding_hashes_option = ( +let _position_nullable_of_string s = + read__position_nullable (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__position_nullable_option = ( Atdgen_runtime.Oj_run.write_std_option ( - write_finding_hashes + write__position_nullable ) ) -let string_of__finding_hashes_option ?(len = 1024) x = +let string_of__position_nullable_option ?(len = 1024) x = let ob = Buffer.create len in - write__finding_hashes_option ob x; + write__position_nullable_option ob x; Buffer.contents ob -let read__finding_hashes_option = ( +let read__position_nullable_option = ( fun p lb -> Yojson.Safe.read_space p lb; match Yojson.Safe.start_any_variant p lb with @@ -24524,7 +22842,7 @@ let read__finding_hashes_option = ( | "Some" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( - read_finding_hashes + read__position_nullable ) p lb in Yojson.Safe.read_space p lb; @@ -24547,7 +22865,7 @@ let read__finding_hashes_option = ( Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; let x = ( - read_finding_hashes + read__position_nullable ) p lb in Yojson.Safe.read_space p lb; @@ -24557,248 +22875,124 @@ let read__finding_hashes_option = ( Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) -let _finding_hashes_option_of_string s = - read__finding_hashes_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_finding : _ -> finding -> _ = ( - fun ob (x : finding) -> +let _position_nullable_option_of_string s = + read__position_nullable_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_error_span : _ -> error_span -> _ = ( + fun ob (x : error_span) -> Buffer.add_char ob '{'; let is_first = ref true in if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"check_id\":"; - ( - write_rule_id - ) - ob x.check_id; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"path\":"; + Buffer.add_string ob "\"file\":"; ( write_fpath ) - ob x.path; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"line\":"; - ( - Yojson.Safe.write_int - ) - ob x.line; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"column\":"; - ( - Yojson.Safe.write_int - ) - ob x.column; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"end_line\":"; - ( - Yojson.Safe.write_int - ) - ob x.end_line; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"end_column\":"; - ( - Yojson.Safe.write_int - ) - ob x.end_column; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"message\":"; - ( - Yojson.Safe.write_string - ) - ob x.message; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"severity\":"; - ( - Yojson.Safe.write_json - ) - ob x.severity; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"index\":"; - ( - Yojson.Safe.write_int - ) - ob x.index; + ob x.file; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"commit_date\":"; + Buffer.add_string ob "\"start\":"; ( - Yojson.Safe.write_string + write_position ) - ob x.commit_date; + ob x.start; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"syntactic_id\":"; + Buffer.add_string ob "\"end\":"; ( - Yojson.Safe.write_string + write_position ) - ob x.syntactic_id; - (match x.match_based_id with None -> () | Some x -> + ob x.end_; + (match x.source_hash with None -> () | Some x -> if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"match_based_id\":"; + Buffer.add_string ob "\"source_hash\":"; ( Yojson.Safe.write_string ) ob x; ); - (match x.hashes with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"hashes\":"; - ( - write_finding_hashes - ) - ob x; - ); - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"metadata\":"; - ( - write_raw_json - ) - ob x.metadata; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"is_blocking\":"; - ( - Yojson.Safe.write_bool - ) - ob x.is_blocking; - (match x.fixed_lines with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"fixed_lines\":"; - ( - write__string_list - ) - ob x; - ); - (match x.sca_info with None -> () | Some x -> + (match x.config_start with None -> () | Some x -> if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"sca_info\":"; + Buffer.add_string ob "\"config_start\":"; ( - write_sca_match + write__position_nullable ) ob x; ); - (match x.dataflow_trace with None -> () | Some x -> + (match x.config_end with None -> () | Some x -> if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"dataflow_trace\":"; + Buffer.add_string ob "\"config_end\":"; ( - write_match_dataflow_trace + write__position_nullable ) ob x; ); - (match x.validation_state with None -> () | Some x -> + (match x.config_path with None -> () | Some x -> if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"validation_state\":"; + Buffer.add_string ob "\"config_path\":"; ( - write_validation_state + write__string_list_nullable ) ob x; ); - (match x.historical_info with None -> () | Some x -> + (match x.context_start with None -> () | Some x -> if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"historical_info\":"; + Buffer.add_string ob "\"context_start\":"; ( - write_historical_info + write__position_nullable ) ob x; ); - (match x.engine_kind with None -> () | Some x -> + (match x.context_end with None -> () | Some x -> if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"engine_kind\":"; + Buffer.add_string ob "\"context_end\":"; ( - write_engine_of_finding + write__position_nullable ) ob x; ); Buffer.add_char ob '}'; ) -let string_of_finding ?(len = 1024) x = +let string_of_error_span ?(len = 1024) x = let ob = Buffer.create len in - write_finding ob x; + write_error_span ob x; Buffer.contents ob -let read_finding = ( +let read_error_span = ( fun p lb -> Yojson.Safe.read_space p lb; Yojson.Safe.read_lcurl p lb; - let field_check_id = ref (None) in - let field_path = ref (None) in - let field_line = ref (None) in - let field_column = ref (None) in - let field_end_line = ref (None) in - let field_end_column = ref (None) in - let field_message = ref (None) in - let field_severity = ref (None) in - let field_index = ref (None) in - let field_commit_date = ref (None) in - let field_syntactic_id = ref (None) in - let field_match_based_id = ref (None) in - let field_hashes = ref (None) in - let field_metadata = ref (None) in - let field_is_blocking = ref (None) in - let field_fixed_lines = ref (None) in - let field_sca_info = ref (None) in - let field_dataflow_trace = ref (None) in - let field_validation_state = ref (None) in - let field_historical_info = ref (None) in - let field_engine_kind = ref (None) in + let field_file = ref (None) in + let field_start = ref (None) in + let field_end_ = ref (None) in + let field_source_hash = ref (None) in + let field_config_start = ref (None) in + let field_config_end = ref (None) in + let field_config_path = ref (None) in + let field_context_start = ref (None) in + let field_context_end = ref (None) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; @@ -24808,120 +23002,32 @@ let read_finding = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); match len with - | 4 -> ( - match String.unsafe_get s pos with - | 'l' -> ( - if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'e' then ( - 2 - ) - else ( - -1 - ) - ) - | 'p' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' then ( - 1 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'x' then ( - 8 + | 3 -> ( + if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' then ( + 2 + ) + else ( + -1 + ) + ) + | 4 -> ( + if String.unsafe_get s pos = 'f' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' then ( + 0 ) else ( -1 ) ) - | 6 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'u' && String.unsafe_get s (pos+4) = 'm' && String.unsafe_get s (pos+5) = 'n' then ( - 3 - ) - else ( - -1 - ) - ) - | 'h' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'h' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 's' then ( - 12 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 7 -> ( - if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = 'e' then ( - 6 + | 5 -> ( + if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' then ( + 1 ) else ( -1 ) ) - | 8 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'k' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | 'e' -> ( - if String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'e' then ( - 4 - ) - else ( - -1 - ) - ) - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'a' then ( - 13 - ) - else ( - -1 - ) - ) - | 's' -> ( - match String.unsafe_get s (pos+1) with - | 'c' -> ( - if String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'f' && String.unsafe_get s (pos+7) = 'o' then ( - 16 - ) - else ( - -1 - ) - ) - | 'e' -> ( - if String.unsafe_get s (pos+2) = 'v' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'y' then ( - 7 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) | 10 -> ( - if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'c' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'u' && String.unsafe_get s (pos+8) = 'm' && String.unsafe_get s (pos+9) = 'n' then ( + if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'f' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'd' then ( 5 ) else ( @@ -24931,32 +23037,35 @@ let read_finding = ( | 11 -> ( match String.unsafe_get s pos with | 'c' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'd' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'e' then ( - 9 - ) - else ( - -1 - ) - ) - | 'e' -> ( - if 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) = 'k' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'd' then ( - 20 - ) - else ( - -1 - ) - ) - | 'f' -> ( - if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'x' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 's' then ( - 15 + if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' then ( + match String.unsafe_get s (pos+3) with + | 'f' -> ( + if String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'p' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'h' then ( + 6 + ) + else ( + -1 + ) + ) + | 't' -> ( + if String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'x' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'd' then ( + 8 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) ) else ( -1 ) ) - | 'i' -> ( - if String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'b' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'c' && String.unsafe_get s (pos+7) = 'k' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'g' then ( - 14 + | 's' -> ( + if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'u' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 'c' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'h' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'h' then ( + 3 ) else ( -1 @@ -24967,239 +23076,109 @@ let read_finding = ( ) ) | 12 -> ( - if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'c' && String.unsafe_get s (pos+9) = '_' && String.unsafe_get s (pos+10) = 'i' && String.unsafe_get s (pos+11) = 'd' then ( - 10 - ) - else ( - -1 - ) - ) - | 14 -> ( - match String.unsafe_get s pos with - | 'd' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'f' && String.unsafe_get s (pos+5) = 'l' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'w' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'r' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 'c' && String.unsafe_get s (pos+13) = 'e' then ( - 17 - ) - else ( - -1 - ) - ) - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'h' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'b' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 's' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 'd' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 'i' && String.unsafe_get s (pos+13) = 'd' then ( - 11 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 15 -> ( - if String.unsafe_get s pos = 'h' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'i' && String.unsafe_get s (pos+12) = 'n' && String.unsafe_get s (pos+13) = 'f' && String.unsafe_get s (pos+14) = 'o' then ( - 19 - ) - else ( - -1 - ) - ) - | 16 -> ( - if String.unsafe_get s pos = 'v' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'e' then ( - 18 - ) - else ( - -1 + if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'f' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 'r' && String.unsafe_get s (pos+11) = 't' then ( + 4 + ) + else ( + -1 ) ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_check_id := ( - Some ( - ( - read_rule_id - ) p lb - ) - ); - | 1 -> - field_path := ( - Some ( - ( - read_fpath - ) p lb - ) - ); - | 2 -> - field_line := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - | 3 -> - field_column := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - | 4 -> - field_end_line := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - | 5 -> - field_end_column := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - | 6 -> - field_message := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - | 7 -> - field_severity := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_json - ) p lb - ) - ); - | 8 -> - field_index := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - | 9 -> - field_commit_date := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb + | 13 -> ( + if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'x' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 's' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'a' && String.unsafe_get s (pos+11) = 'r' && String.unsafe_get s (pos+12) = 't' then ( + 7 + ) + else ( + -1 + ) ) - ); - | 10 -> - field_syntactic_id := ( + | _ -> ( + -1 + ) + in + let i = Yojson.Safe.map_ident p f lb in + Atdgen_runtime.Oj_run.read_until_field_value p lb; + ( + match i with + | 0 -> + field_file := ( Some ( ( - Atdgen_runtime.Oj_run.read_string + read_fpath ) p lb ) ); - | 11 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_match_based_id := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 12 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_hashes := ( - Some ( - ( - read_finding_hashes - ) p lb - ) - ); - ) - | 13 -> - field_metadata := ( + | 1 -> + field_start := ( Some ( ( - read_raw_json + read_position ) p lb ) ); - | 14 -> - field_is_blocking := ( + | 2 -> + field_end_ := ( Some ( ( - Atdgen_runtime.Oj_run.read_bool + read_position ) p lb ) ); - | 15 -> + | 3 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_fixed_lines := ( + field_source_hash := ( Some ( ( - read__string_list + Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) - | 16 -> + | 4 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_sca_info := ( + field_config_start := ( Some ( ( - read_sca_match + read__position_nullable ) p lb ) ); ) - | 17 -> + | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_dataflow_trace := ( + field_config_end := ( Some ( ( - read_match_dataflow_trace + read__position_nullable ) p lb ) ); ) - | 18 -> + | 6 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_validation_state := ( + field_config_path := ( Some ( ( - read_validation_state + read__string_list_nullable ) p lb ) ); ) - | 19 -> + | 7 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_historical_info := ( + field_context_start := ( Some ( ( - read_historical_info + read__position_nullable ) p lb ) ); ) - | 20 -> + | 8 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_engine_kind := ( + field_context_end := ( Some ( ( - read_engine_of_finding + read__position_nullable ) p lb ) ); @@ -25217,185 +23196,70 @@ let read_finding = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); match len with - | 4 -> ( - match String.unsafe_get s pos with - | 'l' -> ( - if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'e' then ( - 2 - ) - else ( - -1 - ) - ) - | 'p' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' then ( - 1 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'x' then ( - 8 - ) - else ( - -1 - ) - ) - | 6 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'u' && String.unsafe_get s (pos+4) = 'm' && String.unsafe_get s (pos+5) = 'n' then ( - 3 - ) - else ( - -1 - ) - ) - | 'h' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'h' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 's' then ( - 12 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 7 -> ( - if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = 'e' then ( - 6 - ) - else ( - -1 - ) - ) - | 8 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'k' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | 'e' -> ( - if String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'e' then ( - 4 - ) - else ( - -1 - ) - ) - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'a' then ( - 13 - ) - else ( - -1 - ) - ) - | 's' -> ( - match String.unsafe_get s (pos+1) with - | 'c' -> ( - if String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'f' && String.unsafe_get s (pos+7) = 'o' then ( - 16 - ) - else ( - -1 - ) - ) - | 'e' -> ( - if String.unsafe_get s (pos+2) = 'v' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'y' then ( - 7 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 10 -> ( - if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'c' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'u' && String.unsafe_get s (pos+8) = 'm' && String.unsafe_get s (pos+9) = 'n' then ( - 5 + | 3 -> ( + if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' then ( + 2 ) else ( -1 ) ) - | 11 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'd' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'e' then ( - 9 - ) - else ( - -1 - ) - ) - | 'e' -> ( - if 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) = 'k' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'd' then ( - 20 - ) - else ( - -1 - ) - ) - | 'f' -> ( - if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'x' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 's' then ( - 15 - ) - else ( - -1 - ) - ) - | 'i' -> ( - if String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'b' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'c' && String.unsafe_get s (pos+7) = 'k' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'g' then ( - 14 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 12 -> ( - if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'c' && String.unsafe_get s (pos+9) = '_' && String.unsafe_get s (pos+10) = 'i' && String.unsafe_get s (pos+11) = 'd' then ( - 10 + | 4 -> ( + if String.unsafe_get s pos = 'f' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' then ( + 0 ) else ( -1 ) ) - | 14 -> ( + | 5 -> ( + if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' then ( + 1 + ) + else ( + -1 + ) + ) + | 10 -> ( + if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'f' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'd' then ( + 5 + ) + else ( + -1 + ) + ) + | 11 -> ( match String.unsafe_get s pos with - | 'd' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'f' && String.unsafe_get s (pos+5) = 'l' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'w' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'r' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 'c' && String.unsafe_get s (pos+13) = 'e' then ( - 17 + | 'c' -> ( + if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' then ( + match String.unsafe_get s (pos+3) with + | 'f' -> ( + if String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'p' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'h' then ( + 6 + ) + else ( + -1 + ) + ) + | 't' -> ( + if String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'x' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'd' then ( + 8 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) ) else ( -1 ) ) - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'h' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'b' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 's' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 'd' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 'i' && String.unsafe_get s (pos+13) = 'd' then ( - 11 + | 's' -> ( + if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'u' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 'c' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'h' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'h' then ( + 3 ) else ( -1 @@ -25405,17 +23269,17 @@ let read_finding = ( -1 ) ) - | 15 -> ( - if String.unsafe_get s pos = 'h' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'i' && String.unsafe_get s (pos+12) = 'n' && String.unsafe_get s (pos+13) = 'f' && String.unsafe_get s (pos+14) = 'o' then ( - 19 + | 12 -> ( + if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'f' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 'r' && String.unsafe_get s (pos+11) = 't' then ( + 4 ) else ( -1 ) ) - | 16 -> ( - if String.unsafe_get s pos = 'v' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'e' then ( - 18 + | 13 -> ( + if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'x' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 's' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'a' && String.unsafe_get s (pos+11) = 'r' && String.unsafe_get s (pos+12) = 't' then ( + 7 ) else ( -1 @@ -25430,96 +23294,32 @@ let read_finding = ( ( match i with | 0 -> - field_check_id := ( + field_file := ( Some ( ( - read_rule_id + read_fpath ) p lb ) ); | 1 -> - field_path := ( + field_start := ( Some ( ( - read_fpath + read_position ) p lb ) ); | 2 -> - field_line := ( + field_end_ := ( Some ( ( - Atdgen_runtime.Oj_run.read_int + read_position ) p lb ) ); | 3 -> - field_column := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - | 4 -> - field_end_line := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - | 5 -> - field_end_column := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - | 6 -> - field_message := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - | 7 -> - field_severity := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_json - ) p lb - ) - ); - | 8 -> - field_index := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - | 9 -> - field_commit_date := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - | 10 -> - field_syntactic_id := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - | 11 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_match_based_id := ( + field_source_hash := ( Some ( ( Atdgen_runtime.Oj_run.read_string @@ -25527,88 +23327,52 @@ let read_finding = ( ) ); ) - | 12 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_hashes := ( - Some ( - ( - read_finding_hashes - ) p lb - ) - ); - ) - | 13 -> - field_metadata := ( - Some ( - ( - read_raw_json - ) p lb - ) - ); - | 14 -> - field_is_blocking := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - | 15 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_fixed_lines := ( - Some ( - ( - read__string_list - ) p lb - ) - ); - ) - | 16 -> + | 4 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_sca_info := ( + field_config_start := ( Some ( ( - read_sca_match + read__position_nullable ) p lb ) ); ) - | 17 -> + | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_dataflow_trace := ( + field_config_end := ( Some ( ( - read_match_dataflow_trace + read__position_nullable ) p lb ) ); ) - | 18 -> + | 6 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_validation_state := ( + field_config_path := ( Some ( ( - read_validation_state + read__string_list_nullable ) p lb ) ); ) - | 19 -> + | 7 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_historical_info := ( + field_context_start := ( Some ( ( - read_historical_info + read__position_nullable ) p lb ) ); ) - | 20 -> + | 8 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_engine_kind := ( + field_context_end := ( Some ( ( - read_engine_of_finding + read__position_nullable ) p lb ) ); @@ -25622,33 +23386,72 @@ let read_finding = ( with Yojson.End_of_object -> ( ( { - check_id = (match !field_check_id with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "check_id"); - path = (match !field_path with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "path"); - line = (match !field_line with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "line"); - column = (match !field_column with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "column"); - end_line = (match !field_end_line with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "end_line"); - end_column = (match !field_end_column with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "end_column"); - message = (match !field_message with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "message"); - severity = (match !field_severity with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "severity"); - index = (match !field_index with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "index"); - commit_date = (match !field_commit_date with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "commit_date"); - syntactic_id = (match !field_syntactic_id with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "syntactic_id"); - match_based_id = !field_match_based_id; - hashes = !field_hashes; - metadata = (match !field_metadata with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "metadata"); - is_blocking = (match !field_is_blocking with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "is_blocking"); - fixed_lines = !field_fixed_lines; - sca_info = !field_sca_info; - dataflow_trace = !field_dataflow_trace; - validation_state = !field_validation_state; - historical_info = !field_historical_info; - engine_kind = !field_engine_kind; + file = (match !field_file with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "file"); + start = (match !field_start with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "start"); + end_ = (match !field_end_ with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "end_"); + source_hash = !field_source_hash; + config_start = !field_config_start; + config_end = !field_config_end; + config_path = !field_config_path; + context_start = !field_context_start; + context_end = !field_context_end; } - : finding) + : error_span) ) ) -let finding_of_string s = - read_finding (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let error_span_of_string s = + read_error_span (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_error_severity = ( + fun ob x -> + match x with + | `Error -> Buffer.add_string ob "\"error\"" + | `Warning -> Buffer.add_string ob "\"warn\"" + | `Info -> Buffer.add_string ob "\"info\"" +) +let string_of_error_severity ?(len = 1024) x = + let ob = Buffer.create len in + write_error_severity ob x; + Buffer.contents ob +let read_error_severity = ( + 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 + | "error" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Error + | "warn" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Warning + | "info" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Info + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Double_quote -> ( + match Yojson.Safe.finish_string p lb with + | "error" -> + `Error + | "warn" -> + `Warning + | "info" -> + `Info + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Square_bracket -> ( + match Atdgen_runtime.Oj_run.read_string p lb with + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) +) +let error_severity_of_string s = + read_error_severity (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_dependency_parser_error : _ -> dependency_parser_error -> _ = ( fun ob (x : dependency_parser_error) -> Buffer.add_char ob '{'; @@ -26148,7 +23951,224 @@ let read_contributor = ( field_commit_author_email := ( Some ( ( - Atdgen_runtime.Oj_run.read_string + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + done; + assert false; + with Yojson.End_of_object -> ( + ( + { + commit_author_name = (match !field_commit_author_name with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "commit_author_name"); + commit_author_email = (match !field_commit_author_email with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "commit_author_email"); + } + : contributor) + ) +) +let contributor_of_string s = + read_contributor (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_contribution : _ -> contribution -> _ = ( + fun ob (x : contribution) -> + Buffer.add_char ob '{'; + let is_first = ref true in + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"commit_hash\":"; + ( + Yojson.Safe.write_string + ) + ob x.commit_hash; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"commit_timestamp\":"; + ( + write_datetime + ) + ob x.commit_timestamp; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"contributor\":"; + ( + write_contributor + ) + ob x.contributor; + Buffer.add_char ob '}'; +) +let string_of_contribution ?(len = 1024) x = + let ob = Buffer.create len in + write_contribution ob x; + Buffer.contents ob +let read_contribution = ( + fun p lb -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_lcurl p lb; + let field_commit_hash = ref (None) in + let field_commit_timestamp = ref (None) in + let field_contributor = ref (None) in + try + Yojson.Safe.read_space p lb; + Yojson.Safe.read_object_end lb; + Yojson.Safe.read_space p lb; + let f = + fun s pos len -> + if pos < 0 || len < 0 || pos + len > String.length s then + invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); + match len with + | 11 -> ( + if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' then ( + match String.unsafe_get s (pos+2) with + | 'm' -> ( + if String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'h' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'h' then ( + 0 + ) + else ( + -1 + ) + ) + | 'n' -> ( + if String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'b' && String.unsafe_get s (pos+7) = 'u' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'r' then ( + 2 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + else ( + -1 + ) + ) + | 16 -> ( + if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'm' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 'm' && String.unsafe_get s (pos+15) = 'p' then ( + 1 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + in + let i = Yojson.Safe.map_ident p f lb in + Atdgen_runtime.Oj_run.read_until_field_value p lb; + ( + match i with + | 0 -> + field_commit_hash := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + | 1 -> + field_commit_timestamp := ( + Some ( + ( + read_datetime + ) p lb + ) + ); + | 2 -> + field_contributor := ( + Some ( + ( + read_contributor + ) p lb + ) + ); + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + while true do + Yojson.Safe.read_space p lb; + Yojson.Safe.read_object_sep p lb; + Yojson.Safe.read_space p lb; + let f = + fun s pos len -> + if pos < 0 || len < 0 || pos + len > String.length s then + invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); + match len with + | 11 -> ( + if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' then ( + match String.unsafe_get s (pos+2) with + | 'm' -> ( + if String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'h' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'h' then ( + 0 + ) + else ( + -1 + ) + ) + | 'n' -> ( + if String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'b' && String.unsafe_get s (pos+7) = 'u' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'r' then ( + 2 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + else ( + -1 + ) + ) + | 16 -> ( + if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'm' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 'm' && String.unsafe_get s (pos+15) = 'p' then ( + 1 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + in + let i = Yojson.Safe.map_ident p f lb in + Atdgen_runtime.Oj_run.read_until_field_value p lb; + ( + match i with + | 0 -> + field_commit_hash := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + | 1 -> + field_commit_timestamp := ( + Some ( + ( + read_datetime + ) p lb + ) + ); + | 2 -> + field_contributor := ( + Some ( + ( + read_contributor ) p lb ) ); @@ -26161,58 +24181,244 @@ let read_contributor = ( with Yojson.End_of_object -> ( ( { - commit_author_name = (match !field_commit_author_name with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "commit_author_name"); - commit_author_email = (match !field_commit_author_email with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "commit_author_email"); + commit_hash = (match !field_commit_hash with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "commit_hash"); + commit_timestamp = (match !field_commit_timestamp with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "commit_timestamp"); + contributor = (match !field_contributor with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "contributor"); } - : contributor) + : contribution) ) ) -let contributor_of_string s = - read_contributor (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_contribution : _ -> contribution -> _ = ( - fun ob (x : contribution) -> +let contribution_of_string s = + read_contribution (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__contribution_list = ( + Atdgen_runtime.Oj_run.write_list ( + write_contribution + ) +) +let string_of__contribution_list ?(len = 1024) x = + let ob = Buffer.create len in + write__contribution_list ob x; + Buffer.contents ob +let read__contribution_list = ( + Atdgen_runtime.Oj_run.read_list ( + read_contribution + ) +) +let _contribution_list_of_string s = + read__contribution_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_contributions = ( + write__contribution_list +) +let string_of_contributions ?(len = 1024) x = + let ob = Buffer.create len in + write_contributions ob x; + Buffer.contents ob +let read_contributions = ( + read__contribution_list +) +let contributions_of_string s = + read_contributions (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__error_span_list = ( + Atdgen_runtime.Oj_run.write_list ( + write_error_span + ) +) +let string_of__error_span_list ?(len = 1024) x = + let ob = Buffer.create len in + write__error_span_list ob x; + Buffer.contents ob +let read__error_span_list = ( + Atdgen_runtime.Oj_run.read_list ( + read_error_span + ) +) +let _error_span_list_of_string s = + read__error_span_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__error_span_list_option = ( + Atdgen_runtime.Oj_run.write_std_option ( + write__error_span_list + ) +) +let string_of__error_span_list_option ?(len = 1024) x = + let ob = Buffer.create len in + write__error_span_list_option ob x; + Buffer.contents ob +let read__error_span_list_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__error_span_list + ) 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__error_span_list + ) 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 _error_span_list_option_of_string s = + read__error_span_list_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_cli_error : _ -> cli_error -> _ = ( + fun ob (x : cli_error) -> Buffer.add_char ob '{'; let is_first = ref true in if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"commit_hash\":"; + Buffer.add_string ob "\"code\":"; ( - Yojson.Safe.write_string + Yojson.Safe.write_int ) - ob x.commit_hash; + ob x.code; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"commit_timestamp\":"; + Buffer.add_string ob "\"level\":"; ( - write_datetime + write_error_severity ) - ob x.commit_timestamp; + ob x.level; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"contributor\":"; + Buffer.add_string ob "\"type\":"; ( - write_contributor + write_error_type ) - ob x.contributor; + ob x.type_; + (match x.rule_id with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"rule_id\":"; + ( + write_rule_id + ) + ob x; + ); + (match x.message with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"message\":"; + ( + Yojson.Safe.write_string + ) + ob x; + ); + (match x.path with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"path\":"; + ( + write_fpath + ) + ob x; + ); + (match x.long_msg with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"long_msg\":"; + ( + Yojson.Safe.write_string + ) + ob x; + ); + (match x.short_msg with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"short_msg\":"; + ( + Yojson.Safe.write_string + ) + ob x; + ); + (match x.spans with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"spans\":"; + ( + write__error_span_list + ) + ob x; + ); + (match x.help with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"help\":"; + ( + Yojson.Safe.write_string + ) + ob x; + ); Buffer.add_char ob '}'; ) -let string_of_contribution ?(len = 1024) x = +let string_of_cli_error ?(len = 1024) x = let ob = Buffer.create len in - write_contribution ob x; + write_cli_error ob x; Buffer.contents ob -let read_contribution = ( +let read_cli_error = ( fun p lb -> Yojson.Safe.read_space p lb; Yojson.Safe.read_lcurl p lb; - let field_commit_hash = ref (None) in - let field_commit_timestamp = ref (None) in - let field_contributor = ref (None) in + let field_code = ref (None) in + let field_level = ref (None) in + let field_type_ = ref (None) in + let field_rule_id = ref (None) in + let field_message = ref (None) in + let field_path = ref (None) in + let field_long_msg = ref (None) in + let field_short_msg = ref (None) in + let field_spans = ref (None) in + let field_help = ref (None) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; @@ -26222,36 +24428,99 @@ let read_contribution = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); match len with - | 11 -> ( - if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' then ( - match String.unsafe_get s (pos+2) with - | 'm' -> ( - if String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'h' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'h' then ( - 0 - ) - else ( - -1 - ) + | 4 -> ( + match String.unsafe_get s pos with + | 'c' -> ( + if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 'e' then ( + 0 + ) + else ( + -1 + ) + ) + | 'h' -> ( + if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'p' then ( + 9 ) - | 'n' -> ( - if String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'b' && String.unsafe_get s (pos+7) = 'u' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'r' then ( - 2 - ) - else ( - -1 - ) + else ( + -1 ) - | _ -> ( + ) + | 'p' -> ( + if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' then ( + 5 + ) + else ( + -1 + ) + ) + | 't' -> ( + if String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'e' then ( + 2 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | 5 -> ( + match String.unsafe_get s pos with + | 'l' -> ( + if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'v' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'l' then ( + 1 + ) + else ( + -1 + ) + ) + | 's' -> ( + if String.unsafe_get s (pos+1) = 'p' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = 's' then ( + 8 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | 7 -> ( + match String.unsafe_get s pos with + | 'm' -> ( + if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = 'e' then ( + 4 + ) + else ( + -1 + ) + ) + | 'r' -> ( + if 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) = '_' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'd' then ( + 3 + ) + else ( -1 ) + ) + | _ -> ( + -1 + ) + ) + | 8 -> ( + if String.unsafe_get s pos = 'l' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'm' && String.unsafe_get s (pos+6) = 's' && String.unsafe_get s (pos+7) = 'g' then ( + 6 ) else ( -1 ) ) - | 16 -> ( - if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'm' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 'm' && String.unsafe_get s (pos+15) = 'p' then ( - 1 + | 9 -> ( + if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'g' then ( + 7 ) else ( -1 @@ -26266,29 +24535,99 @@ let read_contribution = ( ( match i with | 0 -> - field_commit_hash := ( + field_code := ( Some ( ( - Atdgen_runtime.Oj_run.read_string + Atdgen_runtime.Oj_run.read_int ) p lb ) ); | 1 -> - field_commit_timestamp := ( + field_level := ( Some ( ( - read_datetime + read_error_severity ) p lb ) ); | 2 -> - field_contributor := ( + field_type_ := ( Some ( ( - read_contributor + read_error_type ) p lb ) ); + | 3 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_rule_id := ( + Some ( + ( + read_rule_id + ) p lb + ) + ); + ) + | 4 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_message := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + ) + | 5 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_path := ( + Some ( + ( + read_fpath + ) p lb + ) + ); + ) + | 6 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_long_msg := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + ) + | 7 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_short_msg := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + ) + | 8 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_spans := ( + Some ( + ( + read__error_span_list + ) p lb + ) + ); + ) + | 9 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_help := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + ) | _ -> ( Yojson.Safe.skip_json p lb ) @@ -26302,36 +24641,99 @@ let read_contribution = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); match len with - | 11 -> ( - if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' then ( - match String.unsafe_get s (pos+2) with - | 'm' -> ( - if String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'h' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'h' then ( - 0 - ) - else ( - -1 - ) + | 4 -> ( + match String.unsafe_get s pos with + | 'c' -> ( + if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 'e' then ( + 0 ) - | 'n' -> ( - if String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'b' && String.unsafe_get s (pos+7) = 'u' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'r' then ( - 2 - ) - else ( - -1 - ) + else ( + -1 ) - | _ -> ( + ) + | 'h' -> ( + if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'p' then ( + 9 + ) + else ( + -1 + ) + ) + | 'p' -> ( + if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' then ( + 5 + ) + else ( + -1 + ) + ) + | 't' -> ( + if String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'e' then ( + 2 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | 5 -> ( + match String.unsafe_get s pos with + | 'l' -> ( + if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'v' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'l' then ( + 1 + ) + else ( + -1 + ) + ) + | 's' -> ( + if String.unsafe_get s (pos+1) = 'p' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = 's' then ( + 8 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | 7 -> ( + match String.unsafe_get s pos with + | 'm' -> ( + if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = 'e' then ( + 4 + ) + else ( + -1 + ) + ) + | 'r' -> ( + if 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) = '_' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'd' then ( + 3 + ) + else ( -1 ) + ) + | _ -> ( + -1 + ) + ) + | 8 -> ( + if String.unsafe_get s pos = 'l' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'm' && String.unsafe_get s (pos+6) = 's' && String.unsafe_get s (pos+7) = 'g' then ( + 6 ) else ( -1 ) ) - | 16 -> ( - if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'm' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 'm' && String.unsafe_get s (pos+15) = 'p' then ( - 1 + | 9 -> ( + if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'g' then ( + 7 ) else ( -1 @@ -26346,29 +24748,99 @@ let read_contribution = ( ( match i with | 0 -> - field_commit_hash := ( + field_code := ( Some ( ( - Atdgen_runtime.Oj_run.read_string + Atdgen_runtime.Oj_run.read_int ) p lb ) ); | 1 -> - field_commit_timestamp := ( + field_level := ( Some ( ( - read_datetime + read_error_severity ) p lb ) ); | 2 -> - field_contributor := ( + field_type_ := ( Some ( ( - read_contributor + read_error_type ) p lb ) ); + | 3 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_rule_id := ( + Some ( + ( + read_rule_id + ) p lb + ) + ); + ) + | 4 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_message := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + ) + | 5 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_path := ( + Some ( + ( + read_fpath + ) p lb + ) + ); + ) + | 6 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_long_msg := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + ) + | 7 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_short_msg := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + ) + | 8 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_spans := ( + Some ( + ( + read__error_span_list + ) p lb + ) + ); + ) + | 9 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_help := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + ) | _ -> ( Yojson.Safe.skip_json p lb ) @@ -26378,43 +24850,22 @@ let read_contribution = ( with Yojson.End_of_object -> ( ( { - commit_hash = (match !field_commit_hash with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "commit_hash"); - commit_timestamp = (match !field_commit_timestamp with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "commit_timestamp"); - contributor = (match !field_contributor with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "contributor"); + code = (match !field_code with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "code"); + level = (match !field_level with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "level"); + type_ = (match !field_type_ with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "type_"); + rule_id = !field_rule_id; + message = !field_message; + path = !field_path; + long_msg = !field_long_msg; + short_msg = !field_short_msg; + spans = !field_spans; + help = !field_help; } - : contribution) + : cli_error) ) ) -let contribution_of_string s = - read_contribution (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__contribution_list = ( - Atdgen_runtime.Oj_run.write_list ( - write_contribution - ) -) -let string_of__contribution_list ?(len = 1024) x = - let ob = Buffer.create len in - write__contribution_list ob x; - Buffer.contents ob -let read__contribution_list = ( - Atdgen_runtime.Oj_run.read_list ( - read_contribution - ) -) -let _contribution_list_of_string s = - read__contribution_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_contributions = ( - write__contribution_list -) -let string_of_contributions ?(len = 1024) x = - let ob = Buffer.create len in - write_contributions ob x; - Buffer.contents ob -let read_contributions = ( - read__contribution_list -) -let contributions_of_string s = - read_contributions (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let cli_error_of_string s = + read_cli_error (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__x_a534bf0 = ( Atdgen_runtime.Oj_run.write_assoc_list ( Yojson.Safe.write_string @@ -27331,6 +25782,22 @@ let read__supply_chain_stats_option = ( ) let _supply_chain_stats_option_of_string s = read__supply_chain_stats_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__cli_error_list = ( + Atdgen_runtime.Oj_run.write_list ( + write_cli_error + ) +) +let string_of__cli_error_list ?(len = 1024) x = + let ob = Buffer.create len in + write__cli_error_list ob x; + Buffer.contents ob +let read__cli_error_list = ( + Atdgen_runtime.Oj_run.read_list ( + read_cli_error + ) +) +let _cli_error_list_of_string s = + read__cli_error_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_ci_scan_complete_stats : _ -> ci_scan_complete_stats -> _ = ( fun ob (x : ci_scan_complete_stats) -> Buffer.add_char ob '{'; @@ -29469,14 +27936,14 @@ let write_function_return = ( write_contributions ) ob x; Buffer.add_char ob ']' - | `RetSarifFormat x -> - Buffer.add_string ob "[\"RetSarifFormat\","; + | `RetFormatter x -> + Buffer.add_string ob "[\"RetFormatter\","; ( - write_sarif_format_return + Yojson.Safe.write_string ) ob x; Buffer.add_char ob ']' - | `RetFormatter x -> - Buffer.add_string ob "[\"RetFormatter\","; + | `RetSarifFormat x -> + Buffer.add_string ob "[\"RetSarifFormat\","; ( Yojson.Safe.write_string ) ob x; @@ -29535,201 +28002,636 @@ let read_function_return = ( ) p lb in Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; + Yojson.Safe.read_gt p lb; + `RetContributions x + | "RetFormatter" -> + Atdgen_runtime.Oj_run.read_until_field_value p lb; + let x = ( + Atdgen_runtime.Oj_run.read_string + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `RetFormatter x + | "RetSarifFormat" -> + Atdgen_runtime.Oj_run.read_until_field_value p lb; + let x = ( + Atdgen_runtime.Oj_run.read_string + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `RetSarifFormat x + | "RetValidate" -> + Atdgen_runtime.Oj_run.read_until_field_value p lb; + let x = ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `RetValidate x + | "RetResolveDependencies" -> + Atdgen_runtime.Oj_run.read_until_field_value p lb; + let x = ( + read__dependency_source_resolution_result_list + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `RetResolveDependencies x + | "RetDumpRulePartitions" -> + Atdgen_runtime.Oj_run.read_until_field_value p lb; + let x = ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `RetDumpRulePartitions x + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Double_quote -> ( + match Yojson.Safe.finish_string p lb with + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Square_bracket -> ( + match Atdgen_runtime.Oj_run.read_string p lb with + | "RetError" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; + let x = ( + Atdgen_runtime.Oj_run.read_string + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_rbr p lb; + `RetError x + | "RetApplyFixes" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; + let x = ( + read_apply_fixes_return + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_rbr p lb; + `RetApplyFixes x + | "RetContributions" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; + let x = ( + read_contributions + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_rbr p lb; `RetContributions x - | "RetSarifFormat" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; + | "RetFormatter" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; let x = ( - read_sarif_format_return + Atdgen_runtime.Oj_run.read_string ) p lb in Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `RetSarifFormat x - | "RetFormatter" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; + Yojson.Safe.read_rbr p lb; + `RetFormatter x + | "RetSarifFormat" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; let x = ( Atdgen_runtime.Oj_run.read_string ) p lb in Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `RetFormatter x + Yojson.Safe.read_rbr p lb; + `RetSarifFormat x | "RetValidate" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; let x = ( Atdgen_runtime.Oj_run.read_bool ) p lb in Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; + Yojson.Safe.read_rbr p lb; `RetValidate x | "RetResolveDependencies" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; let x = ( read__dependency_source_resolution_result_list ) p lb in Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; + Yojson.Safe.read_rbr p lb; `RetResolveDependencies x | "RetDumpRulePartitions" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; let x = ( Atdgen_runtime.Oj_run.read_bool ) p lb in Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; + Yojson.Safe.read_rbr p lb; `RetDumpRulePartitions x | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "RetError" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_string +) +let function_return_of_string s = + read_function_return (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_format_context : _ -> format_context -> _ = ( + fun ob (x : format_context) -> + Buffer.add_char ob '{'; + let is_first = ref true in + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"is_ci_invocation\":"; + ( + Yojson.Safe.write_bool + ) + ob x.is_ci_invocation; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"is_logged_in\":"; + ( + Yojson.Safe.write_bool + ) + ob x.is_logged_in; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"is_using_registry\":"; + ( + Yojson.Safe.write_bool + ) + ob x.is_using_registry; + Buffer.add_char ob '}'; +) +let string_of_format_context ?(len = 1024) x = + let ob = Buffer.create len in + write_format_context ob x; + Buffer.contents ob +let read_format_context = ( + fun p lb -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_lcurl p lb; + let field_is_ci_invocation = ref (None) in + let field_is_logged_in = ref (None) in + let field_is_using_registry = ref (None) in + try + Yojson.Safe.read_space p lb; + Yojson.Safe.read_object_end lb; + Yojson.Safe.read_space p lb; + let f = + fun s pos len -> + if pos < 0 || len < 0 || pos + len > String.length s then + invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); + match len with + | 12 -> ( + if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = 'g' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'd' && String.unsafe_get s (pos+9) = '_' && String.unsafe_get s (pos+10) = 'i' && String.unsafe_get s (pos+11) = 'n' then ( + 1 + ) + else ( + -1 + ) + ) + | 16 -> ( + if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'v' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'c' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'i' && String.unsafe_get s (pos+14) = 'o' && String.unsafe_get s (pos+15) = 'n' then ( + 0 + ) + else ( + -1 + ) + ) + | 17 -> ( + if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'u' && String.unsafe_get s (pos+4) = 's' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'g' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 'r' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 'g' && String.unsafe_get s (pos+12) = 'i' && String.unsafe_get s (pos+13) = 's' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'r' && String.unsafe_get s (pos+16) = 'y' then ( + 2 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + in + let i = Yojson.Safe.map_ident p f lb in + Atdgen_runtime.Oj_run.read_until_field_value p lb; + ( + match i with + | 0 -> + field_is_ci_invocation := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - `RetError x - | "RetApplyFixes" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_apply_fixes_return + ) + ); + | 1 -> + field_is_logged_in := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | 2 -> + field_is_using_registry := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + while true do + Yojson.Safe.read_space p lb; + Yojson.Safe.read_object_sep p lb; + Yojson.Safe.read_space p lb; + let f = + fun s pos len -> + if pos < 0 || len < 0 || pos + len > String.length s then + invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); + match len with + | 12 -> ( + if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = 'g' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'd' && String.unsafe_get s (pos+9) = '_' && String.unsafe_get s (pos+10) = 'i' && String.unsafe_get s (pos+11) = 'n' then ( + 1 + ) + else ( + -1 + ) + ) + | 16 -> ( + if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'v' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'c' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'i' && String.unsafe_get s (pos+14) = 'o' && String.unsafe_get s (pos+15) = 'n' then ( + 0 + ) + else ( + -1 + ) + ) + | 17 -> ( + if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'u' && String.unsafe_get s (pos+4) = 's' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'g' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 'r' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 'g' && String.unsafe_get s (pos+12) = 'i' && String.unsafe_get s (pos+13) = 's' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'r' && String.unsafe_get s (pos+16) = 'y' then ( + 2 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + in + let i = Yojson.Safe.map_ident p f lb in + Atdgen_runtime.Oj_run.read_until_field_value p lb; + ( + match i with + | 0 -> + field_is_ci_invocation := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | 1 -> + field_is_logged_in := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | 2 -> + field_is_using_registry := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + done; + assert false; + with Yojson.End_of_object -> ( + ( + { + is_ci_invocation = (match !field_is_ci_invocation with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "is_ci_invocation"); + is_logged_in = (match !field_is_logged_in with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "is_logged_in"); + is_using_registry = (match !field_is_using_registry with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "is_using_registry"); + } + : format_context) + ) +) +let format_context_of_string s = + read_format_context (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_edit : _ -> edit -> _ = ( + fun ob (x : edit) -> + Buffer.add_char ob '{'; + let is_first = ref true in + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"path\":"; + ( + write_fpath + ) + ob x.path; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"start_offset\":"; + ( + Yojson.Safe.write_int + ) + ob x.start_offset; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"end_offset\":"; + ( + Yojson.Safe.write_int + ) + ob x.end_offset; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"replacement_text\":"; + ( + Yojson.Safe.write_string + ) + ob x.replacement_text; + Buffer.add_char ob '}'; +) +let string_of_edit ?(len = 1024) x = + let ob = Buffer.create len in + write_edit ob x; + Buffer.contents ob +let read_edit = ( + fun p lb -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_lcurl p lb; + let field_path = ref (None) in + let field_start_offset = ref (None) in + let field_end_offset = ref (None) in + let field_replacement_text = ref (None) in + try + Yojson.Safe.read_space p lb; + Yojson.Safe.read_object_end lb; + Yojson.Safe.read_space p lb; + let f = + fun s pos len -> + if pos < 0 || len < 0 || pos + len > String.length s then + invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); + match len with + | 4 -> ( + if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' then ( + 0 + ) + else ( + -1 + ) + ) + | 10 -> ( + if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'f' && String.unsafe_get s (pos+6) = 'f' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 't' then ( + 2 + ) + else ( + -1 + ) + ) + | 12 -> ( + if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'f' && String.unsafe_get s (pos+8) = 'f' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 't' then ( + 1 + ) + else ( + -1 + ) + ) + | 16 -> ( + if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'm' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 't' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 'x' && String.unsafe_get s (pos+15) = 't' then ( + 3 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + in + let i = Yojson.Safe.map_ident p f lb in + Atdgen_runtime.Oj_run.read_until_field_value p lb; + ( + match i with + | 0 -> + field_path := ( + Some ( + ( + read_fpath ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - `RetApplyFixes x - | "RetContributions" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_contributions + ) + ); + | 1 -> + field_start_offset := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - `RetContributions x - | "RetSarifFormat" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_sarif_format_return + ) + ); + | 2 -> + field_end_offset := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - `RetSarifFormat x - | "RetFormatter" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( + ) + ); + | 3 -> + field_replacement_text := ( + Some ( + ( Atdgen_runtime.Oj_run.read_string ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - `RetFormatter x - | "RetValidate" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - `RetValidate x - | "RetResolveDependencies" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read__dependency_source_resolution_result_list - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - `RetResolveDependencies x - | "RetDumpRulePartitions" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - `RetDumpRulePartitions x - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) + ) + ); + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + while true do + Yojson.Safe.read_space p lb; + Yojson.Safe.read_object_sep p lb; + Yojson.Safe.read_space p lb; + let f = + fun s pos len -> + if pos < 0 || len < 0 || pos + len > String.length s then + invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); + match len with + | 4 -> ( + if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' then ( + 0 + ) + else ( + -1 + ) + ) + | 10 -> ( + if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'f' && String.unsafe_get s (pos+6) = 'f' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 't' then ( + 2 + ) + else ( + -1 + ) + ) + | 12 -> ( + if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'f' && String.unsafe_get s (pos+8) = 'f' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 't' then ( + 1 + ) + else ( + -1 + ) + ) + | 16 -> ( + if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'm' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 't' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 'x' && String.unsafe_get s (pos+15) = 't' then ( + 3 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + in + let i = Yojson.Safe.map_ident p f lb in + Atdgen_runtime.Oj_run.read_until_field_value p lb; + ( + match i with + | 0 -> + field_path := ( + Some ( + ( + read_fpath + ) p lb + ) + ); + | 1 -> + field_start_offset := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 2 -> + field_end_offset := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 3 -> + field_replacement_text := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + done; + assert false; + with Yojson.End_of_object -> ( + ( + { + path = (match !field_path with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "path"); + start_offset = (match !field_start_offset with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "start_offset"); + end_offset = (match !field_end_offset with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "end_offset"); + replacement_text = (match !field_replacement_text with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "replacement_text"); + } + : edit) + ) ) -let function_return_of_string s = - read_function_return (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_format_context : _ -> format_context -> _ = ( - fun ob (x : format_context) -> +let edit_of_string s = + read_edit (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_dump_rule_partitions_params : _ -> dump_rule_partitions_params -> _ = ( + fun ob (x : dump_rule_partitions_params) -> Buffer.add_char ob '{'; let is_first = ref true in if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"is_ci_invocation\":"; + Buffer.add_string ob "\"rules\":"; ( - Yojson.Safe.write_bool + write_raw_json ) - ob x.is_ci_invocation; + ob x.rules; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"is_logged_in\":"; + Buffer.add_string ob "\"n_partitions\":"; ( - Yojson.Safe.write_bool + Yojson.Safe.write_int ) - ob x.is_logged_in; + ob x.n_partitions; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"is_using_registry\":"; + Buffer.add_string ob "\"output_dir\":"; ( - Yojson.Safe.write_bool + write_fpath ) - ob x.is_using_registry; + ob x.output_dir; Buffer.add_char ob '}'; ) -let string_of_format_context ?(len = 1024) x = +let string_of_dump_rule_partitions_params ?(len = 1024) x = let ob = Buffer.create len in - write_format_context ob x; + write_dump_rule_partitions_params ob x; Buffer.contents ob -let read_format_context = ( +let read_dump_rule_partitions_params = ( fun p lb -> Yojson.Safe.read_space p lb; Yojson.Safe.read_lcurl p lb; - let field_is_ci_invocation = ref (None) in - let field_is_logged_in = ref (None) in - let field_is_using_registry = ref (None) in + let field_rules = ref (None) in + let field_n_partitions = ref (None) in + let field_output_dir = ref (None) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; @@ -29739,25 +28641,25 @@ let read_format_context = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); match len with - | 12 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = 'g' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'd' && String.unsafe_get s (pos+9) = '_' && String.unsafe_get s (pos+10) = 'i' && String.unsafe_get s (pos+11) = 'n' then ( - 1 + | 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 ( + 0 ) else ( -1 ) ) - | 16 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'v' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'c' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'i' && String.unsafe_get s (pos+14) = 'o' && String.unsafe_get s (pos+15) = 'n' then ( - 0 + | 10 -> ( + if String.unsafe_get s pos = 'o' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'd' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'r' then ( + 2 ) else ( -1 ) ) - | 17 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'u' && String.unsafe_get s (pos+4) = 's' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'g' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 'r' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 'g' && String.unsafe_get s (pos+12) = 'i' && String.unsafe_get s (pos+13) = 's' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'r' && String.unsafe_get s (pos+16) = 'y' then ( - 2 + | 12 -> ( + if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = '_' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = 's' then ( + 1 ) else ( -1 @@ -29772,26 +28674,26 @@ let read_format_context = ( ( match i with | 0 -> - field_is_ci_invocation := ( + field_rules := ( Some ( ( - Atdgen_runtime.Oj_run.read_bool + read_raw_json ) p lb ) ); | 1 -> - field_is_logged_in := ( + field_n_partitions := ( Some ( ( - Atdgen_runtime.Oj_run.read_bool + Atdgen_runtime.Oj_run.read_int ) p lb ) ); | 2 -> - field_is_using_registry := ( + field_output_dir := ( Some ( ( - Atdgen_runtime.Oj_run.read_bool + read_fpath ) p lb ) ); @@ -29808,25 +28710,25 @@ let read_format_context = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); match len with - | 12 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = 'g' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'd' && String.unsafe_get s (pos+9) = '_' && String.unsafe_get s (pos+10) = 'i' && String.unsafe_get s (pos+11) = 'n' then ( - 1 + | 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 ( + 0 ) else ( -1 ) ) - | 16 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'v' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'c' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'i' && String.unsafe_get s (pos+14) = 'o' && String.unsafe_get s (pos+15) = 'n' then ( - 0 + | 10 -> ( + if String.unsafe_get s pos = 'o' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'd' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'r' then ( + 2 ) else ( -1 ) ) - | 17 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'u' && String.unsafe_get s (pos+4) = 's' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'g' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 'r' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 'g' && String.unsafe_get s (pos+12) = 'i' && String.unsafe_get s (pos+13) = 's' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'r' && String.unsafe_get s (pos+16) = 'y' then ( - 2 + | 12 -> ( + if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = '_' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = 's' then ( + 1 ) else ( -1 @@ -29841,26 +28743,26 @@ let read_format_context = ( ( match i with | 0 -> - field_is_ci_invocation := ( + field_rules := ( Some ( ( - Atdgen_runtime.Oj_run.read_bool + read_raw_json ) p lb ) ); | 1 -> - field_is_logged_in := ( + field_n_partitions := ( Some ( ( - Atdgen_runtime.Oj_run.read_bool + Atdgen_runtime.Oj_run.read_int ) p lb ) ); | 2 -> - field_is_using_registry := ( + field_output_dir := ( Some ( ( - Atdgen_runtime.Oj_run.read_bool + read_fpath ) p lb ) ); @@ -29873,69 +28775,256 @@ let read_format_context = ( with Yojson.End_of_object -> ( ( { - is_ci_invocation = (match !field_is_ci_invocation with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "is_ci_invocation"); - is_logged_in = (match !field_is_logged_in with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "is_logged_in"); - is_using_registry = (match !field_is_using_registry with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "is_using_registry"); + rules = (match !field_rules with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "rules"); + n_partitions = (match !field_n_partitions with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "n_partitions"); + output_dir = (match !field_output_dir with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "output_dir"); } - : format_context) + : dump_rule_partitions_params) + ) +) +let dump_rule_partitions_params_of_string s = + read_dump_rule_partitions_params (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__metavars_option = ( + Atdgen_runtime.Oj_run.write_std_option ( + write_metavars + ) +) +let string_of__metavars_option ?(len = 1024) x = + let ob = Buffer.create len in + write__metavars_option ob x; + Buffer.contents ob +let read__metavars_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_metavars + ) 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_metavars + ) 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 _metavars_option_of_string s = + read__metavars_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_cli_match_extra : _ -> cli_match_extra -> _ = ( + fun ob (x : cli_match_extra) -> + Buffer.add_char ob '{'; + let is_first = ref true in + (match x.metavars with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"metavars\":"; + ( + write_metavars + ) + ob x; + ); + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"message\":"; + ( + Yojson.Safe.write_string + ) + ob x.message; + (match x.fix with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"fix\":"; + ( + Yojson.Safe.write_string + ) + ob x; + ); + (match x.fixed_lines with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"fixed_lines\":"; + ( + write__string_list ) -) -let format_context_of_string s = - read_format_context (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_edit : _ -> edit -> _ = ( - fun ob (x : edit) -> - Buffer.add_char ob '{'; - let is_first = ref true in + ob x; + ); if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"path\":"; + Buffer.add_string ob "\"metadata\":"; ( - write_fpath + write_raw_json ) - ob x.path; + ob x.metadata; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"start_offset\":"; + Buffer.add_string ob "\"severity\":"; ( - Yojson.Safe.write_int + write_match_severity ) - ob x.start_offset; + ob x.severity; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"end_offset\":"; + Buffer.add_string ob "\"fingerprint\":"; ( - Yojson.Safe.write_int + Yojson.Safe.write_string ) - ob x.end_offset; + ob x.fingerprint; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"replacement_text\":"; + Buffer.add_string ob "\"lines\":"; ( Yojson.Safe.write_string ) - ob x.replacement_text; + ob x.lines; + (match x.is_ignored with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"is_ignored\":"; + ( + Yojson.Safe.write_bool + ) + ob x; + ); + (match x.sca_info with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"sca_info\":"; + ( + write_sca_match + ) + ob x; + ); + (match x.validation_state with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"validation_state\":"; + ( + write_validation_state + ) + ob x; + ); + (match x.historical_info with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"historical_info\":"; + ( + write_historical_info + ) + ob x; + ); + (match x.dataflow_trace with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"dataflow_trace\":"; + ( + write_match_dataflow_trace + ) + ob x; + ); + (match x.engine_kind with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"engine_kind\":"; + ( + write_engine_of_finding + ) + ob x; + ); + (match x.extra_extra with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"extra_extra\":"; + ( + write_raw_json + ) + ob x; + ); Buffer.add_char ob '}'; ) -let string_of_edit ?(len = 1024) x = +let string_of_cli_match_extra ?(len = 1024) x = let ob = Buffer.create len in - write_edit ob x; + write_cli_match_extra ob x; Buffer.contents ob -let read_edit = ( +let read_cli_match_extra = ( fun p lb -> Yojson.Safe.read_space p lb; Yojson.Safe.read_lcurl p lb; - let field_path = ref (None) in - let field_start_offset = ref (None) in - let field_end_offset = ref (None) in - let field_replacement_text = ref (None) in + let field_metavars = ref (None) in + let field_message = ref (None) in + let field_fix = ref (None) in + let field_fixed_lines = ref (None) in + let field_metadata = ref (None) in + let field_severity = ref (None) in + let field_fingerprint = ref (None) in + let field_lines = ref (None) in + let field_is_ignored = ref (None) in + let field_sca_info = ref (None) in + let field_validation_state = ref (None) in + let field_historical_info = ref (None) in + let field_dataflow_trace = ref (None) in + let field_engine_kind = ref (None) in + let field_extra_extra = ref (None) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; @@ -29945,33 +29034,167 @@ let read_edit = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); match len with - | 4 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' then ( - 0 + | 3 -> ( + if String.unsafe_get s pos = 'f' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'x' then ( + 2 + ) + else ( + -1 + ) + ) + | 5 -> ( + if String.unsafe_get s pos = 'l' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' then ( + 7 + ) + else ( + -1 + ) + ) + | 7 -> ( + if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = 'e' then ( + 1 + ) + else ( + -1 + ) + ) + | 8 -> ( + match String.unsafe_get s pos with + | 'm' -> ( + if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' then ( + match String.unsafe_get s (pos+4) with + | 'd' -> ( + if String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'a' then ( + 4 + ) + else ( + -1 + ) + ) + | 'v' -> ( + if String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 's' then ( + 0 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + else ( + -1 + ) + ) + | 's' -> ( + match String.unsafe_get s (pos+1) with + | 'c' -> ( + if String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'f' && String.unsafe_get s (pos+7) = 'o' then ( + 9 + ) + else ( + -1 + ) + ) + | 'e' -> ( + if String.unsafe_get s (pos+2) = 'v' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'y' then ( + 5 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | 10 -> ( + if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'g' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 'd' then ( + 8 ) else ( -1 ) ) - | 10 -> ( - if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'f' && String.unsafe_get s (pos+6) = 'f' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 't' then ( - 2 + | 11 -> ( + match String.unsafe_get s pos with + | 'e' -> ( + match String.unsafe_get s (pos+1) with + | 'n' -> ( + if 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) = 'k' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'd' then ( + 13 + ) + else ( + -1 + ) + ) + | 'x' -> ( + if String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'x' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'r' && String.unsafe_get s (pos+10) = 'a' then ( + 14 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | 'f' -> ( + if String.unsafe_get s (pos+1) = 'i' then ( + match String.unsafe_get s (pos+2) with + | 'n' -> ( + if String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'p' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 't' then ( + 6 + ) + else ( + -1 + ) + ) + | 'x' -> ( + if String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 's' then ( + 3 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | 14 -> ( + if String.unsafe_get s pos = 'd' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'f' && String.unsafe_get s (pos+5) = 'l' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'w' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'r' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 'c' && String.unsafe_get s (pos+13) = 'e' then ( + 12 ) else ( -1 ) ) - | 12 -> ( - if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'f' && String.unsafe_get s (pos+8) = 'f' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 't' then ( - 1 + | 15 -> ( + if String.unsafe_get s pos = 'h' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'i' && String.unsafe_get s (pos+12) = 'n' && String.unsafe_get s (pos+13) = 'f' && String.unsafe_get s (pos+14) = 'o' then ( + 11 ) else ( -1 ) ) | 16 -> ( - if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'm' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 't' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 'x' && String.unsafe_get s (pos+15) = 't' then ( - 3 + if String.unsafe_get s pos = 'v' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'e' then ( + 10 ) else ( -1 @@ -29986,37 +29209,145 @@ let read_edit = ( ( match i with | 0 -> - field_path := ( + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_metavars := ( + Some ( + ( + read_metavars + ) p lb + ) + ); + ) + | 1 -> + field_message := ( Some ( ( - read_fpath + Atdgen_runtime.Oj_run.read_string ) p lb ) ); - | 1 -> - field_start_offset := ( + | 2 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_fix := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + ) + | 3 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_fixed_lines := ( + Some ( + ( + read__string_list + ) p lb + ) + ); + ) + | 4 -> + field_metadata := ( Some ( ( - Atdgen_runtime.Oj_run.read_int + read_raw_json ) p lb ) ); - | 2 -> - field_end_offset := ( + | 5 -> + field_severity := ( Some ( ( - Atdgen_runtime.Oj_run.read_int + read_match_severity ) p lb ) ); - | 3 -> - field_replacement_text := ( + | 6 -> + field_fingerprint := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + | 7 -> + field_lines := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); + | 8 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_is_ignored := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + ) + | 9 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_sca_info := ( + Some ( + ( + read_sca_match + ) p lb + ) + ); + ) + | 10 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_validation_state := ( + Some ( + ( + read_validation_state + ) p lb + ) + ); + ) + | 11 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_historical_info := ( + Some ( + ( + read_historical_info + ) p lb + ) + ); + ) + | 12 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_dataflow_trace := ( + Some ( + ( + read_match_dataflow_trace + ) p lb + ) + ); + ) + | 13 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_engine_kind := ( + Some ( + ( + read_engine_of_finding + ) p lb + ) + ); + ) + | 14 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_extra_extra := ( + Some ( + ( + read_raw_json + ) p lb + ) + ); + ) | _ -> ( Yojson.Safe.skip_json p lb ) @@ -30030,33 +29361,167 @@ let read_edit = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); match len with - | 4 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' then ( - 0 + | 3 -> ( + if String.unsafe_get s pos = 'f' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'x' then ( + 2 + ) + else ( + -1 + ) + ) + | 5 -> ( + if String.unsafe_get s pos = 'l' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' then ( + 7 + ) + else ( + -1 + ) + ) + | 7 -> ( + if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'g' && String.unsafe_get s (pos+6) = 'e' then ( + 1 + ) + else ( + -1 + ) + ) + | 8 -> ( + match String.unsafe_get s pos with + | 'm' -> ( + if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' then ( + match String.unsafe_get s (pos+4) with + | 'd' -> ( + if String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'a' then ( + 4 + ) + else ( + -1 + ) + ) + | 'v' -> ( + if String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 's' then ( + 0 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + else ( + -1 + ) + ) + | 's' -> ( + match String.unsafe_get s (pos+1) with + | 'c' -> ( + if String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'f' && String.unsafe_get s (pos+7) = 'o' then ( + 9 + ) + else ( + -1 + ) + ) + | 'e' -> ( + if String.unsafe_get s (pos+2) = 'v' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'y' then ( + 5 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | 10 -> ( + if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = '_' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'g' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 'd' then ( + 8 ) else ( -1 ) ) - | 10 -> ( - if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'f' && String.unsafe_get s (pos+6) = 'f' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 't' then ( - 2 + | 11 -> ( + match String.unsafe_get s pos with + | 'e' -> ( + match String.unsafe_get s (pos+1) with + | 'n' -> ( + if 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) = 'k' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'd' then ( + 13 + ) + else ( + -1 + ) + ) + | 'x' -> ( + if String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'x' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'r' && String.unsafe_get s (pos+10) = 'a' then ( + 14 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | 'f' -> ( + if String.unsafe_get s (pos+1) = 'i' then ( + match String.unsafe_get s (pos+2) with + | 'n' -> ( + if String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'p' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 't' then ( + 6 + ) + else ( + -1 + ) + ) + | 'x' -> ( + if String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 's' then ( + 3 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | 14 -> ( + if String.unsafe_get s pos = 'd' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'f' && String.unsafe_get s (pos+5) = 'l' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'w' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'r' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 'c' && String.unsafe_get s (pos+13) = 'e' then ( + 12 ) else ( -1 ) ) - | 12 -> ( - if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'f' && String.unsafe_get s (pos+8) = 'f' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 't' then ( - 1 + | 15 -> ( + if String.unsafe_get s pos = 'h' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'i' && String.unsafe_get s (pos+12) = 'n' && String.unsafe_get s (pos+13) = 'f' && String.unsafe_get s (pos+14) = 'o' then ( + 11 ) else ( -1 ) ) | 16 -> ( - if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'm' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 't' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 'x' && String.unsafe_get s (pos+15) = 't' then ( - 3 + if String.unsafe_get s pos = 'v' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'e' then ( + 10 ) else ( -1 @@ -30071,37 +29536,145 @@ let read_edit = ( ( match i with | 0 -> - field_path := ( + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_metavars := ( + Some ( + ( + read_metavars + ) p lb + ) + ); + ) + | 1 -> + field_message := ( Some ( ( - read_fpath + Atdgen_runtime.Oj_run.read_string ) p lb ) ); - | 1 -> - field_start_offset := ( + | 2 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_fix := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + ) + | 3 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_fixed_lines := ( + Some ( + ( + read__string_list + ) p lb + ) + ); + ) + | 4 -> + field_metadata := ( Some ( ( - Atdgen_runtime.Oj_run.read_int + read_raw_json ) p lb ) ); - | 2 -> - field_end_offset := ( + | 5 -> + field_severity := ( Some ( ( - Atdgen_runtime.Oj_run.read_int + read_match_severity ) p lb ) ); - | 3 -> - field_replacement_text := ( + | 6 -> + field_fingerprint := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + | 7 -> + field_lines := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); + | 8 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_is_ignored := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + ) + | 9 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_sca_info := ( + Some ( + ( + read_sca_match + ) p lb + ) + ); + ) + | 10 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_validation_state := ( + Some ( + ( + read_validation_state + ) p lb + ) + ); + ) + | 11 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_historical_info := ( + Some ( + ( + read_historical_info + ) p lb + ) + ); + ) + | 12 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_dataflow_trace := ( + Some ( + ( + read_match_dataflow_trace + ) p lb + ) + ); + ) + | 13 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_engine_kind := ( + Some ( + ( + read_engine_of_finding + ) p lb + ) + ); + ) + | 14 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_extra_extra := ( + Some ( + ( + read_raw_json + ) p lb + ) + ); + ) | _ -> ( Yojson.Safe.skip_json p lb ) @@ -30111,60 +29684,91 @@ let read_edit = ( with Yojson.End_of_object -> ( ( { - path = (match !field_path with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "path"); - start_offset = (match !field_start_offset with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "start_offset"); - end_offset = (match !field_end_offset with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "end_offset"); - replacement_text = (match !field_replacement_text with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "replacement_text"); + metavars = !field_metavars; + message = (match !field_message with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "message"); + fix = !field_fix; + fixed_lines = !field_fixed_lines; + metadata = (match !field_metadata with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "metadata"); + severity = (match !field_severity with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "severity"); + fingerprint = (match !field_fingerprint with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "fingerprint"); + lines = (match !field_lines with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "lines"); + is_ignored = !field_is_ignored; + sca_info = !field_sca_info; + validation_state = !field_validation_state; + historical_info = !field_historical_info; + dataflow_trace = !field_dataflow_trace; + engine_kind = !field_engine_kind; + extra_extra = !field_extra_extra; } - : edit) + : cli_match_extra) ) ) -let edit_of_string s = - read_edit (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_dump_rule_partitions_params : _ -> dump_rule_partitions_params -> _ = ( - fun ob (x : dump_rule_partitions_params) -> +let cli_match_extra_of_string s = + read_cli_match_extra (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_cli_match : _ -> cli_match -> _ = ( + fun ob (x : cli_match) -> Buffer.add_char ob '{'; let is_first = ref true in if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"rules\":"; + Buffer.add_string ob "\"check_id\":"; ( - write_raw_json + write_rule_id ) - ob x.rules; + ob x.check_id; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"n_partitions\":"; + Buffer.add_string ob "\"path\":"; ( - Yojson.Safe.write_int + write_fpath ) - ob x.n_partitions; + ob x.path; if !is_first then is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"output_dir\":"; + Buffer.add_string ob "\"start\":"; ( - write_fpath + write_position + ) + ob x.start; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"end\":"; + ( + write_position + ) + ob x.end_; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"extra\":"; + ( + write_cli_match_extra ) - ob x.output_dir; + ob x.extra; Buffer.add_char ob '}'; ) -let string_of_dump_rule_partitions_params ?(len = 1024) x = +let string_of_cli_match ?(len = 1024) x = let ob = Buffer.create len in - write_dump_rule_partitions_params ob x; + write_cli_match ob x; Buffer.contents ob -let read_dump_rule_partitions_params = ( +let read_cli_match = ( fun p lb -> Yojson.Safe.read_space p lb; Yojson.Safe.read_lcurl p lb; - let field_rules = ref (None) in - let field_n_partitions = ref (None) in - let field_output_dir = ref (None) in + let field_check_id = ref (None) in + let field_path = ref (None) in + let field_start = ref (None) in + let field_end_ = ref (None) in + let field_extra = ref (None) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; @@ -30174,25 +29778,47 @@ let read_dump_rule_partitions_params = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); 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 ( - 0 + | 3 -> ( + if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' then ( + 3 ) else ( -1 ) ) - | 10 -> ( - if String.unsafe_get s pos = 'o' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'd' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'r' then ( - 2 + | 4 -> ( + if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' then ( + 1 ) else ( -1 ) ) - | 12 -> ( - if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = '_' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = 's' then ( - 1 + | 5 -> ( + match String.unsafe_get s pos with + | 'e' -> ( + if String.unsafe_get s (pos+1) = 'x' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 'a' then ( + 4 + ) + else ( + -1 + ) + ) + | 's' -> ( + if String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' then ( + 2 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | 8 -> ( + if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'k' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( + 0 ) else ( -1 @@ -30207,26 +29833,42 @@ let read_dump_rule_partitions_params = ( ( match i with | 0 -> - field_rules := ( + field_check_id := ( Some ( ( - read_raw_json + read_rule_id ) p lb ) ); | 1 -> - field_n_partitions := ( + field_path := ( Some ( ( - Atdgen_runtime.Oj_run.read_int + read_fpath ) p lb ) ); | 2 -> - field_output_dir := ( + field_start := ( Some ( ( - read_fpath + read_position + ) p lb + ) + ); + | 3 -> + field_end_ := ( + Some ( + ( + read_position + ) p lb + ) + ); + | 4 -> + field_extra := ( + Some ( + ( + read_cli_match_extra ) p lb ) ); @@ -30243,25 +29885,47 @@ let read_dump_rule_partitions_params = ( if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); 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 ( - 0 + | 3 -> ( + if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'd' then ( + 3 ) else ( -1 ) ) - | 10 -> ( - if String.unsafe_get s pos = 'o' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'd' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'r' then ( - 2 + | 4 -> ( + if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' then ( + 1 ) else ( -1 ) ) - | 12 -> ( - if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = '_' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = 's' then ( - 1 + | 5 -> ( + match String.unsafe_get s pos with + | 'e' -> ( + if String.unsafe_get s (pos+1) = 'x' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 'a' then ( + 4 + ) + else ( + -1 + ) + ) + | 's' -> ( + if String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 't' then ( + 2 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | 8 -> ( + if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'k' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( + 0 ) else ( -1 @@ -30276,26 +29940,42 @@ let read_dump_rule_partitions_params = ( ( match i with | 0 -> - field_rules := ( + field_check_id := ( Some ( ( - read_raw_json + read_rule_id ) p lb ) ); | 1 -> - field_n_partitions := ( + field_path := ( Some ( ( - Atdgen_runtime.Oj_run.read_int + read_fpath ) p lb ) ); | 2 -> - field_output_dir := ( + field_start := ( Some ( ( - read_fpath + read_position + ) p lb + ) + ); + | 3 -> + field_end_ := ( + Some ( + ( + read_position + ) p lb + ) + ); + | 4 -> + field_extra := ( + Some ( + ( + read_cli_match_extra ) p lb ) ); @@ -30308,15 +29988,17 @@ let read_dump_rule_partitions_params = ( with Yojson.End_of_object -> ( ( { - rules = (match !field_rules with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "rules"); - n_partitions = (match !field_n_partitions with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "n_partitions"); - output_dir = (match !field_output_dir with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "output_dir"); + check_id = (match !field_check_id with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "check_id"); + path = (match !field_path with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "path"); + start = (match !field_start with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "start"); + end_ = (match !field_end_ with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "end_"); + extra = (match !field_extra with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "extra"); } - : dump_rule_partitions_params) + : cli_match) ) ) -let dump_rule_partitions_params_of_string s = - read_dump_rule_partitions_params (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let cli_match_of_string s = + read_cli_match (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__skipped_rule_list = ( Atdgen_runtime.Oj_run.write_list ( write_skipped_rule @@ -30577,6 +30259,22 @@ let read__engine_kind_option = ( ) let _engine_kind_option_of_string s = read__engine_kind_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__cli_match_list = ( + Atdgen_runtime.Oj_run.write_list ( + write_cli_match + ) +) +let string_of__cli_match_list ?(len = 1024) x = + let ob = Buffer.create len in + write__cli_match_list ob x; + Buffer.contents ob +let read__cli_match_list = ( + Atdgen_runtime.Oj_run.read_list ( + read_cli_match + ) +) +let _cli_match_list_of_string s = + read__cli_match_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_cli_output : _ -> cli_output -> _ = ( fun ob (x : cli_output) -> Buffer.add_char ob '{'; @@ -31317,33 +31015,39 @@ let write_function_call = ( write_apply_fixes_params ) ob x; Buffer.add_char ob ']' - | `CallSarifFormat x -> - Buffer.add_string ob "[\"CallSarifFormat\","; + | `CallFormatter x -> + Buffer.add_string ob "[\"CallFormatter\","; ( fun ob x -> Buffer.add_char ob '['; - (let x, _ = x in + (let x, _, _ = x in + ( + write_output_format + ) ob x + ); + Buffer.add_char ob ','; + (let _, x, _ = x in ( write_format_context ) ob x ); Buffer.add_char ob ','; - (let _, x = x in + (let _, _, x = x in ( - write_sarif_format_params + write_cli_output ) ob x ); Buffer.add_char ob ']'; ) ob x; Buffer.add_char ob ']' - | `CallFormatter x -> - Buffer.add_string ob "[\"CallFormatter\","; + | `CallSarifFormat x -> + Buffer.add_string ob "[\"CallSarifFormat\","; ( fun ob x -> Buffer.add_char ob '['; (let x, _, _ = x in ( - write_output_format + write_sarif_format ) ob x ); Buffer.add_char ob ','; @@ -31403,7 +31107,7 @@ let read_function_call = ( Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; `CallApplyFixes x - | "CallSarifFormat" -> + | "CallFormatter" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( fun p lb -> @@ -31415,7 +31119,7 @@ let read_function_call = ( let x0 = let x = ( - read_format_context + read_output_format ) p lb in incr len; @@ -31426,7 +31130,18 @@ let read_function_call = ( let x1 = let x = ( - read_sarif_format_params + 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 x2 = + let x = + ( + read_cli_output ) p lb in incr len; @@ -31445,15 +31160,15 @@ let read_function_call = ( done with Yojson.End_of_tuple -> () ); - (x0, x1) + (x0, x1, x2) with Yojson.End_of_tuple -> - Atdgen_runtime.Oj_run.missing_tuple_fields p !len [ 0; 1 ]); + Atdgen_runtime.Oj_run.missing_tuple_fields p !len [ 0; 1; 2 ]); ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - `CallSarifFormat x - | "CallFormatter" -> + `CallFormatter x + | "CallSarifFormat" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( fun p lb -> @@ -31465,7 +31180,7 @@ let read_function_call = ( let x0 = let x = ( - read_output_format + read_sarif_format ) p lb in incr len; @@ -31513,7 +31228,7 @@ let read_function_call = ( in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - `CallFormatter x + `CallSarifFormat x | "CallValidate" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( @@ -31564,7 +31279,7 @@ let read_function_call = ( Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; `CallApplyFixes x - | "CallSarifFormat" -> + | "CallFormatter" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; @@ -31578,7 +31293,7 @@ let read_function_call = ( let x0 = let x = ( - read_format_context + read_output_format ) p lb in incr len; @@ -31589,7 +31304,18 @@ let read_function_call = ( let x1 = let x = ( - read_sarif_format_params + 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 x2 = + let x = + ( + read_cli_output ) p lb in incr len; @@ -31608,15 +31334,15 @@ let read_function_call = ( done with Yojson.End_of_tuple -> () ); - (x0, x1) + (x0, x1, x2) with Yojson.End_of_tuple -> - Atdgen_runtime.Oj_run.missing_tuple_fields p !len [ 0; 1 ]); + Atdgen_runtime.Oj_run.missing_tuple_fields p !len [ 0; 1; 2 ]); ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; - `CallSarifFormat x - | "CallFormatter" -> + `CallFormatter x + | "CallSarifFormat" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; @@ -31630,7 +31356,7 @@ let read_function_call = ( let x0 = let x = ( - read_output_format + read_sarif_format ) p lb in incr len; @@ -31678,7 +31404,7 @@ let read_function_call = ( in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; - `CallFormatter x + `CallSarifFormat x | "CallValidate" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; diff --git a/semgrep_output_v1_j.mli b/semgrep_output_v1_j.mli index aac9526..4ed0169 100644 --- a/semgrep_output_v1_j.mli +++ b/semgrep_output_v1_j.mli @@ -489,11 +489,16 @@ type scan_config = Semgrep_output_v1_t.scan_config = { type sca_parser_name = Semgrep_output_v1_t.sca_parser_name -type sarif_format_return = Semgrep_output_v1_t.sarif_format_return = { - output: string; - format_time_seconds: float +type sarif_format = Semgrep_output_v1_t.sarif_format = { + rules: fpath; + is_pro: bool; + show_dataflow_traces: bool } +type engine_kind = Semgrep_output_v1_t.engine_kind [@@deriving show] + +type rule_id_and_engine_kind = Semgrep_output_v1_t.rule_id_and_engine_kind + type resolution_cmd_failed = Semgrep_output_v1_t.resolution_cmd_failed = { command: string; message: string @@ -503,6 +508,24 @@ type resolution_cmd_failed = Semgrep_output_v1_t.resolution_cmd_failed = { type resolution_error = Semgrep_output_v1_t.resolution_error [@@deriving show] +type resolution_result = Semgrep_output_v1_t.resolution_result + +type profile = Semgrep_output_v1_t.profile = { + rules: rule_id list; + rules_parse_time: float; + profiling_times: (string * float) list; + targets: target_times list; + total_bytes: int; + max_memory_bytes: int option +} + +type parsing_stats = Semgrep_output_v1_t.parsing_stats = { + targets_parsed: int; + num_targets: int; + bytes_parsed: int; + num_bytes: int +} + type incompatible_rule = Semgrep_output_v1_t.incompatible_rule = { rule_id: rule_id; this_version: version; @@ -511,6 +534,37 @@ type incompatible_rule = Semgrep_output_v1_t.incompatible_rule = { } [@@deriving show] +type finding_hashes = Semgrep_output_v1_t.finding_hashes = { + start_line_hash: string; + end_line_hash: string; + code_hash: string; + pattern_hash: string +} + +type finding = Semgrep_output_v1_t.finding = { + check_id: rule_id; + path: fpath; + line: int; + column: int; + end_line: int; + end_column: int; + message: string; + severity: Yojson.Safe.t; + index: int; + commit_date: string; + syntactic_id: string; + match_based_id: string option; + hashes: finding_hashes option; + metadata: raw_json; + is_blocking: bool; + fixed_lines: string list option; + sca_info: sca_match option; + dataflow_trace: match_dataflow_trace option; + validation_state: validation_state option; + historical_info: historical_info option; + engine_kind: engine_of_finding option +} + type error_type = Semgrep_output_v1_t.error_type = LexicalError | ParseError @@ -556,107 +610,6 @@ type error_span = Semgrep_output_v1_t.error_span = { type error_severity = Semgrep_output_v1_t.error_severity [@@deriving show, eq] -type cli_match_extra = Semgrep_output_v1_t.cli_match_extra = { - metavars: metavars option; - message: string; - fix: string option; - fixed_lines: string list option; - metadata: raw_json; - severity: match_severity; - fingerprint: string; - lines: string; - is_ignored: bool option; - sca_info: sca_match option; - validation_state: validation_state option; - historical_info: historical_info option; - dataflow_trace: match_dataflow_trace option; - engine_kind: engine_of_finding option; - extra_extra: raw_json option -} - -type cli_match = Semgrep_output_v1_t.cli_match = { - check_id: rule_id; - path: fpath; - start: position; - end_ (*atd end *): position; - extra: cli_match_extra -} - -type cli_error = Semgrep_output_v1_t.cli_error = { - code: int; - level: error_severity; - type_: error_type; - rule_id: rule_id option; - message: string option; - path: fpath option; - long_msg: string option; - short_msg: string option; - spans: error_span list option; - help: string option -} - -type sarif_format_params = Semgrep_output_v1_t.sarif_format_params = { - rules: fpath; - cli_matches: cli_match list; - cli_errors: cli_error list; - hide_nudge: bool; - engine_label: string; - show_dataflow_traces: bool -} - -type engine_kind = Semgrep_output_v1_t.engine_kind [@@deriving show] - -type rule_id_and_engine_kind = Semgrep_output_v1_t.rule_id_and_engine_kind - -type resolution_result = Semgrep_output_v1_t.resolution_result - -type profile = Semgrep_output_v1_t.profile = { - rules: rule_id list; - rules_parse_time: float; - profiling_times: (string * float) list; - targets: target_times list; - total_bytes: int; - max_memory_bytes: int option -} - -type parsing_stats = Semgrep_output_v1_t.parsing_stats = { - targets_parsed: int; - num_targets: int; - bytes_parsed: int; - num_bytes: int -} - -type finding_hashes = Semgrep_output_v1_t.finding_hashes = { - start_line_hash: string; - end_line_hash: string; - code_hash: string; - pattern_hash: string -} - -type finding = Semgrep_output_v1_t.finding = { - check_id: rule_id; - path: fpath; - line: int; - column: int; - end_line: int; - end_column: int; - message: string; - severity: Yojson.Safe.t; - index: int; - commit_date: string; - syntactic_id: string; - match_based_id: string option; - hashes: finding_hashes option; - metadata: raw_json; - is_blocking: bool; - fixed_lines: string list option; - sca_info: sca_match option; - dataflow_trace: match_dataflow_trace option; - validation_state: validation_state option; - historical_info: historical_info option; - engine_kind: engine_of_finding option -} - type dependency_parser_error = Semgrep_output_v1_t.dependency_parser_error = { path: fpath; parser: sca_parser_name; @@ -679,6 +632,19 @@ type contribution = Semgrep_output_v1_t.contribution = { type contributions = Semgrep_output_v1_t.contributions +type cli_error = Semgrep_output_v1_t.cli_error = { + code: int; + level: error_severity; + type_: error_type; + rule_id: rule_id option; + message: string option; + path: fpath option; + long_msg: string option; + short_msg: string option; + spans: error_span list option; + help: string option +} + type ci_scan_dependencies = Semgrep_output_v1_t.ci_scan_dependencies type ci_scan_results = Semgrep_output_v1_t.ci_scan_results = { @@ -777,6 +743,32 @@ type dump_rule_partitions_params = output_dir: fpath } +type cli_match_extra = Semgrep_output_v1_t.cli_match_extra = { + metavars: metavars option; + message: string; + fix: string option; + fixed_lines: string list option; + metadata: raw_json; + severity: match_severity; + fingerprint: string; + lines: string; + is_ignored: bool option; + sca_info: sca_match option; + validation_state: validation_state option; + historical_info: historical_info option; + dataflow_trace: match_dataflow_trace option; + engine_kind: engine_of_finding option; + extra_extra: raw_json option +} + +type cli_match = Semgrep_output_v1_t.cli_match = { + check_id: rule_id; + path: fpath; + start: position; + end_ (*atd end *): position; + extra: cli_match_extra +} + type cli_output = Semgrep_output_v1_t.cli_output = { version: version option; results: cli_match list; @@ -2650,25 +2642,65 @@ val sca_parser_name_of_string : string -> sca_parser_name (** Deserialize JSON data of type {!type:sca_parser_name}. *) -val write_sarif_format_return : - Buffer.t -> sarif_format_return -> unit - (** Output a JSON value of type {!type:sarif_format_return}. *) +val write_sarif_format : + Buffer.t -> sarif_format -> unit + (** Output a JSON value of type {!type:sarif_format}. *) + +val string_of_sarif_format : + ?len:int -> sarif_format -> string + (** Serialize a value of type {!type:sarif_format} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_sarif_format : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> sarif_format + (** Input JSON data of type {!type:sarif_format}. *) + +val sarif_format_of_string : + string -> sarif_format + (** Deserialize JSON data of type {!type:sarif_format}. *) + +val write_engine_kind : + Buffer.t -> engine_kind -> unit + (** Output a JSON value of type {!type:engine_kind}. *) + +val string_of_engine_kind : + ?len:int -> engine_kind -> string + (** Serialize a value of type {!type:engine_kind} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_engine_kind : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> engine_kind + (** Input JSON data of type {!type:engine_kind}. *) + +val engine_kind_of_string : + string -> engine_kind + (** Deserialize JSON data of type {!type:engine_kind}. *) + +val write_rule_id_and_engine_kind : + Buffer.t -> rule_id_and_engine_kind -> unit + (** Output a JSON value of type {!type:rule_id_and_engine_kind}. *) -val string_of_sarif_format_return : - ?len:int -> sarif_format_return -> string - (** Serialize a value of type {!type:sarif_format_return} +val string_of_rule_id_and_engine_kind : + ?len:int -> rule_id_and_engine_kind -> string + (** Serialize a value of type {!type:rule_id_and_engine_kind} into a JSON string. @param len specifies the initial length of the buffer used internally. Default: 1024. *) -val read_sarif_format_return : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> sarif_format_return - (** Input JSON data of type {!type:sarif_format_return}. *) +val read_rule_id_and_engine_kind : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> rule_id_and_engine_kind + (** Input JSON data of type {!type:rule_id_and_engine_kind}. *) -val sarif_format_return_of_string : - string -> sarif_format_return - (** Deserialize JSON data of type {!type:sarif_format_return}. *) +val rule_id_and_engine_kind_of_string : + string -> rule_id_and_engine_kind + (** Deserialize JSON data of type {!type:rule_id_and_engine_kind}. *) val write_resolution_cmd_failed : Buffer.t -> resolution_cmd_failed -> unit @@ -2710,225 +2742,25 @@ val resolution_error_of_string : string -> resolution_error (** Deserialize JSON data of type {!type:resolution_error}. *) -val write_incompatible_rule : - Buffer.t -> incompatible_rule -> unit - (** Output a JSON value of type {!type:incompatible_rule}. *) +val write_resolution_result : + Buffer.t -> resolution_result -> unit + (** Output a JSON value of type {!type:resolution_result}. *) -val string_of_incompatible_rule : - ?len:int -> incompatible_rule -> string - (** Serialize a value of type {!type:incompatible_rule} +val string_of_resolution_result : + ?len:int -> resolution_result -> string + (** Serialize a value of type {!type:resolution_result} into a JSON string. @param len specifies the initial length of the buffer used internally. Default: 1024. *) -val read_incompatible_rule : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> incompatible_rule - (** Input JSON data of type {!type:incompatible_rule}. *) +val read_resolution_result : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> resolution_result + (** Input JSON data of type {!type:resolution_result}. *) -val incompatible_rule_of_string : - string -> incompatible_rule - (** Deserialize JSON data of type {!type:incompatible_rule}. *) - -val write_error_type : - Buffer.t -> error_type -> unit - (** Output a JSON value of type {!type:error_type}. *) - -val string_of_error_type : - ?len:int -> error_type -> string - (** Serialize a value of type {!type:error_type} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_error_type : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> error_type - (** Input JSON data of type {!type:error_type}. *) - -val error_type_of_string : - string -> error_type - (** Deserialize JSON data of type {!type:error_type}. *) - -val write_error_span : - Buffer.t -> error_span -> unit - (** Output a JSON value of type {!type:error_span}. *) - -val string_of_error_span : - ?len:int -> error_span -> string - (** Serialize a value of type {!type:error_span} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_error_span : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> error_span - (** Input JSON data of type {!type:error_span}. *) - -val error_span_of_string : - string -> error_span - (** Deserialize JSON data of type {!type:error_span}. *) - -val write_error_severity : - Buffer.t -> error_severity -> unit - (** Output a JSON value of type {!type:error_severity}. *) - -val string_of_error_severity : - ?len:int -> error_severity -> string - (** Serialize a value of type {!type:error_severity} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_error_severity : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> error_severity - (** Input JSON data of type {!type:error_severity}. *) - -val error_severity_of_string : - string -> error_severity - (** Deserialize JSON data of type {!type:error_severity}. *) - -val write_cli_match_extra : - Buffer.t -> cli_match_extra -> unit - (** Output a JSON value of type {!type:cli_match_extra}. *) - -val string_of_cli_match_extra : - ?len:int -> cli_match_extra -> string - (** Serialize a value of type {!type:cli_match_extra} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_cli_match_extra : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> cli_match_extra - (** Input JSON data of type {!type:cli_match_extra}. *) - -val cli_match_extra_of_string : - string -> cli_match_extra - (** Deserialize JSON data of type {!type:cli_match_extra}. *) - -val write_cli_match : - Buffer.t -> cli_match -> unit - (** Output a JSON value of type {!type:cli_match}. *) - -val string_of_cli_match : - ?len:int -> cli_match -> string - (** Serialize a value of type {!type:cli_match} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_cli_match : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> cli_match - (** Input JSON data of type {!type:cli_match}. *) - -val cli_match_of_string : - string -> cli_match - (** Deserialize JSON data of type {!type:cli_match}. *) - -val write_cli_error : - Buffer.t -> cli_error -> unit - (** Output a JSON value of type {!type:cli_error}. *) - -val string_of_cli_error : - ?len:int -> cli_error -> string - (** Serialize a value of type {!type:cli_error} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_cli_error : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> cli_error - (** Input JSON data of type {!type:cli_error}. *) - -val cli_error_of_string : - string -> cli_error - (** Deserialize JSON data of type {!type:cli_error}. *) - -val write_sarif_format_params : - Buffer.t -> sarif_format_params -> unit - (** Output a JSON value of type {!type:sarif_format_params}. *) - -val string_of_sarif_format_params : - ?len:int -> sarif_format_params -> string - (** Serialize a value of type {!type:sarif_format_params} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_sarif_format_params : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> sarif_format_params - (** Input JSON data of type {!type:sarif_format_params}. *) - -val sarif_format_params_of_string : - string -> sarif_format_params - (** Deserialize JSON data of type {!type:sarif_format_params}. *) - -val write_engine_kind : - Buffer.t -> engine_kind -> unit - (** Output a JSON value of type {!type:engine_kind}. *) - -val string_of_engine_kind : - ?len:int -> engine_kind -> string - (** Serialize a value of type {!type:engine_kind} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_engine_kind : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> engine_kind - (** Input JSON data of type {!type:engine_kind}. *) - -val engine_kind_of_string : - string -> engine_kind - (** Deserialize JSON data of type {!type:engine_kind}. *) - -val write_rule_id_and_engine_kind : - Buffer.t -> rule_id_and_engine_kind -> unit - (** Output a JSON value of type {!type:rule_id_and_engine_kind}. *) - -val string_of_rule_id_and_engine_kind : - ?len:int -> rule_id_and_engine_kind -> string - (** Serialize a value of type {!type:rule_id_and_engine_kind} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_rule_id_and_engine_kind : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> rule_id_and_engine_kind - (** Input JSON data of type {!type:rule_id_and_engine_kind}. *) - -val rule_id_and_engine_kind_of_string : - string -> rule_id_and_engine_kind - (** Deserialize JSON data of type {!type:rule_id_and_engine_kind}. *) - -val write_resolution_result : - Buffer.t -> resolution_result -> unit - (** Output a JSON value of type {!type:resolution_result}. *) - -val string_of_resolution_result : - ?len:int -> resolution_result -> string - (** Serialize a value of type {!type:resolution_result} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_resolution_result : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> resolution_result - (** Input JSON data of type {!type:resolution_result}. *) - -val resolution_result_of_string : - string -> resolution_result - (** Deserialize JSON data of type {!type:resolution_result}. *) +val resolution_result_of_string : + string -> resolution_result + (** Deserialize JSON data of type {!type:resolution_result}. *) val write_profile : Buffer.t -> profile -> unit @@ -2970,6 +2802,26 @@ val parsing_stats_of_string : string -> parsing_stats (** Deserialize JSON data of type {!type:parsing_stats}. *) +val write_incompatible_rule : + Buffer.t -> incompatible_rule -> unit + (** Output a JSON value of type {!type:incompatible_rule}. *) + +val string_of_incompatible_rule : + ?len:int -> incompatible_rule -> string + (** Serialize a value of type {!type:incompatible_rule} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_incompatible_rule : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> incompatible_rule + (** Input JSON data of type {!type:incompatible_rule}. *) + +val incompatible_rule_of_string : + string -> incompatible_rule + (** Deserialize JSON data of type {!type:incompatible_rule}. *) + val write_finding_hashes : Buffer.t -> finding_hashes -> unit (** Output a JSON value of type {!type:finding_hashes}. *) @@ -3010,6 +2862,66 @@ val finding_of_string : string -> finding (** Deserialize JSON data of type {!type:finding}. *) +val write_error_type : + Buffer.t -> error_type -> unit + (** Output a JSON value of type {!type:error_type}. *) + +val string_of_error_type : + ?len:int -> error_type -> string + (** Serialize a value of type {!type:error_type} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_error_type : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> error_type + (** Input JSON data of type {!type:error_type}. *) + +val error_type_of_string : + string -> error_type + (** Deserialize JSON data of type {!type:error_type}. *) + +val write_error_span : + Buffer.t -> error_span -> unit + (** Output a JSON value of type {!type:error_span}. *) + +val string_of_error_span : + ?len:int -> error_span -> string + (** Serialize a value of type {!type:error_span} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_error_span : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> error_span + (** Input JSON data of type {!type:error_span}. *) + +val error_span_of_string : + string -> error_span + (** Deserialize JSON data of type {!type:error_span}. *) + +val write_error_severity : + Buffer.t -> error_severity -> unit + (** Output a JSON value of type {!type:error_severity}. *) + +val string_of_error_severity : + ?len:int -> error_severity -> string + (** Serialize a value of type {!type:error_severity} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_error_severity : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> error_severity + (** Input JSON data of type {!type:error_severity}. *) + +val error_severity_of_string : + string -> error_severity + (** Deserialize JSON data of type {!type:error_severity}. *) + val write_dependency_parser_error : Buffer.t -> dependency_parser_error -> unit (** Output a JSON value of type {!type:dependency_parser_error}. *) @@ -3090,6 +3002,26 @@ val contributions_of_string : string -> contributions (** Deserialize JSON data of type {!type:contributions}. *) +val write_cli_error : + Buffer.t -> cli_error -> unit + (** Output a JSON value of type {!type:cli_error}. *) + +val string_of_cli_error : + ?len:int -> cli_error -> string + (** Serialize a value of type {!type:cli_error} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_cli_error : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> cli_error + (** Input JSON data of type {!type:cli_error}. *) + +val cli_error_of_string : + string -> cli_error + (** Deserialize JSON data of type {!type:cli_error}. *) + val write_ci_scan_dependencies : Buffer.t -> ci_scan_dependencies -> unit (** Output a JSON value of type {!type:ci_scan_dependencies}. *) @@ -3410,6 +3342,46 @@ val dump_rule_partitions_params_of_string : string -> dump_rule_partitions_params (** Deserialize JSON data of type {!type:dump_rule_partitions_params}. *) +val write_cli_match_extra : + Buffer.t -> cli_match_extra -> unit + (** Output a JSON value of type {!type:cli_match_extra}. *) + +val string_of_cli_match_extra : + ?len:int -> cli_match_extra -> string + (** Serialize a value of type {!type:cli_match_extra} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_cli_match_extra : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> cli_match_extra + (** Input JSON data of type {!type:cli_match_extra}. *) + +val cli_match_extra_of_string : + string -> cli_match_extra + (** Deserialize JSON data of type {!type:cli_match_extra}. *) + +val write_cli_match : + Buffer.t -> cli_match -> unit + (** Output a JSON value of type {!type:cli_match}. *) + +val string_of_cli_match : + ?len:int -> cli_match -> string + (** Serialize a value of type {!type:cli_match} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_cli_match : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> cli_match + (** Input JSON data of type {!type:cli_match}. *) + +val cli_match_of_string : + string -> cli_match + (** Deserialize JSON data of type {!type:cli_match}. *) + val write_cli_output : Buffer.t -> cli_output -> unit (** Output a JSON value of type {!type:cli_output}. *)