diff --git a/semgrep_output_v1.atd b/semgrep_output_v1.atd index 9101080..d804a2e 100644 --- a/semgrep_output_v1.atd +++ b/semgrep_output_v1.atd @@ -2,7 +2,7 @@ (* Prelude *) (*****************************************************************************) (* Specification of the Semgrep CLI JSON output formats using ATD - * (see https://atd.readthedocs.io/en/latest/ for more information on ATD). + * (see https://atd.readthedocs.io/en/latest/ for information on ATD). * * This file specifies mainly the JSON formats of: * - the output of the 'semgrep scan --json' command @@ -1124,16 +1124,13 @@ type killing_parent = { * types used to communicate with the Semgrep backend and are not meant * to be consumed directly by Semgrep users or tools wrapping Semgrep. * - * The sequence of HTTP requests for 'semgrep ci' is mostly: - * - /api/agent/deployments/current with token - * and response with deployment name in a deployment config - * (TODO? get rid of this one? useful?) + * The sequence of HTTP requests for 'semgrep ci' is: * - /api/cli/scans when starting a scan, with information about the project - * and response with scan_id and scan_config including the rules to use - * - /results to send the findings to the backend + * and response with scan_id and scan_response including the rules to use + * - /api/agent/scans//results to send the findings to the backend * and response with errors and task_id - * - /complete when done, with the exit code and a few more information - * and response with app_block_override and reason + * - /api/agent/scans//complete when done, with the exit code and a + * few more information and response with app_block_override and reason * * alt: we could move all of this in a separate semgrep_posts_v1.atd file * or semgrep_webapp_v1.atd @@ -1143,14 +1140,6 @@ type killing_parent = { (* Features *) (* ----------------------------- *) -(* whether a certain feature is available for a deployment *) -type has_features = { - ~has_autofix : bool; - ~has_deepsemgrep : bool; - ~has_triage_via_comment : bool; - ~has_dependency_query : bool; -} - type features = { ~autofix: bool; ~deepsemgrep: bool; @@ -1192,64 +1181,8 @@ type action = [ ] (* ----------------------------- *) -(* CI configurations *) +(* CI scan response *) (* ----------------------------- *) - -(* Response by the backend to the CLI to the POST deployments/current *) -type deployment_config = { - id : int; - (* the important piece, the deployment name (e.g., "returntocorp" *) - name : string; - ~organization_id : int; - (* All three below seem similar to 'name' mostly (e.g., "returntocorp") *) - ~display_name : string; - ~scm_name : string; - ~slug : string; - (* ex: "github" *) - ~source_type : string; - (* ex: "member" *) - ~default_user_role : string; - (* TODO? factorize in ci_config_from_cloud instead of here and scan_config? *) - inherit has_features; -} - -(* Content of a possible .semgrepconfig.yml in the repository. - * - * This config allows to configure Semgrep per repo, e.g., to store - * a category/tag like "webapp" in a repo so that the Semgrep WebApp can - * return a set of relevant rules automatically for this repo in scan_config - * later when given this ci_config_from_repo in the scan_request. - *) -type ci_config_from_repo = { - (* version of the .semgrepconfig.yml format. "v1" right now (useful?) *) - ~version : version; - ?tags: tag list option; -} -(* ex: "webapp" *) -type tag = string - -(* Response by the backend to the CLI to the POST deployments/scans/config - * DEPRECATED? seems to be used only by semgrep lsp. - *) -type scan_config = { - deployment_id: int; - deployment_name: string; - (* ex: "audit", "comment", "block" TODO use enum? TODO: seems dead *) - policy_names: string list; - (* rules raw content in JSON format (but still sent as a string) *) - rule_config: string; - inherit features; - inherit triage_ignored; - (* glob patterns *) - ~ignored_files: string list; - (* since 1.37.0 *) - ?enabled_products: product list option; - (* since 1.64.0 *) - ~actions: action list; - (* since 1.47.0 but not created by the backend (nor used by the CLI) *) - ?ci_config_from_cloud: ci_config_from_cloud option; - } - (* Response from the backend to the CLI to the POST /api/cli/scans *) type scan_response = { info: scan_info; @@ -1262,16 +1195,15 @@ type scan_response = { type scan_info = { ?id: int option; (* the scan id, null for dry-runs *) enabled_products: product list; - (* redundant with deployment_config? - * TODO? remove the intermediate call to get the deployment and - * start a scan to /api/cli/scans/ without first accessing - * api/agent/deployments/current? + (* Those fields are also in deployment_config but they are also + * here so that 'semgrep ci' does not need an extra HTTP request to the + * deployment endpoint to get this info. *) deployment_id: int; deployment_name: string; } -(* config specific to the scan, eg *) +(* config specific to the scan *) type scan_configuration = { rules: raw_json; (* can we type this better *) inherit triage_ignored; @@ -1308,13 +1240,6 @@ type historical_configuration = { ?lookback_days: int option; } -(* ----------------------------- *) -(* CI Deployment response *) -(* ----------------------------- *) -type deployment_response = { - deployment: deployment_config; -} - (* ----------------------------- *) (* CI Scan request *) (* ----------------------------- *) @@ -1416,6 +1341,21 @@ type scan_metadata = { ?sms_scan_id: string option; } +(* Content of a possible .semgrepconfig.yml in the repository. + * + * This config allows to configure Semgrep per repo, e.g., to store + * a category/tag like "webapp" in a repo so that the Semgrep WebApp can + * return a set of relevant rules automatically for this repo in scan_config + * later when given this ci_config_from_repo in the scan_request. + *) +type ci_config_from_repo = { + (* version of the .semgrepconfig.yml format. "v1" right now (useful?) *) + ~version : version; + ?tags: tag list option; +} +(* ex: "webapp" *) +type tag = string + (* ----------------------------- *) (* Findings *) (* ----------------------------- *) @@ -1729,6 +1669,70 @@ type ci_scan_failure = { stderr: string; } +(* ----------------------------- *) +(* Other comms *) +(* ----------------------------- *) + +(* Response by the backend to the CLI to the POST api/agent/deployments/current + * Some of the information in deployment_config is now returned + * directly in scan_response (e.g., the deployment_name) + * TODO: deprecate this endpoint as it is now used only in 'semgrep login' and + * in 'semgrep show whoami' to just check whether the token is valid. + *) +type deployment_config = { + id : int; + (* the important piece, the deployment name (e.g., "returntocorp" *) + name : string; + ~organization_id : int; + (* All three below seem similar to 'name' mostly (e.g., "returntocorp") *) + ~display_name : string; + ~scm_name : string; + ~slug : string; + (* ex: "github" *) + ~source_type : string; + (* ex: "member" *) + ~default_user_role : string; + inherit has_features; +} + +(* whether a certain feature is available for a deployment *) +type has_features = { + ~has_autofix : bool; + ~has_deepsemgrep : bool; + ~has_triage_via_comment : bool; + ~has_dependency_query : bool; +} + +type deployment_response = { + deployment: deployment_config; +} + +(* Response by the backend to the CLI to the POST deployments/scans/config + * The record is similar to scan_response. + * TODO: deprecate this endpoint/record. Is is used by semgrep lsp and possibly + * semgrep scan --config policy|supply-chain but we should remove + * those --config policy|supply-chain and migrate semgrep lsp to + * /api/cli/scans with dryrun=true + *) +type scan_config = { + deployment_id: int; + deployment_name: string; + (* ex: "audit", "comment", "block" TODO use enum? TODO: seems dead *) + policy_names: string list; + (* rules raw content in JSON format (but still sent as a string) *) + rule_config: string; + inherit features; + inherit triage_ignored; + (* glob patterns *) + ~ignored_files: string list; + (* since 1.37.0 *) + ?enabled_products: product list option; + (* since 1.64.0 *) + ~actions: action list; + (* since 1.47.0 but not created by the backend (nor used by the CLI) *) + ?ci_config_from_cloud: ci_config_from_cloud option; + } + (* ----------------------------- *) (* TODO a better CI config from cloud *) (* ----------------------------- *) diff --git a/semgrep_output_v1.jsonschema b/semgrep_output_v1.jsonschema index ed33034..49f26a1 100644 --- a/semgrep_output_v1.jsonschema +++ b/semgrep_output_v1.jsonschema @@ -836,16 +836,6 @@ "snippet": { "$ref": "#/definitions/snippet" } } }, - "has_features": { - "type": "object", - "required": [], - "properties": { - "has_autofix": { "type": "boolean" }, - "has_deepsemgrep": { "type": "boolean" }, - "has_triage_via_comment": { "type": "boolean" }, - "has_dependency_query": { "type": "boolean" } - } - }, "features": { "type": "object", "required": [], @@ -893,70 +883,6 @@ } ] }, - "deployment_config": { - "type": "object", - "required": [ "id", "name" ], - "properties": { - "id": { "type": "integer" }, - "name": { "type": "string" }, - "organization_id": { "type": "integer" }, - "display_name": { "type": "string" }, - "scm_name": { "type": "string" }, - "slug": { "type": "string" }, - "source_type": { "type": "string" }, - "default_user_role": { "type": "string" }, - "has_autofix": { "type": "boolean" }, - "has_deepsemgrep": { "type": "boolean" }, - "has_triage_via_comment": { "type": "boolean" }, - "has_dependency_query": { "type": "boolean" } - } - }, - "ci_config_from_repo": { - "type": "object", - "required": [], - "properties": { - "version": { "$ref": "#/definitions/version" }, - "tags": { "type": "array", "items": { "$ref": "#/definitions/tag" } } - } - }, - "tag": { "type": "string" }, - "scan_config": { - "type": "object", - "required": [ - "deployment_id", "deployment_name", "policy_names", "rule_config" - ], - "properties": { - "deployment_id": { "type": "integer" }, - "deployment_name": { "type": "string" }, - "policy_names": { "type": "array", "items": { "type": "string" } }, - "rule_config": { "type": "string" }, - "autofix": { "type": "boolean" }, - "deepsemgrep": { "type": "boolean" }, - "dependency_query": { "type": "boolean" }, - "path_to_transitivity": { "type": "boolean" }, - "scan_all_deps_in_diff_scan": { "type": "boolean" }, - "triage_ignored_syntactic_ids": { - "type": "array", - "items": { "type": "string" } - }, - "triage_ignored_match_based_ids": { - "type": "array", - "items": { "type": "string" } - }, - "ignored_files": { "type": "array", "items": { "type": "string" } }, - "enabled_products": { - "type": "array", - "items": { "$ref": "#/definitions/product" } - }, - "actions": { - "type": "array", - "items": { "$ref": "#/definitions/action" } - }, - "ci_config_from_cloud": { - "$ref": "#/definitions/ci_config_from_cloud" - } - } - }, "scan_response": { "type": "object", "required": [ "info", "config", "engine_params" ], @@ -1034,13 +960,6 @@ "lookback_days": { "type": "integer" } } }, - "deployment_response": { - "type": "object", - "required": [ "deployment" ], - "properties": { - "deployment": { "$ref": "#/definitions/deployment_config" } - } - }, "scan_request": { "type": "object", "required": [ "project_metadata", "scan_metadata" ], @@ -1103,6 +1022,15 @@ "sms_scan_id": { "type": "string" } } }, + "ci_config_from_repo": { + "type": "object", + "required": [], + "properties": { + "version": { "$ref": "#/definitions/version" }, + "tags": { "type": "array", "items": { "$ref": "#/definitions/tag" } } + } + }, + "tag": { "type": "string" }, "finding": { "type": "object", "required": [ @@ -1408,6 +1336,78 @@ "stderr": { "type": "string" } } }, + "deployment_config": { + "type": "object", + "required": [ "id", "name" ], + "properties": { + "id": { "type": "integer" }, + "name": { "type": "string" }, + "organization_id": { "type": "integer" }, + "display_name": { "type": "string" }, + "scm_name": { "type": "string" }, + "slug": { "type": "string" }, + "source_type": { "type": "string" }, + "default_user_role": { "type": "string" }, + "has_autofix": { "type": "boolean" }, + "has_deepsemgrep": { "type": "boolean" }, + "has_triage_via_comment": { "type": "boolean" }, + "has_dependency_query": { "type": "boolean" } + } + }, + "has_features": { + "type": "object", + "required": [], + "properties": { + "has_autofix": { "type": "boolean" }, + "has_deepsemgrep": { "type": "boolean" }, + "has_triage_via_comment": { "type": "boolean" }, + "has_dependency_query": { "type": "boolean" } + } + }, + "deployment_response": { + "type": "object", + "required": [ "deployment" ], + "properties": { + "deployment": { "$ref": "#/definitions/deployment_config" } + } + }, + "scan_config": { + "type": "object", + "required": [ + "deployment_id", "deployment_name", "policy_names", "rule_config" + ], + "properties": { + "deployment_id": { "type": "integer" }, + "deployment_name": { "type": "string" }, + "policy_names": { "type": "array", "items": { "type": "string" } }, + "rule_config": { "type": "string" }, + "autofix": { "type": "boolean" }, + "deepsemgrep": { "type": "boolean" }, + "dependency_query": { "type": "boolean" }, + "path_to_transitivity": { "type": "boolean" }, + "scan_all_deps_in_diff_scan": { "type": "boolean" }, + "triage_ignored_syntactic_ids": { + "type": "array", + "items": { "type": "string" } + }, + "triage_ignored_match_based_ids": { + "type": "array", + "items": { "type": "string" } + }, + "ignored_files": { "type": "array", "items": { "type": "string" } }, + "enabled_products": { + "type": "array", + "items": { "$ref": "#/definitions/product" } + }, + "actions": { + "type": "array", + "items": { "$ref": "#/definitions/action" } + }, + "ci_config_from_cloud": { + "$ref": "#/definitions/ci_config_from_cloud" + } + } + }, "ci_config_from_cloud": { "type": "object", "required": [ "repo_config" ], diff --git a/semgrep_output_v1.proto b/semgrep_output_v1.proto index 4b75eb8..a28bd2f 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: 8001990de58c4148e223fc41e9ac343fee04cd84dccdd2786cd9d28cad320fe1 +// Source file sha256 digest: 33230ba7073d518857d03976371d245036c6cdee44238f2224fd57beb5262890 syntax = "proto3"; @@ -284,13 +284,6 @@ message KillingParent { Snippet snippet = 185277154; } -message HasFeatures { - bool has_autofix = 200569152; - bool has_deepsemgrep = 529169105; - bool has_triage_via_comment = 438443412; - bool has_dependency_query = 481855234; -} - message Features { bool autofix = 82457874; bool deepsemgrep = 444846865; @@ -304,44 +297,6 @@ message TriageIgnored { repeated string triage_ignored_match_based_ids = 327942260; } -message DeploymentConfig { - int64 id = 3205; - string name = 3116757; - int64 organization_id = 406301483; - string display_name = 333474672; - string scm_name = 228525604; - string slug = 3184373; - string source_type = 28767383; - string default_user_role = 341961986; - bool has_autofix = 200569152; - bool has_deepsemgrep = 529169105; - bool has_triage_via_comment = 438443412; - bool has_dependency_query = 481855234; -} - -message CiConfigFromRepo { - string version = 508888787; - repeated string tags = 3528071; -} - -message ScanConfig { - int64 deployment_id = 188822146; - string deployment_name = 129624728; - repeated string policy_names = 175625923; - string rule_config = 403140712; - bool autofix = 82457874; - bool deepsemgrep = 444846865; - bool dependency_query = 471197362; - bool path_to_transitivity = 52910370; - bool scan_all_deps_in_diff_scan = 261708029; - repeated string triage_ignored_syntactic_ids = 211590151; - repeated string triage_ignored_match_based_ids = 327942260; - repeated string ignored_files = 482076310; - repeated google.protobuf.Any enabled_products = 447415338; - repeated google.protobuf.Any actions = 91184897; - CiConfigFromCloud ci_config_from_cloud = 120268883; -} - message ScanResponse { ScanInfo info = 3408338; ScanConfiguration config = 364565635; @@ -379,10 +334,6 @@ message HistoricalConfiguration { int64 lookback_days = 382926518; } -message DeploymentResponse { - DeploymentConfig deployment = 498084672; -} - message ScanRequest { ProjectMetadata project_metadata = 24255885; ScanMetadata scan_metadata = 76122041; @@ -426,6 +377,11 @@ message ScanMetadata { string sms_scan_id = 129251445; } +message CiConfigFromRepo { + string version = 508888787; + repeated string tags = 3528071; +} + message Finding { string check_id = 244492357; string path = 3212859; @@ -558,6 +514,50 @@ message CiScanFailure { string stderr = 150887844; } +message DeploymentConfig { + int64 id = 3205; + string name = 3116757; + int64 organization_id = 406301483; + string display_name = 333474672; + string scm_name = 228525604; + string slug = 3184373; + string source_type = 28767383; + string default_user_role = 341961986; + bool has_autofix = 200569152; + bool has_deepsemgrep = 529169105; + bool has_triage_via_comment = 438443412; + bool has_dependency_query = 481855234; +} + +message HasFeatures { + bool has_autofix = 200569152; + bool has_deepsemgrep = 529169105; + bool has_triage_via_comment = 438443412; + bool has_dependency_query = 481855234; +} + +message DeploymentResponse { + DeploymentConfig deployment = 498084672; +} + +message ScanConfig { + int64 deployment_id = 188822146; + string deployment_name = 129624728; + repeated string policy_names = 175625923; + string rule_config = 403140712; + bool autofix = 82457874; + bool deepsemgrep = 444846865; + bool dependency_query = 471197362; + bool path_to_transitivity = 52910370; + bool scan_all_deps_in_diff_scan = 261708029; + repeated string triage_ignored_syntactic_ids = 211590151; + repeated string triage_ignored_match_based_ids = 327942260; + repeated string ignored_files = 482076310; + repeated google.protobuf.Any enabled_products = 447415338; + repeated google.protobuf.Any actions = 91184897; + CiConfigFromCloud ci_config_from_cloud = 120268883; +} + message CiConfigFromCloud { CiConfig repo_config = 403441970; CiConfig org_config = 463285466; diff --git a/semgrep_output_v1.ts b/semgrep_output_v1.ts index f3b8c42..0d6679b 100644 --- a/semgrep_output_v1.ts +++ b/semgrep_output_v1.ts @@ -457,13 +457,6 @@ export type KillingParent = { snippet: Snippet; } -export type HasFeatures = { - has_autofix: boolean; - has_deepsemgrep: boolean; - has_triage_via_comment: boolean; - has_dependency_query: boolean; -} - export type Features = { autofix: boolean; deepsemgrep: boolean; @@ -482,46 +475,6 @@ export type Action = | { kind: 'Delay'; value: number } | { kind: 'Exit'; value: number /*int*/ } -export type DeploymentConfig = { - id: number /*int*/; - name: string; - organization_id: number /*int*/; - display_name: string; - scm_name: string; - slug: string; - source_type: string; - default_user_role: string; - has_autofix: boolean; - has_deepsemgrep: boolean; - has_triage_via_comment: boolean; - has_dependency_query: boolean; -} - -export type CiConfigFromRepo = { - version: Version; - tags?: Tag[]; -} - -export type Tag = string - -export type ScanConfig = { - deployment_id: number /*int*/; - deployment_name: string; - policy_names: string[]; - rule_config: string; - autofix: boolean; - deepsemgrep: boolean; - dependency_query: boolean; - path_to_transitivity: boolean; - scan_all_deps_in_diff_scan: boolean; - triage_ignored_syntactic_ids: string[]; - triage_ignored_match_based_ids: string[]; - ignored_files: string[]; - enabled_products?: Product[]; - actions: Action[]; - ci_config_from_cloud?: CiConfigFromCloud; -} - export type ScanResponse = { info: ScanInfo; config: ScanConfiguration; @@ -561,10 +514,6 @@ export type HistoricalConfiguration = { lookback_days?: number /*int*/; } -export type DeploymentResponse = { - deployment: DeploymentConfig; -} - export type ScanRequest = { project_metadata: ProjectMetadata; scan_metadata: ScanMetadata; @@ -608,6 +557,13 @@ export type ScanMetadata = { sms_scan_id?: string; } +export type CiConfigFromRepo = { + version: Version; + tags?: Tag[]; +} + +export type Tag = string + export type Finding = { check_id: RuleId; path: Fpath; @@ -775,6 +731,50 @@ export type CiScanFailure = { stderr: string; } +export type DeploymentConfig = { + id: number /*int*/; + name: string; + organization_id: number /*int*/; + display_name: string; + scm_name: string; + slug: string; + source_type: string; + default_user_role: string; + has_autofix: boolean; + has_deepsemgrep: boolean; + has_triage_via_comment: boolean; + has_dependency_query: boolean; +} + +export type HasFeatures = { + has_autofix: boolean; + has_deepsemgrep: boolean; + has_triage_via_comment: boolean; + has_dependency_query: boolean; +} + +export type DeploymentResponse = { + deployment: DeploymentConfig; +} + +export type ScanConfig = { + deployment_id: number /*int*/; + deployment_name: string; + policy_names: string[]; + rule_config: string; + autofix: boolean; + deepsemgrep: boolean; + dependency_query: boolean; + path_to_transitivity: boolean; + scan_all_deps_in_diff_scan: boolean; + triage_ignored_syntactic_ids: string[]; + triage_ignored_match_based_ids: string[]; + ignored_files: string[]; + enabled_products?: Product[]; + actions: Action[]; + ci_config_from_cloud?: CiConfigFromCloud; +} + export type CiConfigFromCloud = { repo_config: CiConfig; org_config?: CiConfig; @@ -2510,24 +2510,6 @@ export function readKillingParent(x: any, context: any = x): KillingParent { }; } -export function writeHasFeatures(x: HasFeatures, context: any = x): any { - return { - 'has_autofix': _atd_write_field_with_default(_atd_write_bool, false, x.has_autofix, x), - 'has_deepsemgrep': _atd_write_field_with_default(_atd_write_bool, false, x.has_deepsemgrep, x), - 'has_triage_via_comment': _atd_write_field_with_default(_atd_write_bool, false, x.has_triage_via_comment, x), - 'has_dependency_query': _atd_write_field_with_default(_atd_write_bool, false, x.has_dependency_query, x), - }; -} - -export function readHasFeatures(x: any, context: any = x): HasFeatures { - return { - has_autofix: _atd_read_field_with_default(_atd_read_bool, false, x['has_autofix'], x), - has_deepsemgrep: _atd_read_field_with_default(_atd_read_bool, false, x['has_deepsemgrep'], x), - has_triage_via_comment: _atd_read_field_with_default(_atd_read_bool, false, x['has_triage_via_comment'], x), - has_dependency_query: _atd_read_field_with_default(_atd_read_bool, false, x['has_dependency_query'], x), - }; -} - export function writeFeatures(x: Features, context: any = x): any { return { 'autofix': _atd_write_field_with_default(_atd_write_bool, false, x.autofix, x), @@ -2588,102 +2570,6 @@ export function readAction(x: any, context: any = x): Action { } } -export function writeDeploymentConfig(x: DeploymentConfig, context: any = x): any { - return { - 'id': _atd_write_required_field('DeploymentConfig', 'id', _atd_write_int, x.id, x), - 'name': _atd_write_required_field('DeploymentConfig', 'name', _atd_write_string, x.name, x), - 'organization_id': _atd_write_field_with_default(_atd_write_int, 0, x.organization_id, x), - 'display_name': _atd_write_field_with_default(_atd_write_string, "", x.display_name, x), - 'scm_name': _atd_write_field_with_default(_atd_write_string, "", x.scm_name, x), - 'slug': _atd_write_field_with_default(_atd_write_string, "", x.slug, x), - 'source_type': _atd_write_field_with_default(_atd_write_string, "", x.source_type, x), - 'default_user_role': _atd_write_field_with_default(_atd_write_string, "", x.default_user_role, x), - 'has_autofix': _atd_write_field_with_default(_atd_write_bool, false, x.has_autofix, x), - 'has_deepsemgrep': _atd_write_field_with_default(_atd_write_bool, false, x.has_deepsemgrep, x), - 'has_triage_via_comment': _atd_write_field_with_default(_atd_write_bool, false, x.has_triage_via_comment, x), - 'has_dependency_query': _atd_write_field_with_default(_atd_write_bool, false, x.has_dependency_query, x), - }; -} - -export function readDeploymentConfig(x: any, context: any = x): DeploymentConfig { - return { - id: _atd_read_required_field('DeploymentConfig', 'id', _atd_read_int, x['id'], x), - name: _atd_read_required_field('DeploymentConfig', 'name', _atd_read_string, x['name'], x), - organization_id: _atd_read_field_with_default(_atd_read_int, 0, x['organization_id'], x), - display_name: _atd_read_field_with_default(_atd_read_string, "", x['display_name'], x), - scm_name: _atd_read_field_with_default(_atd_read_string, "", x['scm_name'], x), - slug: _atd_read_field_with_default(_atd_read_string, "", x['slug'], x), - source_type: _atd_read_field_with_default(_atd_read_string, "", x['source_type'], x), - default_user_role: _atd_read_field_with_default(_atd_read_string, "", x['default_user_role'], x), - has_autofix: _atd_read_field_with_default(_atd_read_bool, false, x['has_autofix'], x), - has_deepsemgrep: _atd_read_field_with_default(_atd_read_bool, false, x['has_deepsemgrep'], x), - has_triage_via_comment: _atd_read_field_with_default(_atd_read_bool, false, x['has_triage_via_comment'], x), - has_dependency_query: _atd_read_field_with_default(_atd_read_bool, false, x['has_dependency_query'], x), - }; -} - -export function writeCiConfigFromRepo(x: CiConfigFromRepo, context: any = x): any { - return { - 'version': _atd_write_field_with_default(writeVersion, 'v1', x.version, x), - 'tags': _atd_write_optional_field(_atd_write_array(writeTag), x.tags, x), - }; -} - -export function readCiConfigFromRepo(x: any, context: any = x): CiConfigFromRepo { - return { - version: _atd_read_field_with_default(readVersion, 'v1', x['version'], x), - tags: _atd_read_optional_field(_atd_read_array(readTag), x['tags'], x), - }; -} - -export function writeTag(x: Tag, context: any = x): any { - return _atd_write_string(x, context); -} - -export function readTag(x: any, context: any = x): Tag { - return _atd_read_string(x, context); -} - -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), - '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), - '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), - 'scan_all_deps_in_diff_scan': _atd_write_field_with_default(_atd_write_bool, false, x.scan_all_deps_in_diff_scan, 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), - 'enabled_products': _atd_write_optional_field(_atd_write_array(writeProduct), x.enabled_products, x), - 'actions': _atd_write_field_with_default(_atd_write_array(writeAction), [], x.actions, x), - 'ci_config_from_cloud': _atd_write_optional_field(writeCiConfigFromCloud, x.ci_config_from_cloud, x), - }; -} - -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), - 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), - 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), - scan_all_deps_in_diff_scan: _atd_read_field_with_default(_atd_read_bool, false, x['scan_all_deps_in_diff_scan'], 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), - enabled_products: _atd_read_optional_field(_atd_read_array(readProduct), x['enabled_products'], x), - actions: _atd_read_field_with_default(_atd_read_array(readAction), [], x['actions'], x), - ci_config_from_cloud: _atd_read_optional_field(readCiConfigFromCloud, x['ci_config_from_cloud'], x), - }; -} - export function writeScanResponse(x: ScanResponse, context: any = x): any { return { 'info': _atd_write_required_field('ScanResponse', 'info', writeScanInfo, x.info, x), @@ -2786,18 +2672,6 @@ export function readHistoricalConfiguration(x: any, context: any = x): Historica }; } -export function writeDeploymentResponse(x: DeploymentResponse, context: any = x): any { - return { - 'deployment': _atd_write_required_field('DeploymentResponse', 'deployment', writeDeploymentConfig, x.deployment, x), - }; -} - -export function readDeploymentResponse(x: any, context: any = x): DeploymentResponse { - return { - deployment: _atd_read_required_field('DeploymentResponse', 'deployment', readDeploymentConfig, x['deployment'], x), - }; -} - export function writeScanRequest(x: ScanRequest, context: any = x): any { return { 'project_metadata': _atd_write_required_field('ScanRequest', 'project_metadata', writeProjectMetadata, x.project_metadata, x), @@ -2896,6 +2770,28 @@ export function readScanMetadata(x: any, context: any = x): ScanMetadata { }; } +export function writeCiConfigFromRepo(x: CiConfigFromRepo, context: any = x): any { + return { + 'version': _atd_write_field_with_default(writeVersion, 'v1', x.version, x), + 'tags': _atd_write_optional_field(_atd_write_array(writeTag), x.tags, x), + }; +} + +export function readCiConfigFromRepo(x: any, context: any = x): CiConfigFromRepo { + return { + version: _atd_read_field_with_default(readVersion, 'v1', x['version'], x), + tags: _atd_read_optional_field(_atd_read_array(readTag), x['tags'], x), + }; +} + +export function writeTag(x: Tag, context: any = x): any { + return _atd_write_string(x, context); +} + +export function readTag(x: any, context: any = x): Tag { + return _atd_read_string(x, context); +} + export function writeFinding(x: Finding, context: any = x): any { return { 'check_id': _atd_write_required_field('Finding', 'check_id', writeRuleId, x.check_id, x), @@ -3384,6 +3280,110 @@ export function readCiScanFailure(x: any, context: any = x): CiScanFailure { }; } +export function writeDeploymentConfig(x: DeploymentConfig, context: any = x): any { + return { + 'id': _atd_write_required_field('DeploymentConfig', 'id', _atd_write_int, x.id, x), + 'name': _atd_write_required_field('DeploymentConfig', 'name', _atd_write_string, x.name, x), + 'organization_id': _atd_write_field_with_default(_atd_write_int, 0, x.organization_id, x), + 'display_name': _atd_write_field_with_default(_atd_write_string, "", x.display_name, x), + 'scm_name': _atd_write_field_with_default(_atd_write_string, "", x.scm_name, x), + 'slug': _atd_write_field_with_default(_atd_write_string, "", x.slug, x), + 'source_type': _atd_write_field_with_default(_atd_write_string, "", x.source_type, x), + 'default_user_role': _atd_write_field_with_default(_atd_write_string, "", x.default_user_role, x), + 'has_autofix': _atd_write_field_with_default(_atd_write_bool, false, x.has_autofix, x), + 'has_deepsemgrep': _atd_write_field_with_default(_atd_write_bool, false, x.has_deepsemgrep, x), + 'has_triage_via_comment': _atd_write_field_with_default(_atd_write_bool, false, x.has_triage_via_comment, x), + 'has_dependency_query': _atd_write_field_with_default(_atd_write_bool, false, x.has_dependency_query, x), + }; +} + +export function readDeploymentConfig(x: any, context: any = x): DeploymentConfig { + return { + id: _atd_read_required_field('DeploymentConfig', 'id', _atd_read_int, x['id'], x), + name: _atd_read_required_field('DeploymentConfig', 'name', _atd_read_string, x['name'], x), + organization_id: _atd_read_field_with_default(_atd_read_int, 0, x['organization_id'], x), + display_name: _atd_read_field_with_default(_atd_read_string, "", x['display_name'], x), + scm_name: _atd_read_field_with_default(_atd_read_string, "", x['scm_name'], x), + slug: _atd_read_field_with_default(_atd_read_string, "", x['slug'], x), + source_type: _atd_read_field_with_default(_atd_read_string, "", x['source_type'], x), + default_user_role: _atd_read_field_with_default(_atd_read_string, "", x['default_user_role'], x), + has_autofix: _atd_read_field_with_default(_atd_read_bool, false, x['has_autofix'], x), + has_deepsemgrep: _atd_read_field_with_default(_atd_read_bool, false, x['has_deepsemgrep'], x), + has_triage_via_comment: _atd_read_field_with_default(_atd_read_bool, false, x['has_triage_via_comment'], x), + has_dependency_query: _atd_read_field_with_default(_atd_read_bool, false, x['has_dependency_query'], x), + }; +} + +export function writeHasFeatures(x: HasFeatures, context: any = x): any { + return { + 'has_autofix': _atd_write_field_with_default(_atd_write_bool, false, x.has_autofix, x), + 'has_deepsemgrep': _atd_write_field_with_default(_atd_write_bool, false, x.has_deepsemgrep, x), + 'has_triage_via_comment': _atd_write_field_with_default(_atd_write_bool, false, x.has_triage_via_comment, x), + 'has_dependency_query': _atd_write_field_with_default(_atd_write_bool, false, x.has_dependency_query, x), + }; +} + +export function readHasFeatures(x: any, context: any = x): HasFeatures { + return { + has_autofix: _atd_read_field_with_default(_atd_read_bool, false, x['has_autofix'], x), + has_deepsemgrep: _atd_read_field_with_default(_atd_read_bool, false, x['has_deepsemgrep'], x), + has_triage_via_comment: _atd_read_field_with_default(_atd_read_bool, false, x['has_triage_via_comment'], x), + has_dependency_query: _atd_read_field_with_default(_atd_read_bool, false, x['has_dependency_query'], x), + }; +} + +export function writeDeploymentResponse(x: DeploymentResponse, context: any = x): any { + return { + 'deployment': _atd_write_required_field('DeploymentResponse', 'deployment', writeDeploymentConfig, x.deployment, x), + }; +} + +export function readDeploymentResponse(x: any, context: any = x): DeploymentResponse { + return { + deployment: _atd_read_required_field('DeploymentResponse', 'deployment', readDeploymentConfig, x['deployment'], x), + }; +} + +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), + '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), + '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), + 'scan_all_deps_in_diff_scan': _atd_write_field_with_default(_atd_write_bool, false, x.scan_all_deps_in_diff_scan, 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), + 'enabled_products': _atd_write_optional_field(_atd_write_array(writeProduct), x.enabled_products, x), + 'actions': _atd_write_field_with_default(_atd_write_array(writeAction), [], x.actions, x), + 'ci_config_from_cloud': _atd_write_optional_field(writeCiConfigFromCloud, x.ci_config_from_cloud, x), + }; +} + +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), + 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), + 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), + scan_all_deps_in_diff_scan: _atd_read_field_with_default(_atd_read_bool, false, x['scan_all_deps_in_diff_scan'], 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), + enabled_products: _atd_read_optional_field(_atd_read_array(readProduct), x['enabled_products'], x), + actions: _atd_read_field_with_default(_atd_read_array(readAction), [], x['actions'], x), + ci_config_from_cloud: _atd_read_optional_field(readCiConfigFromCloud, x['ci_config_from_cloud'], x), + }; +} + export function writeCiConfigFromCloud(x: CiConfigFromCloud, context: any = x): any { return { 'repo_config': _atd_write_required_field('CiConfigFromCloud', 'repo_config', writeCiConfig, x.repo_config, x),