Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type for /complete data #96

Merged
merged 6 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions semgrep_output_v1.atd
Original file line number Diff line number Diff line change
Expand Up @@ -801,13 +801,48 @@ type found_dependency <ocaml attr="deriving show"> = {
?line_number: int option;
}


(* json names are to maintain backwards compatibility with the python enum it is replacing *)
mmcqd marked this conversation as resolved.
Show resolved Hide resolved
type sca_parser_name <ocaml attr="deriving show"> = [
| Gemfile_lock <json name="gemfile_lock">
| Go_mod <json name="go_mod">
| Go_sum <json name="go_sum">
| Gradle_lockfile <json name="gradle_lockfile">
| Gradle_build <json name="gradle_build">
| Jsondoc <json name="jsondoc">
| Pipfile <json name="pipfile">
| Pnpm_lock <json name="pnpm_lock">
| Poetry_lock <json name="poetry_lock">
| Pyproject_toml <json name="pyproject_toml">
| Requirements <json name="requirements">
| Yarn_1 <json name="yarn_1">
| Yarn_2 <json name="yarn_2">
| Pomtree <json name="pomtree">
| Cargo_parser <json name="cargo">
| Composer_lock <json name="composer_lock">
]



type dependency_parser_error <ocaml attr="deriving show"> = {
path: string;
parser: sca_parser_name;
reason: string;
(* Not using `position` because this type must be backwards compatible with the python class it is replacing *)
mmcqd marked this conversation as resolved.
Show resolved Hide resolved
?line: int option;
?col: int option;
?text: string option;
}


(*****************************************************************************)
(* Semgrep CLI findings output for the App *)
(*****************************************************************************)
(* TODO: see semgrep/app/scans.py
* there is also api_scans_meta, api_scans_ignores, and api_scans_complete
* EXPERIMENTAL
*)

type ci_scan_results <ocaml attr="deriving show"> = {
(* TODO: ?version: version option; *)
findings: finding list;
Expand All @@ -820,6 +855,47 @@ type ci_scan_results <ocaml attr="deriving show"> = {



type parsing_stats <ocaml attr="deriving show"> = {
mmcqd marked this conversation as resolved.
Show resolved Hide resolved
targets_parsed: int;
num_targets: int;
bytes_parsed: int;
num_bytes: int;
}

type ci_scan_complete_stats <ocaml attr="deriving show"> = {
findings: int;
errors: cli_error list;
total_time: float;
unsupported_exts: (string * int) list
<json repr="object">
<python repr="dict">
<ts repr="map">;
lockfile_scan_info: (string * int) list
<json repr="object">
<python repr="dict">
<ts repr="map">;
parse_rate: (string * parsing_stats) list
<json repr="object">
<python repr="dict">
<ts repr="map">;
(* This is EngineType from python, which is different from engine_kind used in this file *)
?engine_requested: string option;
}

type ci_scan_dependencies <ocaml attr="deriving show"> = (string * found_dependency list) list
<json repr="object">
<python repr="dict">
<ts repr="map">

type ci_scan_complete_response <ocaml attr="deriving show"> = {
exit_code: int;
stats: ci_scan_complete_stats;
?dependencies: ci_scan_dependencies option;
?dependency_parser_errors: dependency_parser_error list option;
?task_id: string option;
}


type finding_hashes <ocaml attr="deriving show"> = {
start_line_hash: string;
end_line_hash: string;
Expand Down
93 changes: 93 additions & 0 deletions semgrep_output_v1.jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,38 @@
"line_number": { "type": "integer" }
}
},
"sca_parser_name": {
"oneOf": [
{ "const": "gemfile_lock" },
{ "const": "go_mod" },
{ "const": "go_sum" },
{ "const": "gradle_lockfile" },
{ "const": "gradle_build" },
{ "const": "jsondoc" },
{ "const": "pipfile" },
{ "const": "pnpm_lock" },
{ "const": "poetry_lock" },
{ "const": "pyproject_toml" },
{ "const": "requirements" },
{ "const": "yarn_1" },
{ "const": "yarn_2" },
{ "const": "pomtree" },
{ "const": "cargo" },
{ "const": "composer_lock" }
]
},
"dependency_parser_error": {
"type": "object",
"required": [ "path", "parser", "reason" ],
"properties": {
"path": { "type": "string" },
"parser": { "$ref": "#/definitions/sca_parser_name" },
"reason": { "type": "string" },
"line": { "type": "integer" },
"col": { "type": "integer" },
"text": { "type": "string" }
}
},
"ci_scan_results": {
"type": "object",
"required": [
Expand All @@ -721,6 +753,67 @@
"rule_ids": { "type": "array", "items": { "type": "string" } }
}
},
"parsing_stats": {
"type": "object",
"required": [
"targets_parsed", "num_targets", "bytes_parsed", "num_bytes"
],
"properties": {
"targets_parsed": { "type": "integer" },
"num_targets": { "type": "integer" },
"bytes_parsed": { "type": "integer" },
"num_bytes": { "type": "integer" }
}
},
"ci_scan_complete_stats": {
"type": "object",
"required": [
"findings", "errors", "total_time", "unsupported_exts",
"lockfile_scan_info", "parse_rate"
],
"properties": {
"findings": { "type": "integer" },
"errors": {
"type": "array",
"items": { "$ref": "#/definitions/cli_error" }
},
"total_time": { "type": "number" },
"unsupported_exts": {
"type": "object",
"additionalProperties": { "type": "integer" }
},
"lockfile_scan_info": {
"type": "object",
"additionalProperties": { "type": "integer" }
},
"parse_rate": {
"type": "object",
"additionalProperties": { "$ref": "#/definitions/parsing_stats" }
},
"engine_requested": { "type": "string" }
}
},
"ci_scan_dependencies": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": { "$ref": "#/definitions/found_dependency" }
}
},
"ci_scan_complete_response": {
"type": "object",
"required": [ "exit_code", "stats" ],
"properties": {
"exit_code": { "type": "integer" },
"stats": { "$ref": "#/definitions/ci_scan_complete_stats" },
"dependencies": { "$ref": "#/definitions/ci_scan_dependencies" },
"dependency_parser_errors": {
"type": "array",
"items": { "$ref": "#/definitions/dependency_parser_error" }
},
"task_id": { "type": "string" }
}
},
"finding_hashes": {
"type": "object",
"required": [
Expand Down
Loading