diff --git a/scripts/check-backwards-compatibility b/scripts/check-backwards-compatibility index 6d2e1ae..37bd743 100755 --- a/scripts/check-backwards-compatibility +++ b/scripts/check-backwards-compatibility @@ -34,10 +34,20 @@ for tag in $tags; do set +e # do our own error handling for a bit echo "Checking backward compatibility of semgrep_output_v1.atd against past version $tag" + + # We don't check for incompatibilities in the pysemgrep/semgrep-core + # interface because these two programs are always distributed together, + # allowing their interface to change freely. + # + # TODO: add the option '--ignore core_output,targets' so as to produce + # an error if we fail to update the '--types' option when adding + # future new type definitions. This requires atddiff > 2.15. + atddiff_options="--no-locations --backward --types ci_scan_complete_response,ci_scan_results_response,deployment_response,diff_files,function_call,function_return,partial_scan_result,scan_config,scan_request,scan_response,tests_result" + # I'm getting an exit code 128 when atddiff returns 3 (as of git 2.43.0), # contrary to what 'git difftool --help' promises for '--trust-exit-code'. # I'd report the bug if it was easier. -- Martin - git difftool --trust-exit-code -x 'atddiff --no-locations --backward' -y \ + git difftool --trust-exit-code -x "atddiff $atddiff_options" -y \ "$tag" "origin/main" -- semgrep_output_v1.atd > before.txt ret=$? if [ "$ret" -ge 1 ] && [ "$ret" -le 2 ]; then @@ -45,7 +55,7 @@ for tag in $tags; do cat before.txt exit 1 fi - git difftool --trust-exit-code -x 'atddiff --no-locations --backward' -y \ + git difftool --trust-exit-code -x "atddiff $atddiff_options" -y \ "$tag" "HEAD" -- semgrep_output_v1.atd > after.txt ret=$? if [ "$ret" -ge 1 ] && [ "$ret" -le 2 ]; then diff --git a/semgrep_output_v1.atd b/semgrep_output_v1.atd index d804a2e..e256e71 100644 --- a/semgrep_output_v1.atd +++ b/semgrep_output_v1.atd @@ -1864,8 +1864,45 @@ type core_error = { those different files (because ATD does not have a proper module system yet). *) -type analyzer = - string wrap +(* See Scan_CLI.ml on how to convert command-line options to this *) +type project_root = [ + (* path *) + | Filesystem of string + (* URL *) + | Git_remote of string +] + +(* + This type is similar to the type Find_targets.conf used by osemgrep. + + We could share the type but it would be slightly more complicated. + This solution will be easier to undo when we're fully migrated to osemgrep. + + It encodes options derived from the pysemgrep command line. + Upon receiving this record, semgrep-core will discover the target + files like osemgrep does. + + - See Find_targets.mli for the meaning of each field. + - See Scan_CLI.ml for the mapping between semgrep CLI and this type. +*) +type targeting_conf = { + exclude : string list; + ?include_ : string list option; + max_target_bytes : int; + respect_gitignore : bool; + respect_semgrepignore_files : bool; + always_select_explicit_targets : bool; + (* This is a hash table in Find_targets.conf: *) + explicit_targets : string list; + (* osemgrep-only: option (see Git_project.ml and the force_root parameter) *) + ?force_project_root : project_root option; + force_novcs_project : bool; + exclude_minified_files : bool; + ?baseline_commit : string option; + diff_depth : int; +} + +type analyzer = string wrap (* A target can either be a traditional code target (now with optional associated lockfile) or it can be a lockfile target, which will be used to @@ -1895,6 +1932,11 @@ type code_target = { ?lockfile_target: lockfile option; } +type scanning_roots = { + root_paths: fpath list; + targeting_conf: targeting_conf; +} + (* The same path can be present multiple times in targets below, with * different languages each time, so a Python file can be both analyzed * with Python rules, but also with generic/regexp rules. @@ -1904,7 +1946,12 @@ type code_target = { * you could have at most one PL language, and then possibly * "generic" and "regexp". *) -type targets = target list +type targets = [ + (* list of paths used to discover targets *) + | Scanning_roots of scanning_roots + (* targets already discovered from the scanning roots by pysemgrep *) + | Targets of target list +] (*****************************************************************************) (* Python -> OCaml RPC typedefs *) diff --git a/semgrep_output_v1.jsonschema b/semgrep_output_v1.jsonschema index 49f26a1..27abf93 100644 --- a/semgrep_output_v1.jsonschema +++ b/semgrep_output_v1.jsonschema @@ -1528,6 +1528,48 @@ "rule_id": { "$ref": "#/definitions/rule_id" } } }, + "project_root": { + "oneOf": [ + { + "type": "array", + "minItems": 2, + "items": false, + "prefixItems": [ { "const": "Filesystem" }, { "type": "string" } ] + }, + { + "type": "array", + "minItems": 2, + "items": false, + "prefixItems": [ { "const": "Git_remote" }, { "type": "string" } ] + } + ] + }, + "targeting_conf": { + "type": "object", + "required": [ + "exclude", "max_target_bytes", "respect_gitignore", + "respect_semgrepignore_files", "always_select_explicit_targets", + "explicit_targets", "force_novcs_project", "exclude_minified_files", + "diff_depth" + ], + "properties": { + "exclude": { "type": "array", "items": { "type": "string" } }, + "include_": { "type": "array", "items": { "type": "string" } }, + "max_target_bytes": { "type": "integer" }, + "respect_gitignore": { "type": "boolean" }, + "respect_semgrepignore_files": { "type": "boolean" }, + "always_select_explicit_targets": { "type": "boolean" }, + "explicit_targets": { + "type": "array", + "items": { "type": "string" } + }, + "force_project_root": { "$ref": "#/definitions/project_root" }, + "force_novcs_project": { "type": "boolean" }, + "exclude_minified_files": { "type": "boolean" }, + "baseline_commit": { "type": "string" }, + "diff_depth": { "type": "integer" } + } + }, "analyzer": { "type": "string" }, "target": { "oneOf": [ @@ -1564,9 +1606,38 @@ "lockfile_target": { "$ref": "#/definitions/lockfile" } } }, + "scanning_roots": { + "type": "object", + "required": [ "root_paths", "targeting_conf" ], + "properties": { + "root_paths": { + "type": "array", + "items": { "$ref": "#/definitions/fpath" } + }, + "targeting_conf": { "$ref": "#/definitions/targeting_conf" } + } + }, "targets": { - "type": "array", - "items": { "$ref": "#/definitions/target" } + "oneOf": [ + { + "type": "array", + "minItems": 2, + "items": false, + "prefixItems": [ + { "const": "Scanning_roots" }, + { "$ref": "#/definitions/scanning_roots" } + ] + }, + { + "type": "array", + "minItems": 2, + "items": false, + "prefixItems": [ + { "const": "Targets" }, + { "type": "array", "items": { "$ref": "#/definitions/target" } } + ] + } + ] }, "edit": { "type": "object", diff --git a/semgrep_output_v1.proto b/semgrep_output_v1.proto index a28bd2f..36e46b1 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: 33230ba7073d518857d03976371d245036c6cdee44238f2224fd57beb5262890 +// Source file sha256 digest: 843cf36ed4bd495e15cf40012842bc278898ed90d51018dadebf6af35b23805c syntax = "proto3"; @@ -621,6 +621,21 @@ message CoreError { string rule_id = 42354089; } +message TargetingConf { + repeated string exclude = 270358534; + repeated string include_ = 481104025; + int64 max_target_bytes = 12818053; + bool respect_gitignore = 205345800; + bool respect_semgrepignore_files = 303139013; + bool always_select_explicit_targets = 233062798; + repeated string explicit_targets = 10319231; + google.protobuf.Any force_project_root = 386274895; + bool force_novcs_project = 448272511; + bool exclude_minified_files = 350140015; + string baseline_commit = 447341693; + int64 diff_depth = 244421090; +} + message CodeTarget { string path = 3212859; string analyzer = 405167385; @@ -628,6 +643,11 @@ message CodeTarget { Lockfile lockfile_target = 293108416; } +message ScanningRoots { + repeated string root_paths = 452502085; + TargetingConf targeting_conf = 159796868; +} + message Edit { string path = 3212859; int64 start_offset = 402579410; diff --git a/semgrep_output_v1.py b/semgrep_output_v1.py index d50f5cf..9d2f444 100644 --- a/semgrep_output_v1.py +++ b/semgrep_output_v1.py @@ -2935,6 +2935,139 @@ def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) +@dataclass +class Filesystem: + """Original type: project_root = [ ... | Filesystem of ... | ... ]""" + + value: str + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'Filesystem' + + def to_json(self) -> Any: + return ['Filesystem', _atd_write_string(self.value)] + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass +class GitRemote: + """Original type: project_root = [ ... | Git_remote of ... | ... ]""" + + value: str + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'GitRemote' + + def to_json(self) -> Any: + return ['Git_remote', _atd_write_string(self.value)] + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass +class ProjectRoot: + """Original type: project_root = [ ... ]""" + + value: Union[Filesystem, GitRemote] + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return self.value.kind + + @classmethod + def from_json(cls, x: Any) -> 'ProjectRoot': + if isinstance(x, List) and len(x) == 2: + cons = x[0] + if cons == 'Filesystem': + return cls(Filesystem(_atd_read_string(x[1]))) + if cons == 'Git_remote': + return cls(GitRemote(_atd_read_string(x[1]))) + _atd_bad_json('ProjectRoot', x) + _atd_bad_json('ProjectRoot', x) + + def to_json(self) -> Any: + return self.value.to_json() + + @classmethod + def from_json_string(cls, x: str) -> 'ProjectRoot': + return cls.from_json(json.loads(x)) + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass +class TargetingConf: + """Original type: targeting_conf = { ... }""" + + exclude: List[str] + max_target_bytes: int + respect_gitignore: bool + respect_semgrepignore_files: bool + always_select_explicit_targets: bool + explicit_targets: List[str] + force_novcs_project: bool + exclude_minified_files: bool + diff_depth: int + include_: Optional[List[str]] = None + force_project_root: Optional[ProjectRoot] = None + baseline_commit: Optional[str] = None + + @classmethod + def from_json(cls, x: Any) -> 'TargetingConf': + if isinstance(x, dict): + return cls( + exclude=_atd_read_list(_atd_read_string)(x['exclude']) if 'exclude' in x else _atd_missing_json_field('TargetingConf', 'exclude'), + max_target_bytes=_atd_read_int(x['max_target_bytes']) if 'max_target_bytes' in x else _atd_missing_json_field('TargetingConf', 'max_target_bytes'), + respect_gitignore=_atd_read_bool(x['respect_gitignore']) if 'respect_gitignore' in x else _atd_missing_json_field('TargetingConf', 'respect_gitignore'), + respect_semgrepignore_files=_atd_read_bool(x['respect_semgrepignore_files']) if 'respect_semgrepignore_files' in x else _atd_missing_json_field('TargetingConf', 'respect_semgrepignore_files'), + always_select_explicit_targets=_atd_read_bool(x['always_select_explicit_targets']) if 'always_select_explicit_targets' in x else _atd_missing_json_field('TargetingConf', 'always_select_explicit_targets'), + explicit_targets=_atd_read_list(_atd_read_string)(x['explicit_targets']) if 'explicit_targets' in x else _atd_missing_json_field('TargetingConf', 'explicit_targets'), + force_novcs_project=_atd_read_bool(x['force_novcs_project']) if 'force_novcs_project' in x else _atd_missing_json_field('TargetingConf', 'force_novcs_project'), + exclude_minified_files=_atd_read_bool(x['exclude_minified_files']) if 'exclude_minified_files' in x else _atd_missing_json_field('TargetingConf', 'exclude_minified_files'), + diff_depth=_atd_read_int(x['diff_depth']) if 'diff_depth' in x else _atd_missing_json_field('TargetingConf', 'diff_depth'), + include_=_atd_read_list(_atd_read_string)(x['include_']) if 'include_' in x else None, + force_project_root=ProjectRoot.from_json(x['force_project_root']) if 'force_project_root' in x else None, + baseline_commit=_atd_read_string(x['baseline_commit']) if 'baseline_commit' in x else None, + ) + else: + _atd_bad_json('TargetingConf', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['exclude'] = _atd_write_list(_atd_write_string)(self.exclude) + res['max_target_bytes'] = _atd_write_int(self.max_target_bytes) + res['respect_gitignore'] = _atd_write_bool(self.respect_gitignore) + res['respect_semgrepignore_files'] = _atd_write_bool(self.respect_semgrepignore_files) + res['always_select_explicit_targets'] = _atd_write_bool(self.always_select_explicit_targets) + res['explicit_targets'] = _atd_write_list(_atd_write_string)(self.explicit_targets) + res['force_novcs_project'] = _atd_write_bool(self.force_novcs_project) + res['exclude_minified_files'] = _atd_write_bool(self.exclude_minified_files) + res['diff_depth'] = _atd_write_int(self.diff_depth) + if self.include_ is not None: + res['include_'] = _atd_write_list(_atd_write_string)(self.include_) + if self.force_project_root is not None: + res['force_project_root'] = (lambda x: x.to_json())(self.force_project_root) + if self.baseline_commit is not None: + res['baseline_commit'] = _atd_write_string(self.baseline_commit) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'TargetingConf': + return cls.from_json(json.loads(x)) + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + @dataclass(frozen=True) class SAST: """Original type: product = [ ... | SAST | ... ]""" @@ -3569,17 +3702,96 @@ def to_json_string(self, **kw: Any) -> str: @dataclass -class Targets: - """Original type: targets""" +class ScanningRoots: + """Original type: scanning_roots = { ... }""" + + root_paths: List[Fpath] + targeting_conf: TargetingConf + + @classmethod + def from_json(cls, x: Any) -> 'ScanningRoots': + if isinstance(x, dict): + return cls( + root_paths=_atd_read_list(Fpath.from_json)(x['root_paths']) if 'root_paths' in x else _atd_missing_json_field('ScanningRoots', 'root_paths'), + targeting_conf=TargetingConf.from_json(x['targeting_conf']) if 'targeting_conf' in x else _atd_missing_json_field('ScanningRoots', 'targeting_conf'), + ) + else: + _atd_bad_json('ScanningRoots', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['root_paths'] = _atd_write_list((lambda x: x.to_json()))(self.root_paths) + res['targeting_conf'] = (lambda x: x.to_json())(self.targeting_conf) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'ScanningRoots': + return cls.from_json(json.loads(x)) + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass +class ScanningRoots_: + """Original type: targets = [ ... | Scanning_roots of ... | ... ]""" + + value: ScanningRoots + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'ScanningRoots_' + + def to_json(self) -> Any: + return ['Scanning_roots', (lambda x: x.to_json())(self.value)] + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass +class Targets_: + """Original type: targets = [ ... | Targets of ... | ... ]""" value: List[Target] + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'Targets_' + + def to_json(self) -> Any: + return ['Targets', _atd_write_list((lambda x: x.to_json()))(self.value)] + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass +class Targets: + """Original type: targets = [ ... ]""" + + value: Union[ScanningRoots_, Targets_] + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return self.value.kind + @classmethod def from_json(cls, x: Any) -> 'Targets': - return cls(_atd_read_list(Target.from_json)(x)) + if isinstance(x, List) and len(x) == 2: + cons = x[0] + if cons == 'Scanning_roots': + return cls(ScanningRoots_(ScanningRoots.from_json(x[1]))) + if cons == 'Targets': + return cls(Targets_(_atd_read_list(Target.from_json)(x[1]))) + _atd_bad_json('Targets', x) + _atd_bad_json('Targets', x) def to_json(self) -> Any: - return _atd_write_list((lambda x: x.to_json()))(self.value) + return self.value.to_json() @classmethod def from_json_string(cls, x: str) -> 'Targets': diff --git a/semgrep_output_v1.ts b/semgrep_output_v1.ts index 0d6679b..bb8d714 100644 --- a/semgrep_output_v1.ts +++ b/semgrep_output_v1.ts @@ -840,6 +840,25 @@ export type CoreError = { rule_id?: RuleId; } +export type ProjectRoot = +| { kind: 'Filesystem'; value: string } +| { kind: 'Git_remote'; value: string } + +export type TargetingConf = { + exclude: string[]; + include_?: string[]; + max_target_bytes: number /*int*/; + respect_gitignore: boolean; + respect_semgrepignore_files: boolean; + always_select_explicit_targets: boolean; + explicit_targets: string[]; + force_project_root?: ProjectRoot; + force_novcs_project: boolean; + exclude_minified_files: boolean; + baseline_commit?: string; + diff_depth: number /*int*/; +} + export type Analyzer = string export type Target = @@ -853,7 +872,14 @@ export type CodeTarget = { lockfile_target?: Lockfile; } -export type Targets = Target[] +export type ScanningRoots = { + root_paths: Fpath[]; + targeting_conf: TargetingConf; +} + +export type Targets = +| { kind: 'Scanning_roots'; value: ScanningRoots } +| { kind: 'Targets'; value: Target[] } export type Edit = { path: Fpath; @@ -3542,6 +3568,62 @@ export function readCoreError(x: any, context: any = x): CoreError { }; } +export function writeProjectRoot(x: ProjectRoot, context: any = x): any { + switch (x.kind) { + case 'Filesystem': + return ['Filesystem', _atd_write_string(x.value, x)] + case 'Git_remote': + return ['Git_remote', _atd_write_string(x.value, x)] + } +} + +export function readProjectRoot(x: any, context: any = x): ProjectRoot { + _atd_check_json_tuple(2, x, context) + switch (x[0]) { + case 'Filesystem': + return { kind: 'Filesystem', value: _atd_read_string(x[1], x) } + case 'Git_remote': + return { kind: 'Git_remote', value: _atd_read_string(x[1], x) } + default: + _atd_bad_json('ProjectRoot', x, context) + throw new Error('impossible') + } +} + +export function writeTargetingConf(x: TargetingConf, context: any = x): any { + return { + 'exclude': _atd_write_required_field('TargetingConf', 'exclude', _atd_write_array(_atd_write_string), x.exclude, x), + 'include_': _atd_write_optional_field(_atd_write_array(_atd_write_string), x.include_, x), + 'max_target_bytes': _atd_write_required_field('TargetingConf', 'max_target_bytes', _atd_write_int, x.max_target_bytes, x), + 'respect_gitignore': _atd_write_required_field('TargetingConf', 'respect_gitignore', _atd_write_bool, x.respect_gitignore, x), + 'respect_semgrepignore_files': _atd_write_required_field('TargetingConf', 'respect_semgrepignore_files', _atd_write_bool, x.respect_semgrepignore_files, x), + 'always_select_explicit_targets': _atd_write_required_field('TargetingConf', 'always_select_explicit_targets', _atd_write_bool, x.always_select_explicit_targets, x), + 'explicit_targets': _atd_write_required_field('TargetingConf', 'explicit_targets', _atd_write_array(_atd_write_string), x.explicit_targets, x), + 'force_project_root': _atd_write_optional_field(writeProjectRoot, x.force_project_root, x), + 'force_novcs_project': _atd_write_required_field('TargetingConf', 'force_novcs_project', _atd_write_bool, x.force_novcs_project, x), + 'exclude_minified_files': _atd_write_required_field('TargetingConf', 'exclude_minified_files', _atd_write_bool, x.exclude_minified_files, x), + 'baseline_commit': _atd_write_optional_field(_atd_write_string, x.baseline_commit, x), + 'diff_depth': _atd_write_required_field('TargetingConf', 'diff_depth', _atd_write_int, x.diff_depth, x), + }; +} + +export function readTargetingConf(x: any, context: any = x): TargetingConf { + return { + exclude: _atd_read_required_field('TargetingConf', 'exclude', _atd_read_array(_atd_read_string), x['exclude'], x), + include_: _atd_read_optional_field(_atd_read_array(_atd_read_string), x['include_'], x), + max_target_bytes: _atd_read_required_field('TargetingConf', 'max_target_bytes', _atd_read_int, x['max_target_bytes'], x), + respect_gitignore: _atd_read_required_field('TargetingConf', 'respect_gitignore', _atd_read_bool, x['respect_gitignore'], x), + respect_semgrepignore_files: _atd_read_required_field('TargetingConf', 'respect_semgrepignore_files', _atd_read_bool, x['respect_semgrepignore_files'], x), + always_select_explicit_targets: _atd_read_required_field('TargetingConf', 'always_select_explicit_targets', _atd_read_bool, x['always_select_explicit_targets'], x), + explicit_targets: _atd_read_required_field('TargetingConf', 'explicit_targets', _atd_read_array(_atd_read_string), x['explicit_targets'], x), + force_project_root: _atd_read_optional_field(readProjectRoot, x['force_project_root'], x), + force_novcs_project: _atd_read_required_field('TargetingConf', 'force_novcs_project', _atd_read_bool, x['force_novcs_project'], x), + exclude_minified_files: _atd_read_required_field('TargetingConf', 'exclude_minified_files', _atd_read_bool, x['exclude_minified_files'], x), + baseline_commit: _atd_read_optional_field(_atd_read_string, x['baseline_commit'], x), + diff_depth: _atd_read_required_field('TargetingConf', 'diff_depth', _atd_read_int, x['diff_depth'], x), + }; +} + export function writeAnalyzer(x: Analyzer, context: any = x): any { return _atd_write_string(x, context); } @@ -3590,12 +3672,40 @@ export function readCodeTarget(x: any, context: any = x): CodeTarget { }; } +export function writeScanningRoots(x: ScanningRoots, context: any = x): any { + return { + 'root_paths': _atd_write_required_field('ScanningRoots', 'root_paths', _atd_write_array(writeFpath), x.root_paths, x), + 'targeting_conf': _atd_write_required_field('ScanningRoots', 'targeting_conf', writeTargetingConf, x.targeting_conf, x), + }; +} + +export function readScanningRoots(x: any, context: any = x): ScanningRoots { + return { + root_paths: _atd_read_required_field('ScanningRoots', 'root_paths', _atd_read_array(readFpath), x['root_paths'], x), + targeting_conf: _atd_read_required_field('ScanningRoots', 'targeting_conf', readTargetingConf, x['targeting_conf'], x), + }; +} + export function writeTargets(x: Targets, context: any = x): any { - return _atd_write_array(writeTarget)(x, context); + switch (x.kind) { + case 'Scanning_roots': + return ['Scanning_roots', writeScanningRoots(x.value, x)] + case 'Targets': + return ['Targets', _atd_write_array(writeTarget)(x.value, x)] + } } export function readTargets(x: any, context: any = x): Targets { - return _atd_read_array(readTarget)(x, context); + _atd_check_json_tuple(2, x, context) + switch (x[0]) { + case 'Scanning_roots': + return { kind: 'Scanning_roots', value: readScanningRoots(x[1], x) } + case 'Targets': + return { kind: 'Targets', value: _atd_read_array(readTarget)(x[1], x) } + default: + _atd_bad_json('Targets', x, context) + throw new Error('impossible') + } } export function writeEdit(x: Edit, context: any = x): any { diff --git a/semgrep_output_v1_j.ml b/semgrep_output_v1_j.ml index 13cc6e8..2d5866e 100644 --- a/semgrep_output_v1_j.ml +++ b/semgrep_output_v1_j.ml @@ -259,6 +259,24 @@ type tests_result = Semgrep_output_v1_t.tests_result = { config_with_errors: config_error list } +type project_root = Semgrep_output_v1_t.project_root [@@deriving show] + +type targeting_conf = Semgrep_output_v1_t.targeting_conf = { + exclude: string list; + include_: string list option; + max_target_bytes: int; + respect_gitignore: bool; + respect_semgrepignore_files: bool; + always_select_explicit_targets: bool; + explicit_targets: string list; + force_project_root: project_root option; + force_novcs_project: bool; + exclude_minified_files: bool; + baseline_commit: string option; + diff_depth: int +} + [@@deriving show] + type product = Semgrep_output_v1_t.product [@@deriving show, eq] type lockfile_kind = Semgrep_output_v1_t.lockfile_kind = @@ -288,6 +306,12 @@ type code_target = Semgrep_output_v1_t.code_target = { type target = Semgrep_output_v1_t.target [@@deriving show] +type scanning_roots = Semgrep_output_v1_t.scanning_roots = { + root_paths: fpath list; + targeting_conf: targeting_conf +} + [@@deriving show] + type targets = Semgrep_output_v1_t.targets [@@deriving show] type target_times = Semgrep_output_v1_t.target_times = { @@ -10096,7 +10120,809 @@ let read_tests_result = ( field_config_with_errors := ( Some ( ( - read__config_error_list + read__config_error_list + ) p lb + ) + ); + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + done; + assert false; + with Yojson.End_of_object -> ( + ( + { + results = (match !field_results with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "results"); + fixtest_results = (match !field_fixtest_results with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "fixtest_results"); + config_missing_tests = (match !field_config_missing_tests with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "config_missing_tests"); + config_missing_fixtests = (match !field_config_missing_fixtests with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "config_missing_fixtests"); + config_with_errors = (match !field_config_with_errors with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "config_with_errors"); + } + : tests_result) + ) +) +let tests_result_of_string s = + read_tests_result (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_project_root = ( + fun ob x -> + match x with + | `Filesystem x -> + Buffer.add_string ob "[\"Filesystem\","; + ( + Yojson.Safe.write_string + ) ob x; + Buffer.add_char ob ']' + | `Git_remote x -> + Buffer.add_string ob "[\"Git_remote\","; + ( + Yojson.Safe.write_string + ) ob x; + Buffer.add_char ob ']' +) +let string_of_project_root ?(len = 1024) x = + let ob = Buffer.create len in + write_project_root ob x; + Buffer.contents ob +let read_project_root = ( + 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 + | "Filesystem" -> + Atdgen_runtime.Oj_run.read_until_field_value p lb; + let x = ( + Atdgen_runtime.Oj_run.read_string + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Filesystem x + | "Git_remote" -> + Atdgen_runtime.Oj_run.read_until_field_value p lb; + let x = ( + Atdgen_runtime.Oj_run.read_string + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Git_remote x + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Double_quote -> ( + match Yojson.Safe.finish_string p lb with + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Square_bracket -> ( + match Atdgen_runtime.Oj_run.read_string p lb with + | "Filesystem" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; + let x = ( + Atdgen_runtime.Oj_run.read_string + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_rbr p lb; + `Filesystem x + | "Git_remote" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; + let x = ( + Atdgen_runtime.Oj_run.read_string + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_rbr p lb; + `Git_remote x + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) +) +let project_root_of_string s = + read_project_root (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__string_list_option = ( + Atdgen_runtime.Oj_run.write_std_option ( + write__string_list + ) +) +let string_of__string_list_option ?(len = 1024) x = + let ob = Buffer.create len in + write__string_list_option ob x; + Buffer.contents ob +let read__string_list_option = ( + fun p lb -> + Yojson.Safe.read_space p lb; + match Yojson.Safe.start_any_variant p lb with + | `Edgy_bracket -> ( + match Yojson.Safe.read_ident p lb with + | "None" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (None : _ option) + | "Some" -> + Atdgen_runtime.Oj_run.read_until_field_value p lb; + let x = ( + read__string_list + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Some x : _ option) + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Double_quote -> ( + match Yojson.Safe.finish_string p lb with + | "None" -> + (None : _ option) + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Square_bracket -> ( + match Atdgen_runtime.Oj_run.read_string p lb with + | "Some" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; + let x = ( + read__string_list + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_rbr p lb; + (Some x : _ option) + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) +) +let _string_list_option_of_string s = + read__string_list_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__project_root_option = ( + Atdgen_runtime.Oj_run.write_std_option ( + write_project_root + ) +) +let string_of__project_root_option ?(len = 1024) x = + let ob = Buffer.create len in + write__project_root_option ob x; + Buffer.contents ob +let read__project_root_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_project_root + ) 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_project_root + ) 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 _project_root_option_of_string s = + read__project_root_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_targeting_conf : _ -> targeting_conf -> _ = ( + fun ob (x : targeting_conf) -> + 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 "\"exclude\":"; + ( + write__string_list + ) + ob x.exclude; + (match x.include_ with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"include_\":"; + ( + write__string_list + ) + ob x; + ); + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"max_target_bytes\":"; + ( + Yojson.Safe.write_int + ) + ob x.max_target_bytes; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"respect_gitignore\":"; + ( + Yojson.Safe.write_bool + ) + ob x.respect_gitignore; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"respect_semgrepignore_files\":"; + ( + Yojson.Safe.write_bool + ) + ob x.respect_semgrepignore_files; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"always_select_explicit_targets\":"; + ( + Yojson.Safe.write_bool + ) + ob x.always_select_explicit_targets; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"explicit_targets\":"; + ( + write__string_list + ) + ob x.explicit_targets; + (match x.force_project_root with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"force_project_root\":"; + ( + write_project_root + ) + ob x; + ); + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"force_novcs_project\":"; + ( + Yojson.Safe.write_bool + ) + ob x.force_novcs_project; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"exclude_minified_files\":"; + ( + Yojson.Safe.write_bool + ) + ob x.exclude_minified_files; + (match x.baseline_commit with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"baseline_commit\":"; + ( + Yojson.Safe.write_string + ) + ob x; + ); + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"diff_depth\":"; + ( + Yojson.Safe.write_int + ) + ob x.diff_depth; + Buffer.add_char ob '}'; +) +let string_of_targeting_conf ?(len = 1024) x = + let ob = Buffer.create len in + write_targeting_conf ob x; + Buffer.contents ob +let read_targeting_conf = ( + fun p lb -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_lcurl p lb; + let field_exclude = ref (None) in + let field_include_ = ref (None) in + let field_max_target_bytes = ref (None) in + let field_respect_gitignore = ref (None) in + let field_respect_semgrepignore_files = ref (None) in + let field_always_select_explicit_targets = ref (None) in + let field_explicit_targets = ref (None) in + let field_force_project_root = ref (None) in + let field_force_novcs_project = ref (None) in + let field_exclude_minified_files = ref (None) in + let field_baseline_commit = ref (None) in + let field_diff_depth = ref (None) in + try + Yojson.Safe.read_space p lb; + Yojson.Safe.read_object_end lb; + Yojson.Safe.read_space p lb; + let f = + fun s pos len -> + if pos < 0 || len < 0 || pos + len > String.length s then + invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); + match len with + | 7 -> ( + if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'x' && String.unsafe_get s (pos+2) = 'c' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'e' then ( + 0 + ) + else ( + -1 + ) + ) + | 8 -> ( + if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'c' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = '_' then ( + 1 + ) + else ( + -1 + ) + ) + | 10 -> ( + if String.unsafe_get s pos = 'd' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'f' && String.unsafe_get s (pos+3) = 'f' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'p' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'h' then ( + 11 + ) + else ( + -1 + ) + ) + | 15 -> ( + if String.unsafe_get s pos = 'b' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 'c' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'm' && String.unsafe_get s (pos+12) = 'm' && String.unsafe_get s (pos+13) = 'i' && String.unsafe_get s (pos+14) = 't' then ( + 10 + ) + else ( + -1 + ) + ) + | 16 -> ( + match String.unsafe_get s pos with + | 'e' -> ( + if String.unsafe_get s (pos+1) = 'x' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'a' && String.unsafe_get s (pos+11) = 'r' && String.unsafe_get s (pos+12) = 'g' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 's' then ( + 6 + ) + else ( + -1 + ) + ) + | 'm' -> ( + if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'x' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 'g' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'b' && String.unsafe_get s (pos+12) = 'y' && String.unsafe_get s (pos+13) = 't' && String.unsafe_get s (pos+14) = 'e' && String.unsafe_get s (pos+15) = 's' then ( + 2 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | 17 -> ( + if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 'e' && 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) = 'g' && String.unsafe_get s (pos+9) = 'i' && String.unsafe_get s (pos+10) = 't' && String.unsafe_get s (pos+11) = 'i' && String.unsafe_get s (pos+12) = 'g' && String.unsafe_get s (pos+13) = 'n' && String.unsafe_get s (pos+14) = 'o' && String.unsafe_get s (pos+15) = 'r' && String.unsafe_get s (pos+16) = 'e' then ( + 3 + ) + else ( + -1 + ) + ) + | 18 -> ( + if String.unsafe_get s pos = 'f' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'p' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'j' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 'c' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = '_' && String.unsafe_get s (pos+14) = 'r' && String.unsafe_get s (pos+15) = 'o' && String.unsafe_get s (pos+16) = 'o' && String.unsafe_get s (pos+17) = 't' then ( + 7 + ) + else ( + -1 + ) + ) + | 19 -> ( + if String.unsafe_get s pos = 'f' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'o' && String.unsafe_get s (pos+8) = 'v' && String.unsafe_get s (pos+9) = 'c' && String.unsafe_get s (pos+10) = 's' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 'p' && String.unsafe_get s (pos+13) = 'r' && String.unsafe_get s (pos+14) = 'o' && String.unsafe_get s (pos+15) = 'j' && String.unsafe_get s (pos+16) = 'e' && String.unsafe_get s (pos+17) = 'c' && String.unsafe_get s (pos+18) = 't' then ( + 8 + ) + else ( + -1 + ) + ) + | 22 -> ( + if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'x' && String.unsafe_get s (pos+2) = 'c' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'm' && String.unsafe_get s (pos+9) = 'i' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = 'i' && String.unsafe_get s (pos+12) = 'f' && String.unsafe_get s (pos+13) = 'i' && String.unsafe_get s (pos+14) = 'e' && String.unsafe_get s (pos+15) = 'd' && String.unsafe_get s (pos+16) = '_' && String.unsafe_get s (pos+17) = 'f' && String.unsafe_get s (pos+18) = 'i' && String.unsafe_get s (pos+19) = 'l' && String.unsafe_get s (pos+20) = 'e' && String.unsafe_get s (pos+21) = 's' then ( + 9 + ) + else ( + -1 + ) + ) + | 27 -> ( + if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 'e' && 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) = 's' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 'm' && String.unsafe_get s (pos+11) = 'g' && String.unsafe_get s (pos+12) = 'r' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 'p' && String.unsafe_get s (pos+15) = 'i' && String.unsafe_get s (pos+16) = 'g' && String.unsafe_get s (pos+17) = 'n' && String.unsafe_get s (pos+18) = 'o' && String.unsafe_get s (pos+19) = 'r' && String.unsafe_get s (pos+20) = 'e' && String.unsafe_get s (pos+21) = '_' && String.unsafe_get s (pos+22) = 'f' && String.unsafe_get s (pos+23) = 'i' && String.unsafe_get s (pos+24) = 'l' && String.unsafe_get s (pos+25) = 'e' && String.unsafe_get s (pos+26) = 's' then ( + 4 + ) + else ( + -1 + ) + ) + | 30 -> ( + 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) = 'e' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 'c' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = '_' && String.unsafe_get s (pos+14) = 'e' && String.unsafe_get s (pos+15) = 'x' && String.unsafe_get s (pos+16) = 'p' && String.unsafe_get s (pos+17) = 'l' && String.unsafe_get s (pos+18) = 'i' && String.unsafe_get s (pos+19) = 'c' && String.unsafe_get s (pos+20) = 'i' && String.unsafe_get s (pos+21) = 't' && String.unsafe_get s (pos+22) = '_' && String.unsafe_get s (pos+23) = 't' && String.unsafe_get s (pos+24) = 'a' && String.unsafe_get s (pos+25) = 'r' && String.unsafe_get s (pos+26) = 'g' && String.unsafe_get s (pos+27) = 'e' && String.unsafe_get s (pos+28) = 't' && String.unsafe_get s (pos+29) = 's' then ( + 5 + ) + 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_exclude := ( + Some ( + ( + read__string_list + ) p lb + ) + ); + | 1 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_include_ := ( + Some ( + ( + read__string_list + ) p lb + ) + ); + ) + | 2 -> + field_max_target_bytes := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 3 -> + field_respect_gitignore := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | 4 -> + field_respect_semgrepignore_files := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | 5 -> + field_always_select_explicit_targets := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | 6 -> + field_explicit_targets := ( + Some ( + ( + read__string_list + ) p lb + ) + ); + | 7 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_force_project_root := ( + Some ( + ( + read_project_root + ) p lb + ) + ); + ) + | 8 -> + field_force_novcs_project := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | 9 -> + field_exclude_minified_files := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | 10 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_baseline_commit := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + ) + | 11 -> + field_diff_depth := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + while true do + Yojson.Safe.read_space p lb; + Yojson.Safe.read_object_sep p lb; + Yojson.Safe.read_space p lb; + let f = + fun s pos len -> + if pos < 0 || len < 0 || pos + len > String.length s then + invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); + match len with + | 7 -> ( + if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'x' && String.unsafe_get s (pos+2) = 'c' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'e' then ( + 0 + ) + else ( + -1 + ) + ) + | 8 -> ( + if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'c' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = '_' then ( + 1 + ) + else ( + -1 + ) + ) + | 10 -> ( + if String.unsafe_get s pos = 'd' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'f' && String.unsafe_get s (pos+3) = 'f' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'p' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'h' then ( + 11 + ) + else ( + -1 + ) + ) + | 15 -> ( + if String.unsafe_get s pos = 'b' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 'c' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'm' && String.unsafe_get s (pos+12) = 'm' && String.unsafe_get s (pos+13) = 'i' && String.unsafe_get s (pos+14) = 't' then ( + 10 + ) + else ( + -1 + ) + ) + | 16 -> ( + match String.unsafe_get s pos with + | 'e' -> ( + if String.unsafe_get s (pos+1) = 'x' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 'a' && String.unsafe_get s (pos+11) = 'r' && String.unsafe_get s (pos+12) = 'g' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 's' then ( + 6 + ) + else ( + -1 + ) + ) + | 'm' -> ( + if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'x' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 'g' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'b' && String.unsafe_get s (pos+12) = 'y' && String.unsafe_get s (pos+13) = 't' && String.unsafe_get s (pos+14) = 'e' && String.unsafe_get s (pos+15) = 's' then ( + 2 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + | 17 -> ( + if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 'e' && 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) = 'g' && String.unsafe_get s (pos+9) = 'i' && String.unsafe_get s (pos+10) = 't' && String.unsafe_get s (pos+11) = 'i' && String.unsafe_get s (pos+12) = 'g' && String.unsafe_get s (pos+13) = 'n' && String.unsafe_get s (pos+14) = 'o' && String.unsafe_get s (pos+15) = 'r' && String.unsafe_get s (pos+16) = 'e' then ( + 3 + ) + else ( + -1 + ) + ) + | 18 -> ( + if String.unsafe_get s pos = 'f' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'p' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'j' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 'c' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = '_' && String.unsafe_get s (pos+14) = 'r' && String.unsafe_get s (pos+15) = 'o' && String.unsafe_get s (pos+16) = 'o' && String.unsafe_get s (pos+17) = 't' then ( + 7 + ) + else ( + -1 + ) + ) + | 19 -> ( + if String.unsafe_get s pos = 'f' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'o' && String.unsafe_get s (pos+8) = 'v' && String.unsafe_get s (pos+9) = 'c' && String.unsafe_get s (pos+10) = 's' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 'p' && String.unsafe_get s (pos+13) = 'r' && String.unsafe_get s (pos+14) = 'o' && String.unsafe_get s (pos+15) = 'j' && String.unsafe_get s (pos+16) = 'e' && String.unsafe_get s (pos+17) = 'c' && String.unsafe_get s (pos+18) = 't' then ( + 8 + ) + else ( + -1 + ) + ) + | 22 -> ( + if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'x' && String.unsafe_get s (pos+2) = 'c' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'm' && String.unsafe_get s (pos+9) = 'i' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = 'i' && String.unsafe_get s (pos+12) = 'f' && String.unsafe_get s (pos+13) = 'i' && String.unsafe_get s (pos+14) = 'e' && String.unsafe_get s (pos+15) = 'd' && String.unsafe_get s (pos+16) = '_' && String.unsafe_get s (pos+17) = 'f' && String.unsafe_get s (pos+18) = 'i' && String.unsafe_get s (pos+19) = 'l' && String.unsafe_get s (pos+20) = 'e' && String.unsafe_get s (pos+21) = 's' then ( + 9 + ) + else ( + -1 + ) + ) + | 27 -> ( + if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 'e' && 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) = 's' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 'm' && String.unsafe_get s (pos+11) = 'g' && String.unsafe_get s (pos+12) = 'r' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 'p' && String.unsafe_get s (pos+15) = 'i' && String.unsafe_get s (pos+16) = 'g' && String.unsafe_get s (pos+17) = 'n' && String.unsafe_get s (pos+18) = 'o' && String.unsafe_get s (pos+19) = 'r' && String.unsafe_get s (pos+20) = 'e' && String.unsafe_get s (pos+21) = '_' && String.unsafe_get s (pos+22) = 'f' && String.unsafe_get s (pos+23) = 'i' && String.unsafe_get s (pos+24) = 'l' && String.unsafe_get s (pos+25) = 'e' && String.unsafe_get s (pos+26) = 's' then ( + 4 + ) + else ( + -1 + ) + ) + | 30 -> ( + 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) = 'e' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 'c' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = '_' && String.unsafe_get s (pos+14) = 'e' && String.unsafe_get s (pos+15) = 'x' && String.unsafe_get s (pos+16) = 'p' && String.unsafe_get s (pos+17) = 'l' && String.unsafe_get s (pos+18) = 'i' && String.unsafe_get s (pos+19) = 'c' && String.unsafe_get s (pos+20) = 'i' && String.unsafe_get s (pos+21) = 't' && String.unsafe_get s (pos+22) = '_' && String.unsafe_get s (pos+23) = 't' && String.unsafe_get s (pos+24) = 'a' && String.unsafe_get s (pos+25) = 'r' && String.unsafe_get s (pos+26) = 'g' && String.unsafe_get s (pos+27) = 'e' && String.unsafe_get s (pos+28) = 't' && String.unsafe_get s (pos+29) = 's' then ( + 5 + ) + 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_exclude := ( + Some ( + ( + read__string_list + ) p lb + ) + ); + | 1 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_include_ := ( + Some ( + ( + read__string_list + ) p lb + ) + ); + ) + | 2 -> + field_max_target_bytes := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 3 -> + field_respect_gitignore := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | 4 -> + field_respect_semgrepignore_files := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | 5 -> + field_always_select_explicit_targets := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | 6 -> + field_explicit_targets := ( + Some ( + ( + read__string_list + ) p lb + ) + ); + | 7 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_force_project_root := ( + Some ( + ( + read_project_root + ) p lb + ) + ); + ) + | 8 -> + field_force_novcs_project := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | 9 -> + field_exclude_minified_files := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ) + ); + | 10 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_baseline_commit := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + ) + | 11 -> + field_diff_depth := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int ) p lb ) ); @@ -10109,17 +10935,24 @@ let read_tests_result = ( with Yojson.End_of_object -> ( ( { - results = (match !field_results with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "results"); - fixtest_results = (match !field_fixtest_results with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "fixtest_results"); - config_missing_tests = (match !field_config_missing_tests with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "config_missing_tests"); - config_missing_fixtests = (match !field_config_missing_fixtests with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "config_missing_fixtests"); - config_with_errors = (match !field_config_with_errors with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "config_with_errors"); + exclude = (match !field_exclude with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "exclude"); + include_ = !field_include_; + max_target_bytes = (match !field_max_target_bytes with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "max_target_bytes"); + respect_gitignore = (match !field_respect_gitignore with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "respect_gitignore"); + respect_semgrepignore_files = (match !field_respect_semgrepignore_files with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "respect_semgrepignore_files"); + always_select_explicit_targets = (match !field_always_select_explicit_targets with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "always_select_explicit_targets"); + explicit_targets = (match !field_explicit_targets with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "explicit_targets"); + force_project_root = !field_force_project_root; + force_novcs_project = (match !field_force_novcs_project with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "force_novcs_project"); + exclude_minified_files = (match !field_exclude_minified_files with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "exclude_minified_files"); + baseline_commit = !field_baseline_commit; + diff_depth = (match !field_diff_depth with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "diff_depth"); } - : tests_result) + : targeting_conf) ) ) -let tests_result_of_string s = - read_tests_result (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let targeting_conf_of_string s = + read_targeting_conf (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_product = ( fun ob x -> match x with @@ -10940,6 +11773,159 @@ let read_target = ( ) let target_of_string s = read_target (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_scanning_roots : _ -> scanning_roots -> _ = ( + fun ob (x : scanning_roots) -> + 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 "\"root_paths\":"; + ( + write__fpath_list + ) + ob x.root_paths; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"targeting_conf\":"; + ( + write_targeting_conf + ) + ob x.targeting_conf; + Buffer.add_char ob '}'; +) +let string_of_scanning_roots ?(len = 1024) x = + let ob = Buffer.create len in + write_scanning_roots ob x; + Buffer.contents ob +let read_scanning_roots = ( + fun p lb -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_lcurl p lb; + let field_root_paths = ref (None) in + let field_targeting_conf = 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 + | 10 -> ( + if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'p' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'h' && String.unsafe_get s (pos+9) = 's' then ( + 0 + ) + else ( + -1 + ) + ) + | 14 -> ( + if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'g' && String.unsafe_get s (pos+9) = '_' && String.unsafe_get s (pos+10) = 'c' && String.unsafe_get s (pos+11) = 'o' && String.unsafe_get s (pos+12) = 'n' && String.unsafe_get s (pos+13) = 'f' 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_root_paths := ( + Some ( + ( + read__fpath_list + ) p lb + ) + ); + | 1 -> + field_targeting_conf := ( + Some ( + ( + read_targeting_conf + ) 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 + | 10 -> ( + if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'p' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'h' && String.unsafe_get s (pos+9) = 's' then ( + 0 + ) + else ( + -1 + ) + ) + | 14 -> ( + if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'g' && String.unsafe_get s (pos+9) = '_' && String.unsafe_get s (pos+10) = 'c' && String.unsafe_get s (pos+11) = 'o' && String.unsafe_get s (pos+12) = 'n' && String.unsafe_get s (pos+13) = 'f' 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_root_paths := ( + Some ( + ( + read__fpath_list + ) p lb + ) + ); + | 1 -> + field_targeting_conf := ( + Some ( + ( + read_targeting_conf + ) p lb + ) + ); + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + done; + assert false; + with Yojson.End_of_object -> ( + ( + { + root_paths = (match !field_root_paths with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "root_paths"); + targeting_conf = (match !field_targeting_conf with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "targeting_conf"); + } + : scanning_roots) + ) +) +let scanning_roots_of_string s = + read_scanning_roots (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__target_list = ( Atdgen_runtime.Oj_run.write_list ( write_target @@ -10957,14 +11943,84 @@ let read__target_list = ( let _target_list_of_string s = read__target_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_targets = ( - write__target_list + fun ob x -> + match x with + | `Scanning_roots x -> + Buffer.add_string ob "[\"Scanning_roots\","; + ( + write_scanning_roots + ) ob x; + Buffer.add_char ob ']' + | `Targets x -> + Buffer.add_string ob "[\"Targets\","; + ( + write__target_list + ) ob x; + Buffer.add_char ob ']' ) let string_of_targets ?(len = 1024) x = let ob = Buffer.create len in write_targets ob x; Buffer.contents ob let read_targets = ( - read__target_list + 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 + | "Scanning_roots" -> + Atdgen_runtime.Oj_run.read_until_field_value p lb; + let x = ( + read_scanning_roots + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Scanning_roots x + | "Targets" -> + Atdgen_runtime.Oj_run.read_until_field_value p lb; + let x = ( + read__target_list + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Targets x + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Double_quote -> ( + match Yojson.Safe.finish_string p lb with + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Square_bracket -> ( + match Atdgen_runtime.Oj_run.read_string p lb with + | "Scanning_roots" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; + let x = ( + read_scanning_roots + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_rbr p lb; + `Scanning_roots x + | "Targets" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; + let x = ( + read__target_list + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_rbr p lb; + `Targets x + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) ) let targets_of_string s = read_targets (Yojson.Safe.init_lexer ()) (Lexing.from_string s) @@ -21201,63 +22257,6 @@ let read_finding_hashes = ( ) let finding_hashes_of_string s = read_finding_hashes (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__string_list_option = ( - Atdgen_runtime.Oj_run.write_std_option ( - write__string_list - ) -) -let string_of__string_list_option ?(len = 1024) x = - let ob = Buffer.create len in - write__string_list_option ob x; - Buffer.contents ob -let read__string_list_option = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read__string_list - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read__string_list - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _string_list_option_of_string s = - read__string_list_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__finding_hashes_option = ( Atdgen_runtime.Oj_run.write_std_option ( write_finding_hashes diff --git a/semgrep_output_v1_j.mli b/semgrep_output_v1_j.mli index 945459f..7d7a8cb 100644 --- a/semgrep_output_v1_j.mli +++ b/semgrep_output_v1_j.mli @@ -259,6 +259,24 @@ type tests_result = Semgrep_output_v1_t.tests_result = { config_with_errors: config_error list } +type project_root = Semgrep_output_v1_t.project_root [@@deriving show] + +type targeting_conf = Semgrep_output_v1_t.targeting_conf = { + exclude: string list; + include_: string list option; + max_target_bytes: int; + respect_gitignore: bool; + respect_semgrepignore_files: bool; + always_select_explicit_targets: bool; + explicit_targets: string list; + force_project_root: project_root option; + force_novcs_project: bool; + exclude_minified_files: bool; + baseline_commit: string option; + diff_depth: int +} + [@@deriving show] + type product = Semgrep_output_v1_t.product [@@deriving show, eq] type lockfile_kind = Semgrep_output_v1_t.lockfile_kind = @@ -288,6 +306,12 @@ type code_target = Semgrep_output_v1_t.code_target = { type target = Semgrep_output_v1_t.target [@@deriving show] +type scanning_roots = Semgrep_output_v1_t.scanning_roots = { + root_paths: fpath list; + targeting_conf: targeting_conf +} + [@@deriving show] + type targets = Semgrep_output_v1_t.targets [@@deriving show] type target_times = Semgrep_output_v1_t.target_times = { @@ -1906,6 +1930,46 @@ val tests_result_of_string : string -> tests_result (** Deserialize JSON data of type {!type:tests_result}. *) +val write_project_root : + Buffer.t -> project_root -> unit + (** Output a JSON value of type {!type:project_root}. *) + +val string_of_project_root : + ?len:int -> project_root -> string + (** Serialize a value of type {!type:project_root} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_project_root : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> project_root + (** Input JSON data of type {!type:project_root}. *) + +val project_root_of_string : + string -> project_root + (** Deserialize JSON data of type {!type:project_root}. *) + +val write_targeting_conf : + Buffer.t -> targeting_conf -> unit + (** Output a JSON value of type {!type:targeting_conf}. *) + +val string_of_targeting_conf : + ?len:int -> targeting_conf -> string + (** Serialize a value of type {!type:targeting_conf} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_targeting_conf : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> targeting_conf + (** Input JSON data of type {!type:targeting_conf}. *) + +val targeting_conf_of_string : + string -> targeting_conf + (** Deserialize JSON data of type {!type:targeting_conf}. *) + val write_product : Buffer.t -> product -> unit (** Output a JSON value of type {!type:product}. *) @@ -2026,6 +2090,26 @@ val target_of_string : string -> target (** Deserialize JSON data of type {!type:target}. *) +val write_scanning_roots : + Buffer.t -> scanning_roots -> unit + (** Output a JSON value of type {!type:scanning_roots}. *) + +val string_of_scanning_roots : + ?len:int -> scanning_roots -> string + (** Serialize a value of type {!type:scanning_roots} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_scanning_roots : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> scanning_roots + (** Input JSON data of type {!type:scanning_roots}. *) + +val scanning_roots_of_string : + string -> scanning_roots + (** Deserialize JSON data of type {!type:scanning_roots}. *) + val write_targets : Buffer.t -> targets -> unit (** Output a JSON value of type {!type:targets}. *)