From 93a040943f6de78b9347c8392f42b56a5b479dc4 Mon Sep 17 00:00:00 2001 From: SayyantR Date: Tue, 22 Oct 2024 13:38:58 -0700 Subject: [PATCH 1/4] Interface changes --- semgrep_output_v1.atd | 4 + semgrep_output_v1.jsonschema | 18 +++- semgrep_output_v1.proto | 4 +- semgrep_output_v1.py | 6 ++ semgrep_output_v1.ts | 6 ++ semgrep_output_v1_j.ml | 174 ++++++++++++++++++++++++++--------- semgrep_output_v1_j.mli | 4 +- 7 files changed, 168 insertions(+), 48 deletions(-) diff --git a/semgrep_output_v1.atd b/semgrep_output_v1.atd index e7b2470c..363374ab 100644 --- a/semgrep_output_v1.atd +++ b/semgrep_output_v1.atd @@ -1293,6 +1293,8 @@ type scan_config = { *) deployment_id: int; deployment_name: string; + (* deployment specific feature flag settings which impact CI behavior *) + deployment_feature_flags: string list; (* 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) *) @@ -1437,6 +1439,8 @@ type scan_info = { enabled_products: product list; deployment_id: int; deployment_name: string; + (* deployment specific feature flag settings which impact CI behavior *) + deployment_feature_flags: string list; } diff --git a/semgrep_output_v1.jsonschema b/semgrep_output_v1.jsonschema index 8c6f01c1..012403b0 100644 --- a/semgrep_output_v1.jsonschema +++ b/semgrep_output_v1.jsonschema @@ -1017,11 +1017,16 @@ "scan_config": { "type": "object", "required": [ - "deployment_id", "deployment_name", "policy_names", "rule_config" + "deployment_id", "deployment_name", "deployment_feature_flags", + "policy_names", "rule_config" ], "properties": { "deployment_id": { "type": "integer" }, "deployment_name": { "type": "string" }, + "deployment_feature_flags": { + "type": "array", + "items": { "type": "string" } + }, "policy_names": { "type": "array", "items": { "type": "string" } }, "rule_config": { "type": "string" }, "ci_config_from_cloud": { @@ -1130,7 +1135,10 @@ }, "scan_info": { "type": "object", - "required": [ "enabled_products", "deployment_id", "deployment_name" ], + "required": [ + "enabled_products", "deployment_id", "deployment_name", + "deployment_feature_flags" + ], "properties": { "id": { "type": "integer" }, "enabled_products": { @@ -1138,7 +1146,11 @@ "items": { "$ref": "#/definitions/product" } }, "deployment_id": { "type": "integer" }, - "deployment_name": { "type": "string" } + "deployment_name": { "type": "string" }, + "deployment_feature_flags": { + "type": "array", + "items": { "type": "string" } + } } }, "scan_configuration": { diff --git a/semgrep_output_v1.proto b/semgrep_output_v1.proto index a971b37b..c8c2e1aa 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: 3128533ce4295e9cf749fad9537838337aaeb44a78a3384f95e7f43238ca0562 +// Source file sha256 digest: 560ae974fbfb7c45870759ce04382caf1c80c51c16b35deea6d9c6c8a170dca7 syntax = "proto3"; @@ -377,6 +377,7 @@ message CiConfigFromRepo { message ScanConfig { int64 deployment_id = 188822146; string deployment_name = 129624728; + repeated string deployment_feature_flags = 530134217; repeated string policy_names = 175625923; string rule_config = 403140712; CiConfigFromCloud ci_config_from_cloud = 120268883; @@ -449,6 +450,7 @@ message ScanInfo { repeated google.protobuf.Any enabled_products = 447415338; int64 deployment_id = 188822146; string deployment_name = 129624728; + repeated string deployment_feature_flags = 530134217; } message ScanConfiguration { diff --git a/semgrep_output_v1.py b/semgrep_output_v1.py index f9778363..c4ebff11 100644 --- a/semgrep_output_v1.py +++ b/semgrep_output_v1.py @@ -3046,6 +3046,7 @@ class ScanInfo: enabled_products: List[Product] deployment_id: int deployment_name: str + deployment_feature_flags: List[str] id: Optional[int] = None @classmethod @@ -3055,6 +3056,7 @@ def from_json(cls, x: Any) -> 'ScanInfo': enabled_products=_atd_read_list(Product.from_json)(x['enabled_products']) if 'enabled_products' in x else _atd_missing_json_field('ScanInfo', 'enabled_products'), deployment_id=_atd_read_int(x['deployment_id']) if 'deployment_id' in x else _atd_missing_json_field('ScanInfo', 'deployment_id'), deployment_name=_atd_read_string(x['deployment_name']) if 'deployment_name' in x else _atd_missing_json_field('ScanInfo', 'deployment_name'), + deployment_feature_flags=_atd_read_list(_atd_read_string)(x['deployment_feature_flags']) if 'deployment_feature_flags' in x else _atd_missing_json_field('ScanInfo', 'deployment_feature_flags'), id=_atd_read_int(x['id']) if 'id' in x else None, ) else: @@ -3065,6 +3067,7 @@ def to_json(self) -> Any: res['enabled_products'] = _atd_write_list((lambda x: x.to_json()))(self.enabled_products) res['deployment_id'] = _atd_write_int(self.deployment_id) res['deployment_name'] = _atd_write_string(self.deployment_name) + res['deployment_feature_flags'] = _atd_write_list(_atd_write_string)(self.deployment_feature_flags) if self.id is not None: res['id'] = _atd_write_int(self.id) return res @@ -3692,6 +3695,7 @@ class ScanConfig: deployment_id: int deployment_name: str + deployment_feature_flags: List[str] policy_names: List[str] rule_config: str ci_config_from_cloud: Optional[CiConfigFromCloud] = None @@ -3710,6 +3714,7 @@ def from_json(cls, x: Any) -> 'ScanConfig': return cls( deployment_id=_atd_read_int(x['deployment_id']) if 'deployment_id' in x else _atd_missing_json_field('ScanConfig', 'deployment_id'), deployment_name=_atd_read_string(x['deployment_name']) if 'deployment_name' in x else _atd_missing_json_field('ScanConfig', 'deployment_name'), + deployment_feature_flags=_atd_read_list(_atd_read_string)(x['deployment_feature_flags']) if 'deployment_feature_flags' in x else _atd_missing_json_field('ScanConfig', 'deployment_feature_flags'), 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, @@ -3729,6 +3734,7 @@ def to_json(self) -> Any: res: Dict[str, Any] = {} res['deployment_id'] = _atd_write_int(self.deployment_id) res['deployment_name'] = _atd_write_string(self.deployment_name) + res['deployment_feature_flags'] = _atd_write_list(_atd_write_string)(self.deployment_feature_flags) 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: diff --git a/semgrep_output_v1.ts b/semgrep_output_v1.ts index 606cd073..6d244101 100644 --- a/semgrep_output_v1.ts +++ b/semgrep_output_v1.ts @@ -572,6 +572,7 @@ export type Tag = string export type ScanConfig = { deployment_id: number /*int*/; deployment_name: string; + deployment_feature_flags: string[]; policy_names: string[]; rule_config: string; ci_config_from_cloud?: CiConfigFromCloud; @@ -644,6 +645,7 @@ export type ScanInfo = { enabled_products: Product[]; deployment_id: number /*int*/; deployment_name: string; + deployment_feature_flags: string[]; } export type ScanConfiguration = { @@ -2708,6 +2710,7 @@ export function writeScanConfig(x: ScanConfig, context: any = x): any { return { 'deployment_id': _atd_write_required_field('ScanConfig', 'deployment_id', _atd_write_int, x.deployment_id, x), 'deployment_name': _atd_write_required_field('ScanConfig', 'deployment_name', _atd_write_string, x.deployment_name, x), + 'deployment_feature_flags': _atd_write_required_field('ScanConfig', 'deployment_feature_flags', _atd_write_array(_atd_write_string), x.deployment_feature_flags, 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), @@ -2726,6 +2729,7 @@ export function readScanConfig(x: any, context: any = x): ScanConfig { return { deployment_id: _atd_read_required_field('ScanConfig', 'deployment_id', _atd_read_int, x['deployment_id'], x), deployment_name: _atd_read_required_field('ScanConfig', 'deployment_name', _atd_read_string, x['deployment_name'], x), + deployment_feature_flags: _atd_read_required_field('ScanConfig', 'deployment_feature_flags', _atd_read_array(_atd_read_string), x['deployment_feature_flags'], 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), @@ -2874,6 +2878,7 @@ export function writeScanInfo(x: ScanInfo, context: any = x): any { '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), + 'deployment_feature_flags': _atd_write_required_field('ScanInfo', 'deployment_feature_flags', _atd_write_array(_atd_write_string), x.deployment_feature_flags, x), }; } @@ -2883,6 +2888,7 @@ export function readScanInfo(x: any, context: any = x): ScanInfo { 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), + deployment_feature_flags: _atd_read_required_field('ScanInfo', 'deployment_feature_flags', _atd_read_array(_atd_read_string), x['deployment_feature_flags'], x), }; } diff --git a/semgrep_output_v1_j.ml b/semgrep_output_v1_j.ml index 85b3d2f3..755983aa 100644 --- a/semgrep_output_v1_j.ml +++ b/semgrep_output_v1_j.ml @@ -261,7 +261,8 @@ type scan_info = Semgrep_output_v1_t.scan_info = { id: int option; enabled_products: product list; deployment_id: int; - deployment_name: string + deployment_name: string; + deployment_feature_flags: string list } type scan_configuration = Semgrep_output_v1_t.scan_configuration = { @@ -369,6 +370,7 @@ type ci_config_from_cloud = Semgrep_output_v1_t.ci_config_from_cloud = { type scan_config = Semgrep_output_v1_t.scan_config = { deployment_id: int; deployment_name: string; + deployment_feature_flags: string list; policy_names: string list; rule_config: string; ci_config_from_cloud: ci_config_from_cloud option; @@ -9580,6 +9582,15 @@ let write_scan_info : _ -> scan_info -> _ = ( Yojson.Safe.write_string ) ob x.deployment_name; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"deployment_feature_flags\":"; + ( + write__string_list + ) + ob x.deployment_feature_flags; Buffer.add_char ob '}'; ) let string_of_scan_info ?(len = 1024) x = @@ -9594,6 +9605,7 @@ let read_scan_info = ( let field_enabled_products = ref (None) in let field_deployment_id = ref (None) in let field_deployment_name = ref (None) in + let field_deployment_feature_flags = ref (None) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; @@ -9635,6 +9647,14 @@ let read_scan_info = ( -1 ) ) + | 24 -> ( + if String.unsafe_get s pos = 'd' && 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) = 'o' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'f' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'u' && String.unsafe_get s (pos+16) = 'r' && String.unsafe_get s (pos+17) = 'e' && String.unsafe_get s (pos+18) = '_' && String.unsafe_get s (pos+19) = 'f' && String.unsafe_get s (pos+20) = 'l' && String.unsafe_get s (pos+21) = 'a' && String.unsafe_get s (pos+22) = 'g' && String.unsafe_get s (pos+23) = 's' then ( + 4 + ) + else ( + -1 + ) + ) | _ -> ( -1 ) @@ -9677,6 +9697,14 @@ let read_scan_info = ( ) p lb ) ); + | 4 -> + field_deployment_feature_flags := ( + Some ( + ( + read__string_list + ) p lb + ) + ); | _ -> ( Yojson.Safe.skip_json p lb ) @@ -9722,6 +9750,14 @@ let read_scan_info = ( -1 ) ) + | 24 -> ( + if String.unsafe_get s pos = 'd' && 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) = 'o' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'f' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'u' && String.unsafe_get s (pos+16) = 'r' && String.unsafe_get s (pos+17) = 'e' && String.unsafe_get s (pos+18) = '_' && String.unsafe_get s (pos+19) = 'f' && String.unsafe_get s (pos+20) = 'l' && String.unsafe_get s (pos+21) = 'a' && String.unsafe_get s (pos+22) = 'g' && String.unsafe_get s (pos+23) = 's' then ( + 4 + ) + else ( + -1 + ) + ) | _ -> ( -1 ) @@ -9764,6 +9800,14 @@ let read_scan_info = ( ) p lb ) ); + | 4 -> + field_deployment_feature_flags := ( + Some ( + ( + read__string_list + ) p lb + ) + ); | _ -> ( Yojson.Safe.skip_json p lb ) @@ -9777,6 +9821,7 @@ let read_scan_info = ( enabled_products = (match !field_enabled_products with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "enabled_products"); deployment_id = (match !field_deployment_id with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_id"); deployment_name = (match !field_deployment_name with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_name"); + deployment_feature_flags = (match !field_deployment_feature_flags with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_feature_flags"); } : scan_info) ) @@ -14517,6 +14562,15 @@ let write_scan_config : _ -> scan_config -> _ = ( ob x.deployment_name; if !is_first then is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"deployment_feature_flags\":"; + ( + write__string_list + ) + ob x.deployment_feature_flags; + if !is_first then + is_first := false else Buffer.add_char ob ','; Buffer.add_string ob "\"policy_names\":"; @@ -14630,6 +14684,7 @@ let read_scan_config = ( Yojson.Safe.read_lcurl p lb; let field_deployment_id = ref (None) in let field_deployment_name = ref (None) in + let field_deployment_feature_flags = 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 @@ -14655,7 +14710,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 ( - 12 + 13 ) else ( -1 @@ -14663,7 +14718,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 + 6 ) else ( -1 @@ -14681,7 +14736,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 + 7 ) else ( -1 @@ -14689,7 +14744,7 @@ let read_scan_config = ( ) | '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) = 'c' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'f' && String.unsafe_get s (pos+9) = 'i' && String.unsafe_get s (pos+10) = 'g' then ( - 3 + 4 ) else ( -1 @@ -14701,7 +14756,7 @@ let read_scan_config = ( ) | 12 -> ( if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'c' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'm' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 's' then ( - 2 + 3 ) else ( -1 @@ -14719,7 +14774,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 ( - 10 + 11 ) else ( -1 @@ -14741,7 +14796,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 + 8 ) else ( -1 @@ -14749,7 +14804,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 ( - 11 + 12 ) else ( -1 @@ -14761,7 +14816,15 @@ let read_scan_config = ( ) | 20 -> ( if String.unsafe_get s pos = 'c' && 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 + 5 + ) + else ( + -1 + ) + ) + | 24 -> ( + if String.unsafe_get s pos = 'd' && 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) = 'o' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'f' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'u' && String.unsafe_get s (pos+16) = 'r' && String.unsafe_get s (pos+17) = 'e' && String.unsafe_get s (pos+18) = '_' && String.unsafe_get s (pos+19) = 'f' && String.unsafe_get s (pos+20) = 'l' && String.unsafe_get s (pos+21) = 'a' && String.unsafe_get s (pos+22) = 'g' && String.unsafe_get s (pos+23) = 's' then ( + 2 ) else ( -1 @@ -14769,7 +14832,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 ( - 8 + 9 ) else ( -1 @@ -14777,7 +14840,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 ( - 9 + 10 ) else ( -1 @@ -14808,7 +14871,7 @@ let read_scan_config = ( ) ); | 2 -> - field_policy_names := ( + field_deployment_feature_flags := ( Some ( ( read__string_list @@ -14816,6 +14879,14 @@ let read_scan_config = ( ) ); | 3 -> + field_policy_names := ( + Some ( + ( + read__string_list + ) p lb + ) + ); + | 4 -> field_rule_config := ( Some ( ( @@ -14823,7 +14894,7 @@ let read_scan_config = ( ) p lb ) ); - | 4 -> + | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_ci_config_from_cloud := ( Some ( @@ -14833,7 +14904,7 @@ let read_scan_config = ( ) ); ) - | 5 -> + | 6 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_autofix := ( ( @@ -14841,7 +14912,7 @@ let read_scan_config = ( ) p lb ); ) - | 6 -> + | 7 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_deepsemgrep := ( ( @@ -14849,7 +14920,7 @@ let read_scan_config = ( ) p lb ); ) - | 7 -> + | 8 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_dependency_query := ( ( @@ -14857,7 +14928,7 @@ let read_scan_config = ( ) p lb ); ) - | 8 -> + | 9 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_triage_ignored_syntactic_ids := ( ( @@ -14865,7 +14936,7 @@ let read_scan_config = ( ) p lb ); ) - | 9 -> + | 10 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_triage_ignored_match_based_ids := ( ( @@ -14873,7 +14944,7 @@ let read_scan_config = ( ) p lb ); ) - | 10 -> + | 11 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_ignored_files := ( ( @@ -14881,7 +14952,7 @@ let read_scan_config = ( ) p lb ); ) - | 11 -> + | 12 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_enabled_products := ( Some ( @@ -14891,7 +14962,7 @@ let read_scan_config = ( ) ); ) - | 12 -> + | 13 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_actions := ( ( @@ -14917,7 +14988,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 ( - 12 + 13 ) else ( -1 @@ -14925,7 +14996,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 + 6 ) else ( -1 @@ -14943,7 +15014,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 + 7 ) else ( -1 @@ -14951,7 +15022,7 @@ let read_scan_config = ( ) | '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) = 'c' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'f' && String.unsafe_get s (pos+9) = 'i' && String.unsafe_get s (pos+10) = 'g' then ( - 3 + 4 ) else ( -1 @@ -14963,7 +15034,7 @@ let read_scan_config = ( ) | 12 -> ( if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'c' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'm' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 's' then ( - 2 + 3 ) else ( -1 @@ -14981,7 +15052,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 ( - 10 + 11 ) else ( -1 @@ -15003,7 +15074,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 + 8 ) else ( -1 @@ -15011,7 +15082,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 ( - 11 + 12 ) else ( -1 @@ -15023,7 +15094,15 @@ let read_scan_config = ( ) | 20 -> ( if String.unsafe_get s pos = 'c' && 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 + 5 + ) + else ( + -1 + ) + ) + | 24 -> ( + if String.unsafe_get s pos = 'd' && 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) = 'o' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'f' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'u' && String.unsafe_get s (pos+16) = 'r' && String.unsafe_get s (pos+17) = 'e' && String.unsafe_get s (pos+18) = '_' && String.unsafe_get s (pos+19) = 'f' && String.unsafe_get s (pos+20) = 'l' && String.unsafe_get s (pos+21) = 'a' && String.unsafe_get s (pos+22) = 'g' && String.unsafe_get s (pos+23) = 's' then ( + 2 ) else ( -1 @@ -15031,7 +15110,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 ( - 8 + 9 ) else ( -1 @@ -15039,7 +15118,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 ( - 9 + 10 ) else ( -1 @@ -15070,7 +15149,7 @@ let read_scan_config = ( ) ); | 2 -> - field_policy_names := ( + field_deployment_feature_flags := ( Some ( ( read__string_list @@ -15078,6 +15157,14 @@ let read_scan_config = ( ) ); | 3 -> + field_policy_names := ( + Some ( + ( + read__string_list + ) p lb + ) + ); + | 4 -> field_rule_config := ( Some ( ( @@ -15085,7 +15172,7 @@ let read_scan_config = ( ) p lb ) ); - | 4 -> + | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_ci_config_from_cloud := ( Some ( @@ -15095,7 +15182,7 @@ let read_scan_config = ( ) ); ) - | 5 -> + | 6 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_autofix := ( ( @@ -15103,7 +15190,7 @@ let read_scan_config = ( ) p lb ); ) - | 6 -> + | 7 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_deepsemgrep := ( ( @@ -15111,7 +15198,7 @@ let read_scan_config = ( ) p lb ); ) - | 7 -> + | 8 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_dependency_query := ( ( @@ -15119,7 +15206,7 @@ let read_scan_config = ( ) p lb ); ) - | 8 -> + | 9 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_triage_ignored_syntactic_ids := ( ( @@ -15127,7 +15214,7 @@ let read_scan_config = ( ) p lb ); ) - | 9 -> + | 10 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_triage_ignored_match_based_ids := ( ( @@ -15135,7 +15222,7 @@ let read_scan_config = ( ) p lb ); ) - | 10 -> + | 11 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_ignored_files := ( ( @@ -15143,7 +15230,7 @@ let read_scan_config = ( ) p lb ); ) - | 11 -> + | 12 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_enabled_products := ( Some ( @@ -15153,7 +15240,7 @@ let read_scan_config = ( ) ); ) - | 12 -> + | 13 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_actions := ( ( @@ -15172,6 +15259,7 @@ let read_scan_config = ( { deployment_id = (match !field_deployment_id with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_id"); deployment_name = (match !field_deployment_name with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_name"); + deployment_feature_flags = (match !field_deployment_feature_flags with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_feature_flags"); 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; diff --git a/semgrep_output_v1_j.mli b/semgrep_output_v1_j.mli index 1bf81594..96137f2e 100644 --- a/semgrep_output_v1_j.mli +++ b/semgrep_output_v1_j.mli @@ -261,7 +261,8 @@ type scan_info = Semgrep_output_v1_t.scan_info = { id: int option; enabled_products: product list; deployment_id: int; - deployment_name: string + deployment_name: string; + deployment_feature_flags: string list } type scan_configuration = Semgrep_output_v1_t.scan_configuration = { @@ -369,6 +370,7 @@ type ci_config_from_cloud = Semgrep_output_v1_t.ci_config_from_cloud = { type scan_config = Semgrep_output_v1_t.scan_config = { deployment_id: int; deployment_name: string; + deployment_feature_flags: string list; policy_names: string list; rule_config: string; ci_config_from_cloud: ci_config_from_cloud option; From 9b89df572c4e69f7a8d9b9b747ce73a7e5a99f85 Mon Sep 17 00:00:00 2001 From: SayyantR Date: Tue, 22 Oct 2024 13:47:48 -0700 Subject: [PATCH 2/4] Added feature_flag type --- semgrep_output_v1.atd | 9 +- semgrep_output_v1.jsonschema | 16 ++- semgrep_output_v1.proto | 11 +- semgrep_output_v1.py | 43 ++++++- semgrep_output_v1.ts | 31 +++++- semgrep_output_v1_j.ml | 210 ++++++++++++++++++++++++++++++++--- semgrep_output_v1_j.mli | 29 ++++- 7 files changed, 308 insertions(+), 41 deletions(-) diff --git a/semgrep_output_v1.atd b/semgrep_output_v1.atd index 363374ab..78fd88b8 100644 --- a/semgrep_output_v1.atd +++ b/semgrep_output_v1.atd @@ -1220,6 +1220,11 @@ type features = { ~dependency_query: bool; } +type feature_flag = { + name: string; + enabled: bool; +} + type triage_ignored = { ~triage_ignored_syntactic_ids: string list; ~triage_ignored_match_based_ids: string list; @@ -1294,7 +1299,7 @@ type scan_config = { deployment_id: int; deployment_name: string; (* deployment specific feature flag settings which impact CI behavior *) - deployment_feature_flags: string list; + deployment_feature_flag: feature_flag list; (* 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) *) @@ -1440,7 +1445,7 @@ type scan_info = { deployment_id: int; deployment_name: string; (* deployment specific feature flag settings which impact CI behavior *) - deployment_feature_flags: string list; + deployment_feature_flags: feature_flag list; } diff --git a/semgrep_output_v1.jsonschema b/semgrep_output_v1.jsonschema index 012403b0..81cc8b88 100644 --- a/semgrep_output_v1.jsonschema +++ b/semgrep_output_v1.jsonschema @@ -951,6 +951,14 @@ "dependency_query": { "type": "boolean" } } }, + "feature_flag": { + "type": "object", + "required": [ "name", "enabled" ], + "properties": { + "name": { "type": "string" }, + "enabled": { "type": "boolean" } + } + }, "triage_ignored": { "type": "object", "required": [], @@ -1017,15 +1025,15 @@ "scan_config": { "type": "object", "required": [ - "deployment_id", "deployment_name", "deployment_feature_flags", + "deployment_id", "deployment_name", "deployment_feature_flag", "policy_names", "rule_config" ], "properties": { "deployment_id": { "type": "integer" }, "deployment_name": { "type": "string" }, - "deployment_feature_flags": { + "deployment_feature_flag": { "type": "array", - "items": { "type": "string" } + "items": { "$ref": "#/definitions/feature_flag" } }, "policy_names": { "type": "array", "items": { "type": "string" } }, "rule_config": { "type": "string" }, @@ -1149,7 +1157,7 @@ "deployment_name": { "type": "string" }, "deployment_feature_flags": { "type": "array", - "items": { "type": "string" } + "items": { "$ref": "#/definitions/feature_flag" } } } }, diff --git a/semgrep_output_v1.proto b/semgrep_output_v1.proto index c8c2e1aa..5d02849f 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: 560ae974fbfb7c45870759ce04382caf1c80c51c16b35deea6d9c6c8a170dca7 +// Source file sha256 digest: 293e036b12c113d2731943081ef1f59503c7180e652ec38f20402980b4240132 syntax = "proto3"; @@ -349,6 +349,11 @@ message Features { bool dependency_query = 471197362; } +message FeatureFlag { + string name = 3116757; + bool enabled = 476613995; +} + message TriageIgnored { repeated string triage_ignored_syntactic_ids = 211590151; repeated string triage_ignored_match_based_ids = 327942260; @@ -377,7 +382,7 @@ message CiConfigFromRepo { message ScanConfig { int64 deployment_id = 188822146; string deployment_name = 129624728; - repeated string deployment_feature_flags = 530134217; + repeated FeatureFlag deployment_feature_flag = 468870978; repeated string policy_names = 175625923; string rule_config = 403140712; CiConfigFromCloud ci_config_from_cloud = 120268883; @@ -450,7 +455,7 @@ message ScanInfo { repeated google.protobuf.Any enabled_products = 447415338; int64 deployment_id = 188822146; string deployment_name = 129624728; - repeated string deployment_feature_flags = 530134217; + repeated FeatureFlag deployment_feature_flags = 530134217; } message ScanConfiguration { diff --git a/semgrep_output_v1.py b/semgrep_output_v1.py index c4ebff11..b5532980 100644 --- a/semgrep_output_v1.py +++ b/semgrep_output_v1.py @@ -3039,6 +3039,37 @@ def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) +@dataclass +class FeatureFlag: + """Original type: feature_flag = { ... }""" + + name: str + enabled: bool + + @classmethod + def from_json(cls, x: Any) -> 'FeatureFlag': + if isinstance(x, dict): + return cls( + name=_atd_read_string(x['name']) if 'name' in x else _atd_missing_json_field('FeatureFlag', 'name'), + enabled=_atd_read_bool(x['enabled']) if 'enabled' in x else _atd_missing_json_field('FeatureFlag', 'enabled'), + ) + else: + _atd_bad_json('FeatureFlag', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['name'] = _atd_write_string(self.name) + res['enabled'] = _atd_write_bool(self.enabled) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'FeatureFlag': + return cls.from_json(json.loads(x)) + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + @dataclass class ScanInfo: """Original type: scan_info = { ... }""" @@ -3046,7 +3077,7 @@ class ScanInfo: enabled_products: List[Product] deployment_id: int deployment_name: str - deployment_feature_flags: List[str] + deployment_feature_flags: List[FeatureFlag] id: Optional[int] = None @classmethod @@ -3056,7 +3087,7 @@ def from_json(cls, x: Any) -> 'ScanInfo': enabled_products=_atd_read_list(Product.from_json)(x['enabled_products']) if 'enabled_products' in x else _atd_missing_json_field('ScanInfo', 'enabled_products'), deployment_id=_atd_read_int(x['deployment_id']) if 'deployment_id' in x else _atd_missing_json_field('ScanInfo', 'deployment_id'), deployment_name=_atd_read_string(x['deployment_name']) if 'deployment_name' in x else _atd_missing_json_field('ScanInfo', 'deployment_name'), - deployment_feature_flags=_atd_read_list(_atd_read_string)(x['deployment_feature_flags']) if 'deployment_feature_flags' in x else _atd_missing_json_field('ScanInfo', 'deployment_feature_flags'), + deployment_feature_flags=_atd_read_list(FeatureFlag.from_json)(x['deployment_feature_flags']) if 'deployment_feature_flags' in x else _atd_missing_json_field('ScanInfo', 'deployment_feature_flags'), id=_atd_read_int(x['id']) if 'id' in x else None, ) else: @@ -3067,7 +3098,7 @@ def to_json(self) -> Any: res['enabled_products'] = _atd_write_list((lambda x: x.to_json()))(self.enabled_products) res['deployment_id'] = _atd_write_int(self.deployment_id) res['deployment_name'] = _atd_write_string(self.deployment_name) - res['deployment_feature_flags'] = _atd_write_list(_atd_write_string)(self.deployment_feature_flags) + res['deployment_feature_flags'] = _atd_write_list((lambda x: x.to_json()))(self.deployment_feature_flags) if self.id is not None: res['id'] = _atd_write_int(self.id) return res @@ -3695,7 +3726,7 @@ class ScanConfig: deployment_id: int deployment_name: str - deployment_feature_flags: List[str] + deployment_feature_flag: List[FeatureFlag] policy_names: List[str] rule_config: str ci_config_from_cloud: Optional[CiConfigFromCloud] = None @@ -3714,7 +3745,7 @@ def from_json(cls, x: Any) -> 'ScanConfig': return cls( deployment_id=_atd_read_int(x['deployment_id']) if 'deployment_id' in x else _atd_missing_json_field('ScanConfig', 'deployment_id'), deployment_name=_atd_read_string(x['deployment_name']) if 'deployment_name' in x else _atd_missing_json_field('ScanConfig', 'deployment_name'), - deployment_feature_flags=_atd_read_list(_atd_read_string)(x['deployment_feature_flags']) if 'deployment_feature_flags' in x else _atd_missing_json_field('ScanConfig', 'deployment_feature_flags'), + deployment_feature_flag=_atd_read_list(FeatureFlag.from_json)(x['deployment_feature_flag']) if 'deployment_feature_flag' in x else _atd_missing_json_field('ScanConfig', 'deployment_feature_flag'), 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, @@ -3734,7 +3765,7 @@ def to_json(self) -> Any: res: Dict[str, Any] = {} res['deployment_id'] = _atd_write_int(self.deployment_id) res['deployment_name'] = _atd_write_string(self.deployment_name) - res['deployment_feature_flags'] = _atd_write_list(_atd_write_string)(self.deployment_feature_flags) + res['deployment_feature_flag'] = _atd_write_list((lambda x: x.to_json()))(self.deployment_feature_flag) 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: diff --git a/semgrep_output_v1.ts b/semgrep_output_v1.ts index 6d244101..1239cfbe 100644 --- a/semgrep_output_v1.ts +++ b/semgrep_output_v1.ts @@ -537,6 +537,11 @@ export type Features = { dependency_query: boolean; } +export type FeatureFlag = { + name: string; + enabled: boolean; +} + export type TriageIgnored = { triage_ignored_syntactic_ids: string[]; triage_ignored_match_based_ids: string[]; @@ -572,7 +577,7 @@ export type Tag = string export type ScanConfig = { deployment_id: number /*int*/; deployment_name: string; - deployment_feature_flags: string[]; + deployment_feature_flag: FeatureFlag[]; policy_names: string[]; rule_config: string; ci_config_from_cloud?: CiConfigFromCloud; @@ -645,7 +650,7 @@ export type ScanInfo = { enabled_products: Product[]; deployment_id: number /*int*/; deployment_name: string; - deployment_feature_flags: string[]; + deployment_feature_flags: FeatureFlag[]; } export type ScanConfiguration = { @@ -2610,6 +2615,20 @@ export function readFeatures(x: any, context: any = x): Features { }; } +export function writeFeatureFlag(x: FeatureFlag, context: any = x): any { + return { + 'name': _atd_write_required_field('FeatureFlag', 'name', _atd_write_string, x.name, x), + 'enabled': _atd_write_required_field('FeatureFlag', 'enabled', _atd_write_bool, x.enabled, x), + }; +} + +export function readFeatureFlag(x: any, context: any = x): FeatureFlag { + return { + name: _atd_read_required_field('FeatureFlag', 'name', _atd_read_string, x['name'], x), + enabled: _atd_read_required_field('FeatureFlag', 'enabled', _atd_read_bool, x['enabled'], x), + }; +} + export function writeTriageIgnored(x: TriageIgnored, context: any = x): any { return { 'triage_ignored_syntactic_ids': _atd_write_field_with_default(_atd_write_array(_atd_write_string), [], x.triage_ignored_syntactic_ids, x), @@ -2710,7 +2729,7 @@ export function writeScanConfig(x: ScanConfig, context: any = x): any { return { 'deployment_id': _atd_write_required_field('ScanConfig', 'deployment_id', _atd_write_int, x.deployment_id, x), 'deployment_name': _atd_write_required_field('ScanConfig', 'deployment_name', _atd_write_string, x.deployment_name, x), - 'deployment_feature_flags': _atd_write_required_field('ScanConfig', 'deployment_feature_flags', _atd_write_array(_atd_write_string), x.deployment_feature_flags, x), + 'deployment_feature_flag': _atd_write_required_field('ScanConfig', 'deployment_feature_flag', _atd_write_array(writeFeatureFlag), x.deployment_feature_flag, 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), @@ -2729,7 +2748,7 @@ export function readScanConfig(x: any, context: any = x): ScanConfig { return { deployment_id: _atd_read_required_field('ScanConfig', 'deployment_id', _atd_read_int, x['deployment_id'], x), deployment_name: _atd_read_required_field('ScanConfig', 'deployment_name', _atd_read_string, x['deployment_name'], x), - deployment_feature_flags: _atd_read_required_field('ScanConfig', 'deployment_feature_flags', _atd_read_array(_atd_read_string), x['deployment_feature_flags'], x), + deployment_feature_flag: _atd_read_required_field('ScanConfig', 'deployment_feature_flag', _atd_read_array(readFeatureFlag), x['deployment_feature_flag'], 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), @@ -2878,7 +2897,7 @@ export function writeScanInfo(x: ScanInfo, context: any = x): any { '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), - 'deployment_feature_flags': _atd_write_required_field('ScanInfo', 'deployment_feature_flags', _atd_write_array(_atd_write_string), x.deployment_feature_flags, x), + 'deployment_feature_flags': _atd_write_required_field('ScanInfo', 'deployment_feature_flags', _atd_write_array(writeFeatureFlag), x.deployment_feature_flags, x), }; } @@ -2888,7 +2907,7 @@ export function readScanInfo(x: any, context: any = x): ScanInfo { 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), - deployment_feature_flags: _atd_read_required_field('ScanInfo', 'deployment_feature_flags', _atd_read_array(_atd_read_string), x['deployment_feature_flags'], x), + deployment_feature_flags: _atd_read_required_field('ScanInfo', 'deployment_feature_flags', _atd_read_array(readFeatureFlag), x['deployment_feature_flags'], x), }; } diff --git a/semgrep_output_v1_j.ml b/semgrep_output_v1_j.ml index 755983aa..b6a49516 100644 --- a/semgrep_output_v1_j.ml +++ b/semgrep_output_v1_j.ml @@ -257,12 +257,17 @@ type scanned_and_skipped = Semgrep_output_v1_t.scanned_and_skipped = { type product = Semgrep_output_v1_t.product [@@deriving show, eq] +type feature_flag = Semgrep_output_v1_t.feature_flag = { + name: string; + enabled: bool +} + type scan_info = Semgrep_output_v1_t.scan_info = { id: int option; enabled_products: product list; deployment_id: int; deployment_name: string; - deployment_feature_flags: string list + deployment_feature_flags: feature_flag list } type scan_configuration = Semgrep_output_v1_t.scan_configuration = { @@ -370,7 +375,7 @@ type ci_config_from_cloud = Semgrep_output_v1_t.ci_config_from_cloud = { type scan_config = Semgrep_output_v1_t.scan_config = { deployment_id: int; deployment_name: string; - deployment_feature_flags: string list; + deployment_feature_flag: feature_flag list; policy_names: string list; rule_config: string; ci_config_from_cloud: ci_config_from_cloud option; @@ -9467,6 +9472,159 @@ let read_product = ( ) let product_of_string s = read_product (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_feature_flag : _ -> feature_flag -> _ = ( + fun ob (x : feature_flag) -> + 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 "\"name\":"; + ( + Yojson.Safe.write_string + ) + ob x.name; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"enabled\":"; + ( + Yojson.Safe.write_bool + ) + ob x.enabled; + Buffer.add_char ob '}'; +) +let string_of_feature_flag ?(len = 1024) x = + let ob = Buffer.create len in + write_feature_flag ob x; + Buffer.contents ob +let read_feature_flag = ( + fun p lb -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_lcurl p lb; + let field_name = ref (None) in + let field_enabled = 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 = 'n' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( + 0 + ) + else ( + -1 + ) + ) + | 7 -> ( + if String.unsafe_get s pos = 'e' && 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' 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_name := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + | 1 -> + field_enabled := ( + 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 + | 4 -> ( + if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( + 0 + ) + else ( + -1 + ) + ) + | 7 -> ( + if String.unsafe_get s pos = 'e' && 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' 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_name := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + | 1 -> + field_enabled := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + done; + assert false; + with Yojson.End_of_object -> ( + ( + { + name = (match !field_name with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "name"); + enabled = (match !field_enabled with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "enabled"); + } + : feature_flag) + ) +) +let feature_flag_of_string s = + read_feature_flag (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__product_list = ( Atdgen_runtime.Oj_run.write_list ( write_product @@ -9540,6 +9698,22 @@ let read__int_option = ( ) let _int_option_of_string s = read__int_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__feature_flag_list = ( + Atdgen_runtime.Oj_run.write_list ( + write_feature_flag + ) +) +let string_of__feature_flag_list ?(len = 1024) x = + let ob = Buffer.create len in + write__feature_flag_list ob x; + Buffer.contents ob +let read__feature_flag_list = ( + Atdgen_runtime.Oj_run.read_list ( + read_feature_flag + ) +) +let _feature_flag_list_of_string s = + read__feature_flag_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_scan_info : _ -> scan_info -> _ = ( fun ob (x : scan_info) -> Buffer.add_char ob '{'; @@ -9588,7 +9762,7 @@ let write_scan_info : _ -> scan_info -> _ = ( Buffer.add_char ob ','; Buffer.add_string ob "\"deployment_feature_flags\":"; ( - write__string_list + write__feature_flag_list ) ob x.deployment_feature_flags; Buffer.add_char ob '}'; @@ -9701,7 +9875,7 @@ let read_scan_info = ( field_deployment_feature_flags := ( Some ( ( - read__string_list + read__feature_flag_list ) p lb ) ); @@ -9804,7 +9978,7 @@ let read_scan_info = ( field_deployment_feature_flags := ( Some ( ( - read__string_list + read__feature_flag_list ) p lb ) ); @@ -14564,11 +14738,11 @@ let write_scan_config : _ -> scan_config -> _ = ( is_first := false else Buffer.add_char ob ','; - Buffer.add_string ob "\"deployment_feature_flags\":"; + Buffer.add_string ob "\"deployment_feature_flag\":"; ( - write__string_list + write__feature_flag_list ) - ob x.deployment_feature_flags; + ob x.deployment_feature_flag; if !is_first then is_first := false else @@ -14684,7 +14858,7 @@ let read_scan_config = ( Yojson.Safe.read_lcurl p lb; let field_deployment_id = ref (None) in let field_deployment_name = ref (None) in - let field_deployment_feature_flags = ref (None) in + let field_deployment_feature_flag = 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 @@ -14822,8 +14996,8 @@ let read_scan_config = ( -1 ) ) - | 24 -> ( - if String.unsafe_get s pos = 'd' && 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) = 'o' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'f' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'u' && String.unsafe_get s (pos+16) = 'r' && String.unsafe_get s (pos+17) = 'e' && String.unsafe_get s (pos+18) = '_' && String.unsafe_get s (pos+19) = 'f' && String.unsafe_get s (pos+20) = 'l' && String.unsafe_get s (pos+21) = 'a' && String.unsafe_get s (pos+22) = 'g' && String.unsafe_get s (pos+23) = 's' then ( + | 23 -> ( + if String.unsafe_get s pos = 'd' && 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) = 'o' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'f' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'u' && String.unsafe_get s (pos+16) = 'r' && String.unsafe_get s (pos+17) = 'e' && String.unsafe_get s (pos+18) = '_' && String.unsafe_get s (pos+19) = 'f' && String.unsafe_get s (pos+20) = 'l' && String.unsafe_get s (pos+21) = 'a' && String.unsafe_get s (pos+22) = 'g' then ( 2 ) else ( @@ -14871,10 +15045,10 @@ let read_scan_config = ( ) ); | 2 -> - field_deployment_feature_flags := ( + field_deployment_feature_flag := ( Some ( ( - read__string_list + read__feature_flag_list ) p lb ) ); @@ -15100,8 +15274,8 @@ let read_scan_config = ( -1 ) ) - | 24 -> ( - if String.unsafe_get s pos = 'd' && 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) = 'o' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'f' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'u' && String.unsafe_get s (pos+16) = 'r' && String.unsafe_get s (pos+17) = 'e' && String.unsafe_get s (pos+18) = '_' && String.unsafe_get s (pos+19) = 'f' && String.unsafe_get s (pos+20) = 'l' && String.unsafe_get s (pos+21) = 'a' && String.unsafe_get s (pos+22) = 'g' && String.unsafe_get s (pos+23) = 's' then ( + | 23 -> ( + if String.unsafe_get s pos = 'd' && 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) = 'o' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'f' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'u' && String.unsafe_get s (pos+16) = 'r' && String.unsafe_get s (pos+17) = 'e' && String.unsafe_get s (pos+18) = '_' && String.unsafe_get s (pos+19) = 'f' && String.unsafe_get s (pos+20) = 'l' && String.unsafe_get s (pos+21) = 'a' && String.unsafe_get s (pos+22) = 'g' then ( 2 ) else ( @@ -15149,10 +15323,10 @@ let read_scan_config = ( ) ); | 2 -> - field_deployment_feature_flags := ( + field_deployment_feature_flag := ( Some ( ( - read__string_list + read__feature_flag_list ) p lb ) ); @@ -15259,7 +15433,7 @@ let read_scan_config = ( { deployment_id = (match !field_deployment_id with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_id"); deployment_name = (match !field_deployment_name with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_name"); - deployment_feature_flags = (match !field_deployment_feature_flags with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_feature_flags"); + deployment_feature_flag = (match !field_deployment_feature_flag with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_feature_flag"); 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; diff --git a/semgrep_output_v1_j.mli b/semgrep_output_v1_j.mli index 96137f2e..ee3e3e8d 100644 --- a/semgrep_output_v1_j.mli +++ b/semgrep_output_v1_j.mli @@ -257,12 +257,17 @@ type scanned_and_skipped = Semgrep_output_v1_t.scanned_and_skipped = { type product = Semgrep_output_v1_t.product [@@deriving show, eq] +type feature_flag = Semgrep_output_v1_t.feature_flag = { + name: string; + enabled: bool +} + type scan_info = Semgrep_output_v1_t.scan_info = { id: int option; enabled_products: product list; deployment_id: int; deployment_name: string; - deployment_feature_flags: string list + deployment_feature_flags: feature_flag list } type scan_configuration = Semgrep_output_v1_t.scan_configuration = { @@ -370,7 +375,7 @@ type ci_config_from_cloud = Semgrep_output_v1_t.ci_config_from_cloud = { type scan_config = Semgrep_output_v1_t.scan_config = { deployment_id: int; deployment_name: string; - deployment_feature_flags: string list; + deployment_feature_flag: feature_flag list; policy_names: string list; rule_config: string; ci_config_from_cloud: ci_config_from_cloud option; @@ -1828,6 +1833,26 @@ val product_of_string : string -> product (** Deserialize JSON data of type {!type:product}. *) +val write_feature_flag : + Buffer.t -> feature_flag -> unit + (** Output a JSON value of type {!type:feature_flag}. *) + +val string_of_feature_flag : + ?len:int -> feature_flag -> string + (** Serialize a value of type {!type:feature_flag} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_feature_flag : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> feature_flag + (** Input JSON data of type {!type:feature_flag}. *) + +val feature_flag_of_string : + string -> feature_flag + (** Deserialize JSON data of type {!type:feature_flag}. *) + val write_scan_info : Buffer.t -> scan_info -> unit (** Output a JSON value of type {!type:scan_info}. *) From 9bd8695ab07f1ba581179d690318f2e8ee5da442 Mon Sep 17 00:00:00 2001 From: SayyantR Date: Tue, 22 Oct 2024 13:56:44 -0700 Subject: [PATCH 3/4] Backwards compatible oooops --- semgrep_output_v1.atd | 4 +- semgrep_output_v1.jsonschema | 8 +- semgrep_output_v1.proto | 2 +- semgrep_output_v1.py | 14 +-- semgrep_output_v1.ts | 12 +-- semgrep_output_v1_j.ml | 169 ++++++++++++++++++++++++----------- semgrep_output_v1_j.mli | 4 +- 7 files changed, 140 insertions(+), 73 deletions(-) diff --git a/semgrep_output_v1.atd b/semgrep_output_v1.atd index 78fd88b8..b6a5f267 100644 --- a/semgrep_output_v1.atd +++ b/semgrep_output_v1.atd @@ -1299,7 +1299,7 @@ type scan_config = { deployment_id: int; deployment_name: string; (* deployment specific feature flag settings which impact CI behavior *) - deployment_feature_flag: feature_flag list; + ?deployment_feature_flag: feature_flag list option; (* 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) *) @@ -1445,7 +1445,7 @@ type scan_info = { deployment_id: int; deployment_name: string; (* deployment specific feature flag settings which impact CI behavior *) - deployment_feature_flags: feature_flag list; + ?deployment_feature_flags: feature_flag list option; } diff --git a/semgrep_output_v1.jsonschema b/semgrep_output_v1.jsonschema index 81cc8b88..5acec281 100644 --- a/semgrep_output_v1.jsonschema +++ b/semgrep_output_v1.jsonschema @@ -1025,8 +1025,7 @@ "scan_config": { "type": "object", "required": [ - "deployment_id", "deployment_name", "deployment_feature_flag", - "policy_names", "rule_config" + "deployment_id", "deployment_name", "policy_names", "rule_config" ], "properties": { "deployment_id": { "type": "integer" }, @@ -1143,10 +1142,7 @@ }, "scan_info": { "type": "object", - "required": [ - "enabled_products", "deployment_id", "deployment_name", - "deployment_feature_flags" - ], + "required": [ "enabled_products", "deployment_id", "deployment_name" ], "properties": { "id": { "type": "integer" }, "enabled_products": { diff --git a/semgrep_output_v1.proto b/semgrep_output_v1.proto index 5d02849f..32c5052b 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: 293e036b12c113d2731943081ef1f59503c7180e652ec38f20402980b4240132 +// Source file sha256 digest: fdf2a74174d3ea6059970c5786274ff4e773e4492e5b2d5c89a978399c5afc51 syntax = "proto3"; diff --git a/semgrep_output_v1.py b/semgrep_output_v1.py index b5532980..201cb6b1 100644 --- a/semgrep_output_v1.py +++ b/semgrep_output_v1.py @@ -3077,8 +3077,8 @@ class ScanInfo: enabled_products: List[Product] deployment_id: int deployment_name: str - deployment_feature_flags: List[FeatureFlag] id: Optional[int] = None + deployment_feature_flags: Optional[List[FeatureFlag]] = None @classmethod def from_json(cls, x: Any) -> 'ScanInfo': @@ -3087,8 +3087,8 @@ def from_json(cls, x: Any) -> 'ScanInfo': enabled_products=_atd_read_list(Product.from_json)(x['enabled_products']) if 'enabled_products' in x else _atd_missing_json_field('ScanInfo', 'enabled_products'), deployment_id=_atd_read_int(x['deployment_id']) if 'deployment_id' in x else _atd_missing_json_field('ScanInfo', 'deployment_id'), deployment_name=_atd_read_string(x['deployment_name']) if 'deployment_name' in x else _atd_missing_json_field('ScanInfo', 'deployment_name'), - deployment_feature_flags=_atd_read_list(FeatureFlag.from_json)(x['deployment_feature_flags']) if 'deployment_feature_flags' in x else _atd_missing_json_field('ScanInfo', 'deployment_feature_flags'), id=_atd_read_int(x['id']) if 'id' in x else None, + deployment_feature_flags=_atd_read_list(FeatureFlag.from_json)(x['deployment_feature_flags']) if 'deployment_feature_flags' in x else None, ) else: _atd_bad_json('ScanInfo', x) @@ -3098,9 +3098,10 @@ def to_json(self) -> Any: res['enabled_products'] = _atd_write_list((lambda x: x.to_json()))(self.enabled_products) res['deployment_id'] = _atd_write_int(self.deployment_id) res['deployment_name'] = _atd_write_string(self.deployment_name) - res['deployment_feature_flags'] = _atd_write_list((lambda x: x.to_json()))(self.deployment_feature_flags) if self.id is not None: res['id'] = _atd_write_int(self.id) + if self.deployment_feature_flags is not None: + res['deployment_feature_flags'] = _atd_write_list((lambda x: x.to_json()))(self.deployment_feature_flags) return res @classmethod @@ -3726,9 +3727,9 @@ class ScanConfig: deployment_id: int deployment_name: str - deployment_feature_flag: List[FeatureFlag] policy_names: List[str] rule_config: str + deployment_feature_flag: Optional[List[FeatureFlag]] = None ci_config_from_cloud: Optional[CiConfigFromCloud] = None autofix: bool = field(default_factory=lambda: False) deepsemgrep: bool = field(default_factory=lambda: False) @@ -3745,9 +3746,9 @@ def from_json(cls, x: Any) -> 'ScanConfig': return cls( deployment_id=_atd_read_int(x['deployment_id']) if 'deployment_id' in x else _atd_missing_json_field('ScanConfig', 'deployment_id'), deployment_name=_atd_read_string(x['deployment_name']) if 'deployment_name' in x else _atd_missing_json_field('ScanConfig', 'deployment_name'), - deployment_feature_flag=_atd_read_list(FeatureFlag.from_json)(x['deployment_feature_flag']) if 'deployment_feature_flag' in x else _atd_missing_json_field('ScanConfig', 'deployment_feature_flag'), 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'), + deployment_feature_flag=_atd_read_list(FeatureFlag.from_json)(x['deployment_feature_flag']) if 'deployment_feature_flag' in x else None, 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, @@ -3765,9 +3766,10 @@ def to_json(self) -> Any: res: Dict[str, Any] = {} res['deployment_id'] = _atd_write_int(self.deployment_id) res['deployment_name'] = _atd_write_string(self.deployment_name) - res['deployment_feature_flag'] = _atd_write_list((lambda x: x.to_json()))(self.deployment_feature_flag) res['policy_names'] = _atd_write_list(_atd_write_string)(self.policy_names) res['rule_config'] = _atd_write_string(self.rule_config) + if self.deployment_feature_flag is not None: + res['deployment_feature_flag'] = _atd_write_list((lambda x: x.to_json()))(self.deployment_feature_flag) 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) diff --git a/semgrep_output_v1.ts b/semgrep_output_v1.ts index 1239cfbe..c0625caa 100644 --- a/semgrep_output_v1.ts +++ b/semgrep_output_v1.ts @@ -577,7 +577,7 @@ export type Tag = string export type ScanConfig = { deployment_id: number /*int*/; deployment_name: string; - deployment_feature_flag: FeatureFlag[]; + deployment_feature_flag?: FeatureFlag[]; policy_names: string[]; rule_config: string; ci_config_from_cloud?: CiConfigFromCloud; @@ -650,7 +650,7 @@ export type ScanInfo = { enabled_products: Product[]; deployment_id: number /*int*/; deployment_name: string; - deployment_feature_flags: FeatureFlag[]; + deployment_feature_flags?: FeatureFlag[]; } export type ScanConfiguration = { @@ -2729,7 +2729,7 @@ export function writeScanConfig(x: ScanConfig, context: any = x): any { return { 'deployment_id': _atd_write_required_field('ScanConfig', 'deployment_id', _atd_write_int, x.deployment_id, x), 'deployment_name': _atd_write_required_field('ScanConfig', 'deployment_name', _atd_write_string, x.deployment_name, x), - 'deployment_feature_flag': _atd_write_required_field('ScanConfig', 'deployment_feature_flag', _atd_write_array(writeFeatureFlag), x.deployment_feature_flag, x), + 'deployment_feature_flag': _atd_write_optional_field(_atd_write_array(writeFeatureFlag), x.deployment_feature_flag, 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), @@ -2748,7 +2748,7 @@ export function readScanConfig(x: any, context: any = x): ScanConfig { return { deployment_id: _atd_read_required_field('ScanConfig', 'deployment_id', _atd_read_int, x['deployment_id'], x), deployment_name: _atd_read_required_field('ScanConfig', 'deployment_name', _atd_read_string, x['deployment_name'], x), - deployment_feature_flag: _atd_read_required_field('ScanConfig', 'deployment_feature_flag', _atd_read_array(readFeatureFlag), x['deployment_feature_flag'], x), + deployment_feature_flag: _atd_read_optional_field(_atd_read_array(readFeatureFlag), x['deployment_feature_flag'], 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), @@ -2897,7 +2897,7 @@ export function writeScanInfo(x: ScanInfo, context: any = x): any { '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), - 'deployment_feature_flags': _atd_write_required_field('ScanInfo', 'deployment_feature_flags', _atd_write_array(writeFeatureFlag), x.deployment_feature_flags, x), + 'deployment_feature_flags': _atd_write_optional_field(_atd_write_array(writeFeatureFlag), x.deployment_feature_flags, x), }; } @@ -2907,7 +2907,7 @@ export function readScanInfo(x: any, context: any = x): ScanInfo { 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), - deployment_feature_flags: _atd_read_required_field('ScanInfo', 'deployment_feature_flags', _atd_read_array(readFeatureFlag), x['deployment_feature_flags'], x), + deployment_feature_flags: _atd_read_optional_field(_atd_read_array(readFeatureFlag), x['deployment_feature_flags'], x), }; } diff --git a/semgrep_output_v1_j.ml b/semgrep_output_v1_j.ml index b6a49516..67f67366 100644 --- a/semgrep_output_v1_j.ml +++ b/semgrep_output_v1_j.ml @@ -267,7 +267,7 @@ type scan_info = Semgrep_output_v1_t.scan_info = { enabled_products: product list; deployment_id: int; deployment_name: string; - deployment_feature_flags: feature_flag list + deployment_feature_flags: feature_flag list option } type scan_configuration = Semgrep_output_v1_t.scan_configuration = { @@ -375,7 +375,7 @@ type ci_config_from_cloud = Semgrep_output_v1_t.ci_config_from_cloud = { type scan_config = Semgrep_output_v1_t.scan_config = { deployment_id: int; deployment_name: string; - deployment_feature_flag: feature_flag list; + deployment_feature_flag: feature_flag list option; policy_names: string list; rule_config: string; ci_config_from_cloud: ci_config_from_cloud option; @@ -9714,6 +9714,63 @@ let read__feature_flag_list = ( ) let _feature_flag_list_of_string s = read__feature_flag_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__feature_flag_list_option = ( + Atdgen_runtime.Oj_run.write_std_option ( + write__feature_flag_list + ) +) +let string_of__feature_flag_list_option ?(len = 1024) x = + let ob = Buffer.create len in + write__feature_flag_list_option ob x; + Buffer.contents ob +let read__feature_flag_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__feature_flag_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__feature_flag_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 _feature_flag_list_option_of_string s = + read__feature_flag_list_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_scan_info : _ -> scan_info -> _ = ( fun ob (x : scan_info) -> Buffer.add_char ob '{'; @@ -9756,15 +9813,17 @@ let write_scan_info : _ -> scan_info -> _ = ( Yojson.Safe.write_string ) ob x.deployment_name; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"deployment_feature_flags\":"; - ( - write__feature_flag_list - ) - ob x.deployment_feature_flags; + (match x.deployment_feature_flags with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"deployment_feature_flags\":"; + ( + write__feature_flag_list + ) + ob x; + ); Buffer.add_char ob '}'; ) let string_of_scan_info ?(len = 1024) x = @@ -9872,13 +9931,15 @@ let read_scan_info = ( ) ); | 4 -> - field_deployment_feature_flags := ( - Some ( - ( - read__feature_flag_list - ) p lb - ) - ); + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_deployment_feature_flags := ( + Some ( + ( + read__feature_flag_list + ) p lb + ) + ); + ) | _ -> ( Yojson.Safe.skip_json p lb ) @@ -9975,13 +10036,15 @@ let read_scan_info = ( ) ); | 4 -> - field_deployment_feature_flags := ( - Some ( - ( - read__feature_flag_list - ) p lb - ) - ); + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_deployment_feature_flags := ( + Some ( + ( + read__feature_flag_list + ) p lb + ) + ); + ) | _ -> ( Yojson.Safe.skip_json p lb ) @@ -9995,7 +10058,7 @@ let read_scan_info = ( enabled_products = (match !field_enabled_products with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "enabled_products"); deployment_id = (match !field_deployment_id with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_id"); deployment_name = (match !field_deployment_name with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_name"); - deployment_feature_flags = (match !field_deployment_feature_flags with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_feature_flags"); + deployment_feature_flags = !field_deployment_feature_flags; } : scan_info) ) @@ -14734,15 +14797,17 @@ let write_scan_config : _ -> scan_config -> _ = ( Yojson.Safe.write_string ) ob x.deployment_name; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"deployment_feature_flag\":"; - ( - write__feature_flag_list - ) - ob x.deployment_feature_flag; + (match x.deployment_feature_flag with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"deployment_feature_flag\":"; + ( + write__feature_flag_list + ) + ob x; + ); if !is_first then is_first := false else @@ -15045,13 +15110,15 @@ let read_scan_config = ( ) ); | 2 -> - field_deployment_feature_flag := ( - Some ( - ( - read__feature_flag_list - ) p lb - ) - ); + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_deployment_feature_flag := ( + Some ( + ( + read__feature_flag_list + ) p lb + ) + ); + ) | 3 -> field_policy_names := ( Some ( @@ -15323,13 +15390,15 @@ let read_scan_config = ( ) ); | 2 -> - field_deployment_feature_flag := ( - Some ( - ( - read__feature_flag_list - ) p lb - ) - ); + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_deployment_feature_flag := ( + Some ( + ( + read__feature_flag_list + ) p lb + ) + ); + ) | 3 -> field_policy_names := ( Some ( @@ -15433,7 +15502,7 @@ let read_scan_config = ( { deployment_id = (match !field_deployment_id with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_id"); deployment_name = (match !field_deployment_name with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_name"); - deployment_feature_flag = (match !field_deployment_feature_flag with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_feature_flag"); + deployment_feature_flag = !field_deployment_feature_flag; 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; diff --git a/semgrep_output_v1_j.mli b/semgrep_output_v1_j.mli index ee3e3e8d..5aa05b37 100644 --- a/semgrep_output_v1_j.mli +++ b/semgrep_output_v1_j.mli @@ -267,7 +267,7 @@ type scan_info = Semgrep_output_v1_t.scan_info = { enabled_products: product list; deployment_id: int; deployment_name: string; - deployment_feature_flags: feature_flag list + deployment_feature_flags: feature_flag list option } type scan_configuration = Semgrep_output_v1_t.scan_configuration = { @@ -375,7 +375,7 @@ type ci_config_from_cloud = Semgrep_output_v1_t.ci_config_from_cloud = { type scan_config = Semgrep_output_v1_t.scan_config = { deployment_id: int; deployment_name: string; - deployment_feature_flag: feature_flag list; + deployment_feature_flag: feature_flag list option; policy_names: string list; rule_config: string; ci_config_from_cloud: ci_config_from_cloud option; From 0e52fb61302a7612d165d1103a7c7e50c188a329 Mon Sep 17 00:00:00 2001 From: SayyantR Date: Tue, 22 Oct 2024 14:25:17 -0700 Subject: [PATCH 4/4] Switched to using existing features space --- semgrep_output_v1.atd | 10 +- semgrep_output_v1.jsonschema | 26 +- semgrep_output_v1.proto | 13 +- semgrep_output_v1.py | 51 +-- semgrep_output_v1.ts | 37 +- semgrep_output_v1_j.ml | 657 ++++++++++++++--------------------- semgrep_output_v1_j.mli | 37 +- 7 files changed, 307 insertions(+), 524 deletions(-) diff --git a/semgrep_output_v1.atd b/semgrep_output_v1.atd index b6a5f267..5b9a5226 100644 --- a/semgrep_output_v1.atd +++ b/semgrep_output_v1.atd @@ -1218,11 +1218,7 @@ type features = { ~autofix: bool; ~deepsemgrep: bool; ~dependency_query: bool; -} - -type feature_flag = { - name: string; - enabled: bool; + ~path_to_transitivity: bool; } type triage_ignored = { @@ -1298,8 +1294,6 @@ type scan_config = { *) deployment_id: int; deployment_name: string; - (* deployment specific feature flag settings which impact CI behavior *) - ?deployment_feature_flag: feature_flag list option; (* 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) *) @@ -1444,8 +1438,6 @@ type scan_info = { enabled_products: product list; deployment_id: int; deployment_name: string; - (* deployment specific feature flag settings which impact CI behavior *) - ?deployment_feature_flags: feature_flag list option; } diff --git a/semgrep_output_v1.jsonschema b/semgrep_output_v1.jsonschema index 5acec281..355ca226 100644 --- a/semgrep_output_v1.jsonschema +++ b/semgrep_output_v1.jsonschema @@ -948,15 +948,8 @@ "properties": { "autofix": { "type": "boolean" }, "deepsemgrep": { "type": "boolean" }, - "dependency_query": { "type": "boolean" } - } - }, - "feature_flag": { - "type": "object", - "required": [ "name", "enabled" ], - "properties": { - "name": { "type": "string" }, - "enabled": { "type": "boolean" } + "dependency_query": { "type": "boolean" }, + "path_to_transitivity": { "type": "boolean" } } }, "triage_ignored": { @@ -1030,10 +1023,6 @@ "properties": { "deployment_id": { "type": "integer" }, "deployment_name": { "type": "string" }, - "deployment_feature_flag": { - "type": "array", - "items": { "$ref": "#/definitions/feature_flag" } - }, "policy_names": { "type": "array", "items": { "type": "string" } }, "rule_config": { "type": "string" }, "ci_config_from_cloud": { @@ -1042,6 +1031,7 @@ "autofix": { "type": "boolean" }, "deepsemgrep": { "type": "boolean" }, "dependency_query": { "type": "boolean" }, + "path_to_transitivity": { "type": "boolean" }, "triage_ignored_syntactic_ids": { "type": "array", "items": { "type": "string" } @@ -1150,11 +1140,7 @@ "items": { "$ref": "#/definitions/product" } }, "deployment_id": { "type": "integer" }, - "deployment_name": { "type": "string" }, - "deployment_feature_flags": { - "type": "array", - "items": { "$ref": "#/definitions/feature_flag" } - } + "deployment_name": { "type": "string" } } }, "scan_configuration": { @@ -1200,6 +1186,7 @@ "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" @@ -1442,7 +1429,8 @@ "ignored_files": { "type": "array", "items": { "type": "string" } }, "autofix": { "type": "boolean" }, "deepsemgrep": { "type": "boolean" }, - "dependency_query": { "type": "boolean" } + "dependency_query": { "type": "boolean" }, + "path_to_transitivity": { "type": "boolean" } } }, "ci_env": { diff --git a/semgrep_output_v1.proto b/semgrep_output_v1.proto index 32c5052b..4ef46d82 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: fdf2a74174d3ea6059970c5786274ff4e773e4492e5b2d5c89a978399c5afc51 +// Source file sha256 digest: 1dafd6316cd4beb7f32e2081510da5297aebe6a1990dd95e075b59899516a608 syntax = "proto3"; @@ -347,11 +347,7 @@ message Features { bool autofix = 82457874; bool deepsemgrep = 444846865; bool dependency_query = 471197362; -} - -message FeatureFlag { - string name = 3116757; - bool enabled = 476613995; + bool path_to_transitivity = 52910370; } message TriageIgnored { @@ -382,13 +378,13 @@ message CiConfigFromRepo { message ScanConfig { int64 deployment_id = 188822146; string deployment_name = 129624728; - repeated FeatureFlag deployment_feature_flag = 468870978; 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; + bool path_to_transitivity = 52910370; repeated string triage_ignored_syntactic_ids = 211590151; repeated string triage_ignored_match_based_ids = 327942260; repeated string ignored_files = 482076310; @@ -455,7 +451,6 @@ message ScanInfo { repeated google.protobuf.Any enabled_products = 447415338; int64 deployment_id = 188822146; string deployment_name = 129624728; - repeated FeatureFlag deployment_feature_flags = 530134217; } message ScanConfiguration { @@ -473,6 +468,7 @@ 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; @@ -594,6 +590,7 @@ message CiConfig { bool autofix = 82457874; bool deepsemgrep = 444846865; bool dependency_query = 471197362; + bool path_to_transitivity = 52910370; } message Edit { diff --git a/semgrep_output_v1.py b/semgrep_output_v1.py index 201cb6b1..bad51331 100644 --- a/semgrep_output_v1.py +++ b/semgrep_output_v1.py @@ -3039,37 +3039,6 @@ def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class FeatureFlag: - """Original type: feature_flag = { ... }""" - - name: str - enabled: bool - - @classmethod - def from_json(cls, x: Any) -> 'FeatureFlag': - if isinstance(x, dict): - return cls( - name=_atd_read_string(x['name']) if 'name' in x else _atd_missing_json_field('FeatureFlag', 'name'), - enabled=_atd_read_bool(x['enabled']) if 'enabled' in x else _atd_missing_json_field('FeatureFlag', 'enabled'), - ) - else: - _atd_bad_json('FeatureFlag', x) - - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['name'] = _atd_write_string(self.name) - res['enabled'] = _atd_write_bool(self.enabled) - return res - - @classmethod - def from_json_string(cls, x: str) -> 'FeatureFlag': - return cls.from_json(json.loads(x)) - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - @dataclass class ScanInfo: """Original type: scan_info = { ... }""" @@ -3078,7 +3047,6 @@ class ScanInfo: deployment_id: int deployment_name: str id: Optional[int] = None - deployment_feature_flags: Optional[List[FeatureFlag]] = None @classmethod def from_json(cls, x: Any) -> 'ScanInfo': @@ -3088,7 +3056,6 @@ def from_json(cls, x: Any) -> 'ScanInfo': deployment_id=_atd_read_int(x['deployment_id']) if 'deployment_id' in x else _atd_missing_json_field('ScanInfo', 'deployment_id'), deployment_name=_atd_read_string(x['deployment_name']) if 'deployment_name' in x else _atd_missing_json_field('ScanInfo', 'deployment_name'), id=_atd_read_int(x['id']) if 'id' in x else None, - deployment_feature_flags=_atd_read_list(FeatureFlag.from_json)(x['deployment_feature_flags']) if 'deployment_feature_flags' in x else None, ) else: _atd_bad_json('ScanInfo', x) @@ -3100,8 +3067,6 @@ def to_json(self) -> Any: res['deployment_name'] = _atd_write_string(self.deployment_name) if self.id is not None: res['id'] = _atd_write_int(self.id) - if self.deployment_feature_flags is not None: - res['deployment_feature_flags'] = _atd_write_list((lambda x: x.to_json()))(self.deployment_feature_flags) return res @classmethod @@ -3227,6 +3192,7 @@ class EngineConfiguration: autofix: bool = field(default_factory=lambda: False) deepsemgrep: bool = field(default_factory=lambda: False) dependency_query: bool = field(default_factory=lambda: False) + path_to_transitivity: bool = field(default_factory=lambda: False) ignored_files: List[str] = field(default_factory=lambda: []) product_ignored_files: Optional[ProductIgnoredFiles] = None generic_slow_rollout: bool = field(default_factory=lambda: False) @@ -3240,6 +3206,7 @@ def from_json(cls, x: Any) -> 'EngineConfiguration': 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, + path_to_transitivity=_atd_read_bool(x['path_to_transitivity']) if 'path_to_transitivity' in x else False, ignored_files=_atd_read_list(_atd_read_string)(x['ignored_files']) if 'ignored_files' in x else [], product_ignored_files=ProductIgnoredFiles.from_json(x['product_ignored_files']) if 'product_ignored_files' in x else None, generic_slow_rollout=_atd_read_bool(x['generic_slow_rollout']) if 'generic_slow_rollout' in x else False, @@ -3254,6 +3221,7 @@ def to_json(self) -> Any: res['autofix'] = _atd_write_bool(self.autofix) res['deepsemgrep'] = _atd_write_bool(self.deepsemgrep) res['dependency_query'] = _atd_write_bool(self.dependency_query) + res['path_to_transitivity'] = _atd_write_bool(self.path_to_transitivity) res['ignored_files'] = _atd_write_list(_atd_write_string)(self.ignored_files) if self.product_ignored_files is not None: res['product_ignored_files'] = (lambda x: x.to_json())(self.product_ignored_files) @@ -3560,6 +3528,7 @@ class CiConfig: autofix: bool = field(default_factory=lambda: False) deepsemgrep: bool = field(default_factory=lambda: False) dependency_query: bool = field(default_factory=lambda: False) + path_to_transitivity: bool = field(default_factory=lambda: False) @classmethod def from_json(cls, x: Any) -> 'CiConfig': @@ -3571,6 +3540,7 @@ def from_json(cls, x: Any) -> 'CiConfig': 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, + path_to_transitivity=_atd_read_bool(x['path_to_transitivity']) if 'path_to_transitivity' in x else False, ) else: _atd_bad_json('CiConfig', x) @@ -3583,6 +3553,7 @@ def to_json(self) -> Any: res['autofix'] = _atd_write_bool(self.autofix) res['deepsemgrep'] = _atd_write_bool(self.deepsemgrep) res['dependency_query'] = _atd_write_bool(self.dependency_query) + res['path_to_transitivity'] = _atd_write_bool(self.path_to_transitivity) return res @classmethod @@ -3729,11 +3700,11 @@ class ScanConfig: deployment_name: str policy_names: List[str] rule_config: str - deployment_feature_flag: Optional[List[FeatureFlag]] = None 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) + path_to_transitivity: bool = field(default_factory=lambda: False) triage_ignored_syntactic_ids: List[str] = field(default_factory=lambda: []) triage_ignored_match_based_ids: List[str] = field(default_factory=lambda: []) ignored_files: List[str] = field(default_factory=lambda: []) @@ -3748,11 +3719,11 @@ 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'), - deployment_feature_flag=_atd_read_list(FeatureFlag.from_json)(x['deployment_feature_flag']) if 'deployment_feature_flag' in x else None, 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, + path_to_transitivity=_atd_read_bool(x['path_to_transitivity']) if 'path_to_transitivity' in x else False, triage_ignored_syntactic_ids=_atd_read_list(_atd_read_string)(x['triage_ignored_syntactic_ids']) if 'triage_ignored_syntactic_ids' in x else [], triage_ignored_match_based_ids=_atd_read_list(_atd_read_string)(x['triage_ignored_match_based_ids']) if 'triage_ignored_match_based_ids' in x else [], ignored_files=_atd_read_list(_atd_read_string)(x['ignored_files']) if 'ignored_files' in x else [], @@ -3768,13 +3739,12 @@ 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.deployment_feature_flag is not None: - res['deployment_feature_flag'] = _atd_write_list((lambda x: x.to_json()))(self.deployment_feature_flag) 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) + res['path_to_transitivity'] = _atd_write_bool(self.path_to_transitivity) res['triage_ignored_syntactic_ids'] = _atd_write_list(_atd_write_string)(self.triage_ignored_syntactic_ids) res['triage_ignored_match_based_ids'] = _atd_write_list(_atd_write_string)(self.triage_ignored_match_based_ids) res['ignored_files'] = _atd_write_list(_atd_write_string)(self.ignored_files) @@ -7272,6 +7242,7 @@ class Features: autofix: bool = field(default_factory=lambda: False) deepsemgrep: bool = field(default_factory=lambda: False) dependency_query: bool = field(default_factory=lambda: False) + path_to_transitivity: bool = field(default_factory=lambda: False) @classmethod def from_json(cls, x: Any) -> 'Features': @@ -7280,6 +7251,7 @@ def from_json(cls, x: Any) -> 'Features': 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, + path_to_transitivity=_atd_read_bool(x['path_to_transitivity']) if 'path_to_transitivity' in x else False, ) else: _atd_bad_json('Features', x) @@ -7289,6 +7261,7 @@ def to_json(self) -> Any: res['autofix'] = _atd_write_bool(self.autofix) res['deepsemgrep'] = _atd_write_bool(self.deepsemgrep) res['dependency_query'] = _atd_write_bool(self.dependency_query) + res['path_to_transitivity'] = _atd_write_bool(self.path_to_transitivity) return res @classmethod diff --git a/semgrep_output_v1.ts b/semgrep_output_v1.ts index c0625caa..0da31341 100644 --- a/semgrep_output_v1.ts +++ b/semgrep_output_v1.ts @@ -535,11 +535,7 @@ export type Features = { autofix: boolean; deepsemgrep: boolean; dependency_query: boolean; -} - -export type FeatureFlag = { - name: string; - enabled: boolean; + path_to_transitivity: boolean; } export type TriageIgnored = { @@ -577,13 +573,13 @@ export type Tag = string export type ScanConfig = { deployment_id: number /*int*/; deployment_name: string; - deployment_feature_flag?: FeatureFlag[]; policy_names: string[]; rule_config: string; ci_config_from_cloud?: CiConfigFromCloud; autofix: boolean; deepsemgrep: boolean; dependency_query: boolean; + path_to_transitivity: boolean; triage_ignored_syntactic_ids: string[]; triage_ignored_match_based_ids: string[]; ignored_files: string[]; @@ -650,7 +646,6 @@ export type ScanInfo = { enabled_products: Product[]; deployment_id: number /*int*/; deployment_name: string; - deployment_feature_flags?: FeatureFlag[]; } export type ScanConfiguration = { @@ -672,6 +667,7 @@ 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; @@ -797,6 +793,7 @@ export type CiConfig = { autofix: boolean; deepsemgrep: boolean; dependency_query: boolean; + path_to_transitivity: boolean; } export type CiEnv = Map @@ -2604,6 +2601,7 @@ export function writeFeatures(x: Features, context: any = x): any { '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), }; } @@ -2612,20 +2610,7 @@ export function readFeatures(x: any, context: any = x): Features { 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), - }; -} - -export function writeFeatureFlag(x: FeatureFlag, context: any = x): any { - return { - 'name': _atd_write_required_field('FeatureFlag', 'name', _atd_write_string, x.name, x), - 'enabled': _atd_write_required_field('FeatureFlag', 'enabled', _atd_write_bool, x.enabled, x), - }; -} - -export function readFeatureFlag(x: any, context: any = x): FeatureFlag { - return { - name: _atd_read_required_field('FeatureFlag', 'name', _atd_read_string, x['name'], x), - enabled: _atd_read_required_field('FeatureFlag', 'enabled', _atd_read_bool, x['enabled'], x), + path_to_transitivity: _atd_read_field_with_default(_atd_read_bool, false, x['path_to_transitivity'], x), }; } @@ -2729,13 +2714,13 @@ export function writeScanConfig(x: ScanConfig, context: any = x): any { return { 'deployment_id': _atd_write_required_field('ScanConfig', 'deployment_id', _atd_write_int, x.deployment_id, x), 'deployment_name': _atd_write_required_field('ScanConfig', 'deployment_name', _atd_write_string, x.deployment_name, x), - 'deployment_feature_flag': _atd_write_optional_field(_atd_write_array(writeFeatureFlag), x.deployment_feature_flag, 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), + 'path_to_transitivity': _atd_write_field_with_default(_atd_write_bool, false, x.path_to_transitivity, 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), 'ignored_files': _atd_write_field_with_default(_atd_write_array(_atd_write_string), [], x.ignored_files, x), @@ -2748,13 +2733,13 @@ export function readScanConfig(x: any, context: any = x): ScanConfig { return { deployment_id: _atd_read_required_field('ScanConfig', 'deployment_id', _atd_read_int, x['deployment_id'], x), deployment_name: _atd_read_required_field('ScanConfig', 'deployment_name', _atd_read_string, x['deployment_name'], x), - deployment_feature_flag: _atd_read_optional_field(_atd_read_array(readFeatureFlag), x['deployment_feature_flag'], 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), + path_to_transitivity: _atd_read_field_with_default(_atd_read_bool, false, x['path_to_transitivity'], 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), ignored_files: _atd_read_field_with_default(_atd_read_array(_atd_read_string), [], x['ignored_files'], x), @@ -2897,7 +2882,6 @@ export function writeScanInfo(x: ScanInfo, context: any = x): any { '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), - 'deployment_feature_flags': _atd_write_optional_field(_atd_write_array(writeFeatureFlag), x.deployment_feature_flags, x), }; } @@ -2907,7 +2891,6 @@ export function readScanInfo(x: any, context: any = x): ScanInfo { 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), - deployment_feature_flags: _atd_read_optional_field(_atd_read_array(readFeatureFlag), x['deployment_feature_flags'], x), }; } @@ -2962,6 +2945,7 @@ export function writeEngineConfiguration(x: EngineConfiguration, context: any = '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), @@ -2975,6 +2959,7 @@ export function readEngineConfiguration(x: any, context: any = x): EngineConfigu 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), @@ -3273,6 +3258,7 @@ export function writeCiConfig(x: CiConfig, context: any = x): any { '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), }; } @@ -3284,6 +3270,7 @@ export function readCiConfig(x: any, context: any = x): CiConfig { 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), }; } diff --git a/semgrep_output_v1_j.ml b/semgrep_output_v1_j.ml index 67f67366..848e0c82 100644 --- a/semgrep_output_v1_j.ml +++ b/semgrep_output_v1_j.ml @@ -257,17 +257,11 @@ type scanned_and_skipped = Semgrep_output_v1_t.scanned_and_skipped = { type product = Semgrep_output_v1_t.product [@@deriving show, eq] -type feature_flag = Semgrep_output_v1_t.feature_flag = { - name: string; - enabled: bool -} - type scan_info = Semgrep_output_v1_t.scan_info = { id: int option; enabled_products: product list; deployment_id: int; - deployment_name: string; - deployment_feature_flags: feature_flag list option + deployment_name: string } type scan_configuration = Semgrep_output_v1_t.scan_configuration = { @@ -290,6 +284,7 @@ type engine_configuration = Semgrep_output_v1_t.engine_configuration = { autofix: bool; deepsemgrep: bool; dependency_query: bool; + path_to_transitivity: bool; ignored_files: string list; product_ignored_files: product_ignored_files option; generic_slow_rollout: bool; @@ -360,7 +355,8 @@ type ci_config = Semgrep_output_v1_t.ci_config = { ignored_files: string list; autofix: bool; deepsemgrep: bool; - dependency_query: bool + dependency_query: bool; + path_to_transitivity: bool } type action = Semgrep_output_v1_t.action @@ -375,13 +371,13 @@ type ci_config_from_cloud = Semgrep_output_v1_t.ci_config_from_cloud = { type scan_config = Semgrep_output_v1_t.scan_config = { deployment_id: int; deployment_name: string; - deployment_feature_flag: feature_flag list option; policy_names: string list; rule_config: string; ci_config_from_cloud: ci_config_from_cloud option; autofix: bool; deepsemgrep: bool; dependency_query: bool; + path_to_transitivity: bool; triage_ignored_syntactic_ids: string list; triage_ignored_match_based_ids: string list; ignored_files: string list; @@ -717,7 +713,8 @@ type function_call = Semgrep_output_v1_t.function_call type features = Semgrep_output_v1_t.features = { autofix: bool; deepsemgrep: bool; - dependency_query: bool + dependency_query: bool; + path_to_transitivity: bool } type deployment_config = Semgrep_output_v1_t.deployment_config = { @@ -9472,159 +9469,6 @@ let read_product = ( ) let product_of_string s = read_product (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_feature_flag : _ -> feature_flag -> _ = ( - fun ob (x : feature_flag) -> - 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 "\"name\":"; - ( - Yojson.Safe.write_string - ) - ob x.name; - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"enabled\":"; - ( - Yojson.Safe.write_bool - ) - ob x.enabled; - Buffer.add_char ob '}'; -) -let string_of_feature_flag ?(len = 1024) x = - let ob = Buffer.create len in - write_feature_flag ob x; - Buffer.contents ob -let read_feature_flag = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_name = ref (None) in - let field_enabled = 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 = 'n' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( - 0 - ) - else ( - -1 - ) - ) - | 7 -> ( - if String.unsafe_get s pos = 'e' && 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' 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_name := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - | 1 -> - field_enabled := ( - 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 - | 4 -> ( - if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( - 0 - ) - else ( - -1 - ) - ) - | 7 -> ( - if String.unsafe_get s pos = 'e' && 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' 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_name := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - | 1 -> - field_enabled := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - ( - { - name = (match !field_name with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "name"); - enabled = (match !field_enabled with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "enabled"); - } - : feature_flag) - ) -) -let feature_flag_of_string s = - read_feature_flag (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__product_list = ( Atdgen_runtime.Oj_run.write_list ( write_product @@ -9698,79 +9542,6 @@ let read__int_option = ( ) let _int_option_of_string s = read__int_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__feature_flag_list = ( - Atdgen_runtime.Oj_run.write_list ( - write_feature_flag - ) -) -let string_of__feature_flag_list ?(len = 1024) x = - let ob = Buffer.create len in - write__feature_flag_list ob x; - Buffer.contents ob -let read__feature_flag_list = ( - Atdgen_runtime.Oj_run.read_list ( - read_feature_flag - ) -) -let _feature_flag_list_of_string s = - read__feature_flag_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__feature_flag_list_option = ( - Atdgen_runtime.Oj_run.write_std_option ( - write__feature_flag_list - ) -) -let string_of__feature_flag_list_option ?(len = 1024) x = - let ob = Buffer.create len in - write__feature_flag_list_option ob x; - Buffer.contents ob -let read__feature_flag_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__feature_flag_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__feature_flag_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 _feature_flag_list_option_of_string s = - read__feature_flag_list_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_scan_info : _ -> scan_info -> _ = ( fun ob (x : scan_info) -> Buffer.add_char ob '{'; @@ -9813,17 +9584,6 @@ let write_scan_info : _ -> scan_info -> _ = ( Yojson.Safe.write_string ) ob x.deployment_name; - (match x.deployment_feature_flags with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"deployment_feature_flags\":"; - ( - write__feature_flag_list - ) - ob x; - ); Buffer.add_char ob '}'; ) let string_of_scan_info ?(len = 1024) x = @@ -9838,7 +9598,6 @@ let read_scan_info = ( let field_enabled_products = ref (None) in let field_deployment_id = ref (None) in let field_deployment_name = ref (None) in - let field_deployment_feature_flags = ref (None) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; @@ -9880,14 +9639,6 @@ let read_scan_info = ( -1 ) ) - | 24 -> ( - if String.unsafe_get s pos = 'd' && 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) = 'o' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'f' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'u' && String.unsafe_get s (pos+16) = 'r' && String.unsafe_get s (pos+17) = 'e' && String.unsafe_get s (pos+18) = '_' && String.unsafe_get s (pos+19) = 'f' && String.unsafe_get s (pos+20) = 'l' && String.unsafe_get s (pos+21) = 'a' && String.unsafe_get s (pos+22) = 'g' && String.unsafe_get s (pos+23) = 's' then ( - 4 - ) - else ( - -1 - ) - ) | _ -> ( -1 ) @@ -9930,16 +9681,6 @@ let read_scan_info = ( ) p lb ) ); - | 4 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_deployment_feature_flags := ( - Some ( - ( - read__feature_flag_list - ) p lb - ) - ); - ) | _ -> ( Yojson.Safe.skip_json p lb ) @@ -9985,14 +9726,6 @@ let read_scan_info = ( -1 ) ) - | 24 -> ( - if String.unsafe_get s pos = 'd' && 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) = 'o' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'f' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'u' && String.unsafe_get s (pos+16) = 'r' && String.unsafe_get s (pos+17) = 'e' && String.unsafe_get s (pos+18) = '_' && String.unsafe_get s (pos+19) = 'f' && String.unsafe_get s (pos+20) = 'l' && String.unsafe_get s (pos+21) = 'a' && String.unsafe_get s (pos+22) = 'g' && String.unsafe_get s (pos+23) = 's' then ( - 4 - ) - else ( - -1 - ) - ) | _ -> ( -1 ) @@ -10035,16 +9768,6 @@ let read_scan_info = ( ) p lb ) ); - | 4 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_deployment_feature_flags := ( - Some ( - ( - read__feature_flag_list - ) p lb - ) - ); - ) | _ -> ( Yojson.Safe.skip_json p lb ) @@ -10058,7 +9781,6 @@ let read_scan_info = ( enabled_products = (match !field_enabled_products with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "enabled_products"); deployment_id = (match !field_deployment_id with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_id"); deployment_name = (match !field_deployment_name with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_name"); - deployment_feature_flags = !field_deployment_feature_flags; } : scan_info) ) @@ -10677,6 +10399,15 @@ let write_engine_configuration : _ -> engine_configuration -> _ = ( ob x.dependency_query; if !is_first then is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"path_to_transitivity\":"; + ( + Yojson.Safe.write_bool + ) + ob x.path_to_transitivity; + if !is_first then + is_first := false else Buffer.add_char ob ','; Buffer.add_string ob "\"ignored_files\":"; @@ -10737,6 +10468,7 @@ let read_engine_configuration = ( let field_autofix = ref (false) in let field_deepsemgrep = ref (false) in let field_dependency_query = ref (false) in + let field_path_to_transitivity = ref (false) in let field_ignored_files = ref ([]) in let field_product_ignored_files = ref (None) in let field_generic_slow_rollout = ref (false) in @@ -10769,7 +10501,7 @@ let read_engine_configuration = ( ) | 13 -> ( if String.unsafe_get s pos = 'i' && 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 ( - 3 + 4 ) else ( -1 @@ -10785,23 +10517,37 @@ let read_engine_configuration = ( ) | 17 -> ( 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) = 'c' && String.unsafe_get s (pos+12) = 'o' && String.unsafe_get s (pos+13) = 'n' && String.unsafe_get s (pos+14) = 'f' && String.unsafe_get s (pos+15) = 'i' && String.unsafe_get s (pos+16) = 'g' then ( - 6 + 7 ) else ( -1 ) ) | 20 -> ( - if String.unsafe_get s pos = 'g' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'n' && 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) = 'c' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 's' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'w' && String.unsafe_get s (pos+12) = '_' && String.unsafe_get s (pos+13) = 'r' && String.unsafe_get s (pos+14) = 'o' && String.unsafe_get s (pos+15) = 'l' && 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) = 't' then ( - 5 - ) - else ( - -1 - ) + match String.unsafe_get s pos with + | 'g' -> ( + if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'n' && 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) = 'c' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 's' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'w' && String.unsafe_get s (pos+12) = '_' && String.unsafe_get s (pos+13) = 'r' && String.unsafe_get s (pos+14) = 'o' && String.unsafe_get s (pos+15) = 'l' && 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) = 't' then ( + 6 + ) + 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' && 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 ( + 3 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) ) | 21 -> ( 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) = 'd' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'g' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = 'o' && String.unsafe_get s (pos+12) = 'r' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 'd' && String.unsafe_get s (pos+15) = '_' && String.unsafe_get s (pos+16) = 'f' && String.unsafe_get s (pos+17) = 'i' && String.unsafe_get s (pos+18) = 'l' && String.unsafe_get s (pos+19) = 'e' && String.unsafe_get s (pos+20) = 's' then ( - 4 + 5 ) else ( -1 @@ -10809,7 +10555,7 @@ let read_engine_configuration = ( ) | 22 -> ( if String.unsafe_get s pos = 'a' && String.unsafe_get s (pos+1) = 'l' && String.unsafe_get s (pos+2) = 'w' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'y' && String.unsafe_get s (pos+5) = 's' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'u' && String.unsafe_get s (pos+9) = 'p' && String.unsafe_get s (pos+10) = 'p' && String.unsafe_get s (pos+11) = 'r' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 's' && String.unsafe_get s (pos+14) = 's' && String.unsafe_get s (pos+15) = '_' && String.unsafe_get s (pos+16) = 'e' && String.unsafe_get s (pos+17) = 'r' && String.unsafe_get s (pos+18) = 'r' && String.unsafe_get s (pos+19) = 'o' && String.unsafe_get s (pos+20) = 'r' && String.unsafe_get s (pos+21) = 's' then ( - 7 + 8 ) else ( -1 @@ -10848,6 +10594,14 @@ let read_engine_configuration = ( ); ) | 3 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_path_to_transitivity := ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ); + ) + | 4 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_ignored_files := ( ( @@ -10855,7 +10609,7 @@ let read_engine_configuration = ( ) p lb ); ) - | 4 -> + | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_product_ignored_files := ( Some ( @@ -10865,7 +10619,7 @@ let read_engine_configuration = ( ) ); ) - | 5 -> + | 6 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_generic_slow_rollout := ( ( @@ -10873,7 +10627,7 @@ let read_engine_configuration = ( ) p lb ); ) - | 6 -> + | 7 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_historical_config := ( Some ( @@ -10883,7 +10637,7 @@ let read_engine_configuration = ( ) ); ) - | 7 -> + | 8 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_always_suppress_errors := ( ( @@ -10922,7 +10676,7 @@ let read_engine_configuration = ( ) | 13 -> ( if String.unsafe_get s pos = 'i' && 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 ( - 3 + 4 ) else ( -1 @@ -10938,23 +10692,37 @@ let read_engine_configuration = ( ) | 17 -> ( 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) = 'c' && String.unsafe_get s (pos+12) = 'o' && String.unsafe_get s (pos+13) = 'n' && String.unsafe_get s (pos+14) = 'f' && String.unsafe_get s (pos+15) = 'i' && String.unsafe_get s (pos+16) = 'g' then ( - 6 + 7 ) else ( -1 ) ) | 20 -> ( - if String.unsafe_get s pos = 'g' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'n' && 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) = 'c' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 's' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'w' && String.unsafe_get s (pos+12) = '_' && String.unsafe_get s (pos+13) = 'r' && String.unsafe_get s (pos+14) = 'o' && String.unsafe_get s (pos+15) = 'l' && 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) = 't' then ( - 5 - ) - else ( - -1 - ) + match String.unsafe_get s pos with + | 'g' -> ( + if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'n' && 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) = 'c' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 's' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'w' && String.unsafe_get s (pos+12) = '_' && String.unsafe_get s (pos+13) = 'r' && String.unsafe_get s (pos+14) = 'o' && String.unsafe_get s (pos+15) = 'l' && 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) = 't' then ( + 6 + ) + 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' && 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 ( + 3 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) ) | 21 -> ( 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) = 'd' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'g' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = 'o' && String.unsafe_get s (pos+12) = 'r' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 'd' && String.unsafe_get s (pos+15) = '_' && String.unsafe_get s (pos+16) = 'f' && String.unsafe_get s (pos+17) = 'i' && String.unsafe_get s (pos+18) = 'l' && String.unsafe_get s (pos+19) = 'e' && String.unsafe_get s (pos+20) = 's' then ( - 4 + 5 ) else ( -1 @@ -10962,7 +10730,7 @@ let read_engine_configuration = ( ) | 22 -> ( if String.unsafe_get s pos = 'a' && String.unsafe_get s (pos+1) = 'l' && String.unsafe_get s (pos+2) = 'w' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'y' && String.unsafe_get s (pos+5) = 's' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = 'u' && String.unsafe_get s (pos+9) = 'p' && String.unsafe_get s (pos+10) = 'p' && String.unsafe_get s (pos+11) = 'r' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 's' && String.unsafe_get s (pos+14) = 's' && String.unsafe_get s (pos+15) = '_' && String.unsafe_get s (pos+16) = 'e' && String.unsafe_get s (pos+17) = 'r' && String.unsafe_get s (pos+18) = 'r' && String.unsafe_get s (pos+19) = 'o' && String.unsafe_get s (pos+20) = 'r' && String.unsafe_get s (pos+21) = 's' then ( - 7 + 8 ) else ( -1 @@ -11001,6 +10769,14 @@ let read_engine_configuration = ( ); ) | 3 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_path_to_transitivity := ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ); + ) + | 4 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_ignored_files := ( ( @@ -11008,7 +10784,7 @@ let read_engine_configuration = ( ) p lb ); ) - | 4 -> + | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_product_ignored_files := ( Some ( @@ -11018,7 +10794,7 @@ let read_engine_configuration = ( ) ); ) - | 5 -> + | 6 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_generic_slow_rollout := ( ( @@ -11026,7 +10802,7 @@ let read_engine_configuration = ( ) p lb ); ) - | 6 -> + | 7 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_historical_config := ( Some ( @@ -11036,7 +10812,7 @@ let read_engine_configuration = ( ) ); ) - | 7 -> + | 8 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_always_suppress_errors := ( ( @@ -11056,6 +10832,7 @@ let read_engine_configuration = ( autofix = !field_autofix; deepsemgrep = !field_deepsemgrep; dependency_query = !field_dependency_query; + path_to_transitivity = !field_path_to_transitivity; ignored_files = !field_ignored_files; product_ignored_files = !field_product_ignored_files; generic_slow_rollout = !field_generic_slow_rollout; @@ -13811,6 +13588,15 @@ let write_ci_config : _ -> ci_config -> _ = ( Yojson.Safe.write_bool ) ob x.dependency_query; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"path_to_transitivity\":"; + ( + Yojson.Safe.write_bool + ) + ob x.path_to_transitivity; Buffer.add_char ob '}'; ) let string_of_ci_config ?(len = 1024) x = @@ -13827,6 +13613,7 @@ let read_ci_config = ( let field_autofix = ref (false) in let field_deepsemgrep = ref (false) in let field_dependency_query = ref (false) in + let field_path_to_transitivity = ref (false) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; @@ -13890,6 +13677,14 @@ let read_ci_config = ( -1 ) ) + | 20 -> ( + 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' && 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 ( + 6 + ) + else ( + -1 + ) + ) | _ -> ( -1 ) @@ -13946,6 +13741,14 @@ let read_ci_config = ( ) p lb ); ) + | 6 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_path_to_transitivity := ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ); + ) | _ -> ( Yojson.Safe.skip_json p lb ) @@ -14013,6 +13816,14 @@ let read_ci_config = ( -1 ) ) + | 20 -> ( + 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' && 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 ( + 6 + ) + else ( + -1 + ) + ) | _ -> ( -1 ) @@ -14069,6 +13880,14 @@ let read_ci_config = ( ) p lb ); ) + | 6 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_path_to_transitivity := ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ); + ) | _ -> ( Yojson.Safe.skip_json p lb ) @@ -14084,6 +13903,7 @@ let read_ci_config = ( autofix = !field_autofix; deepsemgrep = !field_deepsemgrep; dependency_query = !field_dependency_query; + path_to_transitivity = !field_path_to_transitivity; } : ci_config) ) @@ -14797,17 +14617,6 @@ let write_scan_config : _ -> scan_config -> _ = ( Yojson.Safe.write_string ) ob x.deployment_name; - (match x.deployment_feature_flag with None -> () | Some x -> - if !is_first then - is_first := false - else - Buffer.add_char ob ','; - Buffer.add_string ob "\"deployment_feature_flag\":"; - ( - write__feature_flag_list - ) - ob x; - ); if !is_first then is_first := false else @@ -14866,6 +14675,15 @@ let write_scan_config : _ -> scan_config -> _ = ( ob x.dependency_query; if !is_first then is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"path_to_transitivity\":"; + ( + Yojson.Safe.write_bool + ) + ob x.path_to_transitivity; + if !is_first then + is_first := false else Buffer.add_char ob ','; Buffer.add_string ob "\"triage_ignored_syntactic_ids\":"; @@ -14923,13 +14741,13 @@ let read_scan_config = ( Yojson.Safe.read_lcurl p lb; let field_deployment_id = ref (None) in let field_deployment_name = ref (None) in - let field_deployment_feature_flag = 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 + let field_path_to_transitivity = ref (false) in let field_triage_ignored_syntactic_ids = ref ([]) in let field_triage_ignored_match_based_ids = ref ([]) in let field_ignored_files = ref ([]) in @@ -14957,7 +14775,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 ( - 6 + 5 ) else ( -1 @@ -14975,7 +14793,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 ( - 7 + 6 ) else ( -1 @@ -14983,7 +14801,7 @@ let read_scan_config = ( ) | '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) = 'c' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'f' && String.unsafe_get s (pos+9) = 'i' && String.unsafe_get s (pos+10) = 'g' then ( - 4 + 3 ) else ( -1 @@ -14995,7 +14813,7 @@ let read_scan_config = ( ) | 12 -> ( if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'c' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'm' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 's' then ( - 3 + 2 ) else ( -1 @@ -15035,7 +14853,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 ( - 8 + 7 ) else ( -1 @@ -15054,20 +14872,26 @@ let read_scan_config = ( ) ) | 20 -> ( - if String.unsafe_get s pos = 'c' && 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 ( - 5 - ) - else ( - -1 - ) - ) - | 23 -> ( - if String.unsafe_get s pos = 'd' && 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) = 'o' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'f' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'u' && String.unsafe_get s (pos+16) = 'r' && String.unsafe_get s (pos+17) = 'e' && String.unsafe_get s (pos+18) = '_' && String.unsafe_get s (pos+19) = 'f' && String.unsafe_get s (pos+20) = 'l' && String.unsafe_get s (pos+21) = 'a' && String.unsafe_get s (pos+22) = 'g' then ( - 2 - ) - else ( - -1 - ) + 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 + ) + 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' && 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 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) ) | 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 ( @@ -15110,16 +14934,6 @@ let read_scan_config = ( ) ); | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_deployment_feature_flag := ( - Some ( - ( - read__feature_flag_list - ) p lb - ) - ); - ) - | 3 -> field_policy_names := ( Some ( ( @@ -15127,7 +14941,7 @@ let read_scan_config = ( ) p lb ) ); - | 4 -> + | 3 -> field_rule_config := ( Some ( ( @@ -15135,7 +14949,7 @@ let read_scan_config = ( ) p lb ) ); - | 5 -> + | 4 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_ci_config_from_cloud := ( Some ( @@ -15145,7 +14959,7 @@ let read_scan_config = ( ) ); ) - | 6 -> + | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_autofix := ( ( @@ -15153,7 +14967,7 @@ let read_scan_config = ( ) p lb ); ) - | 7 -> + | 6 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_deepsemgrep := ( ( @@ -15161,7 +14975,7 @@ let read_scan_config = ( ) p lb ); ) - | 8 -> + | 7 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_dependency_query := ( ( @@ -15169,6 +14983,14 @@ let read_scan_config = ( ) p lb ); ) + | 8 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_path_to_transitivity := ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ); + ) | 9 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_triage_ignored_syntactic_ids := ( @@ -15237,7 +15059,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 ( - 6 + 5 ) else ( -1 @@ -15255,7 +15077,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 ( - 7 + 6 ) else ( -1 @@ -15263,7 +15085,7 @@ let read_scan_config = ( ) | '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) = 'c' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'f' && String.unsafe_get s (pos+9) = 'i' && String.unsafe_get s (pos+10) = 'g' then ( - 4 + 3 ) else ( -1 @@ -15275,7 +15097,7 @@ let read_scan_config = ( ) | 12 -> ( if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'c' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'm' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 's' then ( - 3 + 2 ) else ( -1 @@ -15315,7 +15137,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 ( - 8 + 7 ) else ( -1 @@ -15334,20 +15156,26 @@ let read_scan_config = ( ) ) | 20 -> ( - if String.unsafe_get s pos = 'c' && 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 ( - 5 - ) - else ( - -1 - ) - ) - | 23 -> ( - if String.unsafe_get s pos = 'd' && 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) = 'o' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'f' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'u' && String.unsafe_get s (pos+16) = 'r' && String.unsafe_get s (pos+17) = 'e' && String.unsafe_get s (pos+18) = '_' && String.unsafe_get s (pos+19) = 'f' && String.unsafe_get s (pos+20) = 'l' && String.unsafe_get s (pos+21) = 'a' && String.unsafe_get s (pos+22) = 'g' then ( - 2 - ) - else ( - -1 - ) + 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 + ) + 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' && 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 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) ) | 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 ( @@ -15390,16 +15218,6 @@ let read_scan_config = ( ) ); | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_deployment_feature_flag := ( - Some ( - ( - read__feature_flag_list - ) p lb - ) - ); - ) - | 3 -> field_policy_names := ( Some ( ( @@ -15407,7 +15225,7 @@ let read_scan_config = ( ) p lb ) ); - | 4 -> + | 3 -> field_rule_config := ( Some ( ( @@ -15415,7 +15233,7 @@ let read_scan_config = ( ) p lb ) ); - | 5 -> + | 4 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_ci_config_from_cloud := ( Some ( @@ -15425,7 +15243,7 @@ let read_scan_config = ( ) ); ) - | 6 -> + | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_autofix := ( ( @@ -15433,7 +15251,7 @@ let read_scan_config = ( ) p lb ); ) - | 7 -> + | 6 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_deepsemgrep := ( ( @@ -15441,7 +15259,7 @@ let read_scan_config = ( ) p lb ); ) - | 8 -> + | 7 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_dependency_query := ( ( @@ -15449,6 +15267,14 @@ let read_scan_config = ( ) p lb ); ) + | 8 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_path_to_transitivity := ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ); + ) | 9 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_triage_ignored_syntactic_ids := ( @@ -15502,13 +15328,13 @@ let read_scan_config = ( { deployment_id = (match !field_deployment_id with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_id"); deployment_name = (match !field_deployment_name with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "deployment_name"); - deployment_feature_flag = !field_deployment_feature_flag; 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; + path_to_transitivity = !field_path_to_transitivity; triage_ignored_syntactic_ids = !field_triage_ignored_syntactic_ids; triage_ignored_match_based_ids = !field_triage_ignored_match_based_ids; ignored_files = !field_ignored_files; @@ -29138,6 +28964,15 @@ let write_features : _ -> features -> _ = ( Yojson.Safe.write_bool ) ob x.dependency_query; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"path_to_transitivity\":"; + ( + Yojson.Safe.write_bool + ) + ob x.path_to_transitivity; Buffer.add_char ob '}'; ) let string_of_features ?(len = 1024) x = @@ -29151,6 +28986,7 @@ let read_features = ( let field_autofix = ref (false) in let field_deepsemgrep = ref (false) in let field_dependency_query = ref (false) in + let field_path_to_transitivity = ref (false) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; @@ -29184,6 +29020,14 @@ let read_features = ( -1 ) ) + | 20 -> ( + 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' && 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 ( + 3 + ) + else ( + -1 + ) + ) | _ -> ( -1 ) @@ -29216,6 +29060,14 @@ let read_features = ( ) p lb ); ) + | 3 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_path_to_transitivity := ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ); + ) | _ -> ( Yojson.Safe.skip_json p lb ) @@ -29253,6 +29105,14 @@ let read_features = ( -1 ) ) + | 20 -> ( + 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' && 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 ( + 3 + ) + else ( + -1 + ) + ) | _ -> ( -1 ) @@ -29285,6 +29145,14 @@ let read_features = ( ) p lb ); ) + | 3 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_path_to_transitivity := ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ); + ) | _ -> ( Yojson.Safe.skip_json p lb ) @@ -29297,6 +29165,7 @@ let read_features = ( autofix = !field_autofix; deepsemgrep = !field_deepsemgrep; dependency_query = !field_dependency_query; + path_to_transitivity = !field_path_to_transitivity; } : features) ) diff --git a/semgrep_output_v1_j.mli b/semgrep_output_v1_j.mli index 5aa05b37..6f8833e8 100644 --- a/semgrep_output_v1_j.mli +++ b/semgrep_output_v1_j.mli @@ -257,17 +257,11 @@ type scanned_and_skipped = Semgrep_output_v1_t.scanned_and_skipped = { type product = Semgrep_output_v1_t.product [@@deriving show, eq] -type feature_flag = Semgrep_output_v1_t.feature_flag = { - name: string; - enabled: bool -} - type scan_info = Semgrep_output_v1_t.scan_info = { id: int option; enabled_products: product list; deployment_id: int; - deployment_name: string; - deployment_feature_flags: feature_flag list option + deployment_name: string } type scan_configuration = Semgrep_output_v1_t.scan_configuration = { @@ -290,6 +284,7 @@ type engine_configuration = Semgrep_output_v1_t.engine_configuration = { autofix: bool; deepsemgrep: bool; dependency_query: bool; + path_to_transitivity: bool; ignored_files: string list; product_ignored_files: product_ignored_files option; generic_slow_rollout: bool; @@ -360,7 +355,8 @@ type ci_config = Semgrep_output_v1_t.ci_config = { ignored_files: string list; autofix: bool; deepsemgrep: bool; - dependency_query: bool + dependency_query: bool; + path_to_transitivity: bool } type action = Semgrep_output_v1_t.action @@ -375,13 +371,13 @@ type ci_config_from_cloud = Semgrep_output_v1_t.ci_config_from_cloud = { type scan_config = Semgrep_output_v1_t.scan_config = { deployment_id: int; deployment_name: string; - deployment_feature_flag: feature_flag list option; policy_names: string list; rule_config: string; ci_config_from_cloud: ci_config_from_cloud option; autofix: bool; deepsemgrep: bool; dependency_query: bool; + path_to_transitivity: bool; triage_ignored_syntactic_ids: string list; triage_ignored_match_based_ids: string list; ignored_files: string list; @@ -717,7 +713,8 @@ type function_call = Semgrep_output_v1_t.function_call type features = Semgrep_output_v1_t.features = { autofix: bool; deepsemgrep: bool; - dependency_query: bool + dependency_query: bool; + path_to_transitivity: bool } type deployment_config = Semgrep_output_v1_t.deployment_config = { @@ -1833,26 +1830,6 @@ val product_of_string : string -> product (** Deserialize JSON data of type {!type:product}. *) -val write_feature_flag : - Buffer.t -> feature_flag -> unit - (** Output a JSON value of type {!type:feature_flag}. *) - -val string_of_feature_flag : - ?len:int -> feature_flag -> string - (** Serialize a value of type {!type:feature_flag} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_feature_flag : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> feature_flag - (** Input JSON data of type {!type:feature_flag}. *) - -val feature_flag_of_string : - string -> feature_flag - (** Deserialize JSON data of type {!type:feature_flag}. *) - val write_scan_info : Buffer.t -> scan_info -> unit (** Output a JSON value of type {!type:scan_info}. *)