From b35746b9ec4472a0de0dc6c48a0769518ba429dd Mon Sep 17 00:00:00 2001 From: Sal Olivares Date: Tue, 19 Nov 2024 14:01:35 -0800 Subject: [PATCH] feat(sca): new SCA stats schema (#313) # Context The [existing "bytes parsed" metric](https://metabase.corp.semgrep.dev/dashboard/272-ssc-adoption-dashboard?tab=147-summary) we are currently relying on provides a limited perspective on customer SSC adoption, as it aggregates usage across languages without fully capturing which languages are meaningfully used. We want to augment the stats schema to improve metrics around Java dependency detection, lockfile-less scanning, and python requirements identification. - [x] I ran `make setup && make` to update the generated code after editing a `.atd` file (TODO: have a CI check) - [x] I made sure we're still backward compatible with old versions of the CLI. For example, the Semgrep backend need to still be able to *consume* data generated by Semgrep 1.17.0. See https://atd.readthedocs.io/en/latest/atdgen-tutorial.html#smooth-protocol-upgrades --- semgrep_output_v1.atd | 44 + semgrep_output_v1.jsonschema | 69 + semgrep_output_v1.proto | 24 +- semgrep_output_v1.py | 5835 ++++++++++++++++++---------------- semgrep_output_v1.ts | 133 + semgrep_output_v1_j.ml | 2198 +++++++++---- semgrep_output_v1_j.mli | 298 +- 7 files changed, 5154 insertions(+), 3447 deletions(-) diff --git a/semgrep_output_v1.atd b/semgrep_output_v1.atd index a02303e..d861fb6 100644 --- a/semgrep_output_v1.atd +++ b/semgrep_output_v1.atd @@ -1687,6 +1687,50 @@ type ci_scan_complete_stats = { option; + + (* since 1.98.0 *) + (* In collaboration with the Data Science team, it was suggested + * that we start to group stats by product for organizational purposes. + * + * This field will only be defined for SCA scans. + *) + ?supply_chain_stats: supply_chain_stats option; +} + +type resolution_method = [ + | LockfileParsing + | DynamicResolution +] + +type dependency_resolution_stats = { + resolution_method: resolution_method; + dependency_count: int; + ecosystem: ecosystem; +} + +type dependency_source_file_kind = [ + | Lockfile of lockfile_kind + | Manifest of manifest_kind +] + +type dependency_source_file = { + kind: dependency_source_file_kind; + path: fpath; +} + +type subproject_stats = { + (* The `subproject_id` is derived as a stable hash of the sorted paths of `dependency_source_file`s. + Any change to the set of dependency sources (addition, removal, or modification) results in a new + `subproject_id`, as different dependency sources indicate a different subproject context. *) + subproject_id: string; + (* Files used to determine the subproject's dependencies (lockfiles, manifest files, etc) *) + dependency_sources: dependency_source_file list; + (* Results of dependency resolution, empty if resolution failed *) + ?resolved_stats: dependency_resolution_stats option; +} + +type supply_chain_stats = { + subprojects_stats: subproject_stats list; } type parsing_stats = { diff --git a/semgrep_output_v1.jsonschema b/semgrep_output_v1.jsonschema index d28bd05..fd3ee34 100644 --- a/semgrep_output_v1.jsonschema +++ b/semgrep_output_v1.jsonschema @@ -1373,6 +1373,75 @@ "findings_by_product": { "type": "object", "additionalProperties": { "type": "integer" } + }, + "supply_chain_stats": { "$ref": "#/definitions/supply_chain_stats" } + } + }, + "resolution_method": { + "oneOf": [ + { "const": "LockfileParsing" }, { "const": "DynamicResolution" } + ] + }, + "dependency_resolution_stats": { + "type": "object", + "required": [ "resolution_method", "dependency_count", "ecosystem" ], + "properties": { + "resolution_method": { "$ref": "#/definitions/resolution_method" }, + "dependency_count": { "type": "integer" }, + "ecosystem": { "$ref": "#/definitions/ecosystem" } + } + }, + "dependency_source_file_kind": { + "oneOf": [ + { + "type": "array", + "minItems": 2, + "items": false, + "prefixItems": [ + { "const": "Lockfile" }, + { "$ref": "#/definitions/lockfile_kind" } + ] + }, + { + "type": "array", + "minItems": 2, + "items": false, + "prefixItems": [ + { "const": "Manifest" }, + { "$ref": "#/definitions/manifest_kind" } + ] + } + ] + }, + "dependency_source_file": { + "type": "object", + "required": [ "kind", "path" ], + "properties": { + "kind": { "$ref": "#/definitions/dependency_source_file_kind" }, + "path": { "$ref": "#/definitions/fpath" } + } + }, + "subproject_stats": { + "type": "object", + "required": [ "subproject_id", "dependency_sources" ], + "properties": { + "subproject_id": { "type": "string" }, + "dependency_sources": { + "type": "array", + "items": { "$ref": "#/definitions/dependency_source_file" } + }, + "resolved_stats": { + "$ref": "#/definitions/dependency_resolution_stats" + } + } + }, + "supply_chain_stats": { + "type": "object", + "required": [ "subprojects_stats" ], + "properties": { + "subprojects_stats": { + "type": "array", + "items": { "$ref": "#/definitions/subproject_stats" } } } }, diff --git a/semgrep_output_v1.proto b/semgrep_output_v1.proto index f6580b3..dfac968 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: 1e74e1e50c97e4ff7c94c9d0c45134b61b53533d69d28342203e3cb2bc7373eb +// Source file sha256 digest: 9e7f28fdb812d97483514411de60911c80496fbccf1a0fb88c770873a8818de1 syntax = "proto3"; @@ -558,6 +558,28 @@ message CiScanCompleteStats { map parse_rate = 50643605; string engine_requested = 513422373; map findings_by_product = 499456012; + SupplyChainStats supply_chain_stats = 329027804; +} + +message DependencyResolutionStats { + google.protobuf.Any resolution_method = 495111318; + int64 dependency_count = 507475109; + google.protobuf.Any ecosystem = 7072103; +} + +message DependencySourceFile { + google.protobuf.Any kind = 3088172; + string path = 3212859; +} + +message SubprojectStats { + string subproject_id = 481879717; + repeated DependencySourceFile dependency_sources = 4836694; + DependencyResolutionStats resolved_stats = 364874699; +} + +message SupplyChainStats { + repeated SubprojectStats subprojects_stats = 28460775; } message ParsingStats { diff --git a/semgrep_output_v1.py b/semgrep_output_v1.py index 66cb519..6771882 100644 --- a/semgrep_output_v1.py +++ b/semgrep_output_v1.py @@ -2517,1135 +2517,1014 @@ def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class AlwaysSkipped: - """Original type: skip_reason = [ ... | Always_skipped | ... ]""" +@dataclass(frozen=True, order=True) +class LockfileParsing: + """Original type: resolution_method = [ ... | LockfileParsing | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'AlwaysSkipped' + return 'LockfileParsing' @staticmethod def to_json() -> Any: - return 'always_skipped' + return 'LockfileParsing' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class SemgrepignorePatternsMatch: - """Original type: skip_reason = [ ... | Semgrepignore_patterns_match | ... ]""" +@dataclass(frozen=True, order=True) +class DynamicResolution: + """Original type: resolution_method = [ ... | DynamicResolution | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'SemgrepignorePatternsMatch' + return 'DynamicResolution' @staticmethod def to_json() -> Any: - return 'semgrepignore_patterns_match' + return 'DynamicResolution' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class CliIncludeFlagsDoNotMatch: - """Original type: skip_reason = [ ... | Cli_include_flags_do_not_match | ... ]""" +@dataclass(frozen=True, order=True) +class ResolutionMethod: + """Original type: resolution_method = [ ... ]""" + + value: Union[LockfileParsing, DynamicResolution] @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'CliIncludeFlagsDoNotMatch' + return self.value.kind - @staticmethod - def to_json() -> Any: - return 'cli_include_flags_do_not_match' + @classmethod + def from_json(cls, x: Any) -> 'ResolutionMethod': + if isinstance(x, str): + if x == 'LockfileParsing': + return cls(LockfileParsing()) + if x == 'DynamicResolution': + return cls(DynamicResolution()) + _atd_bad_json('ResolutionMethod', x) + _atd_bad_json('ResolutionMethod', x) + + def to_json(self) -> Any: + return self.value.to_json() + + @classmethod + def from_json_string(cls, x: str) -> 'ResolutionMethod': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class CliExcludeFlagsMatch: - """Original type: skip_reason = [ ... | Cli_exclude_flags_match | ... ]""" +@dataclass(frozen=True) +class RequirementsIn: + """Original type: manifest_kind = [ ... | RequirementsIn | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'CliExcludeFlagsMatch' + return 'RequirementsIn' @staticmethod def to_json() -> Any: - return 'cli_exclude_flags_match' + return 'RequirementsIn' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class ExceededSizeLimit: - """Original type: skip_reason = [ ... | Exceeded_size_limit | ... ]""" +@dataclass(frozen=True) +class PackageJson: + """Original type: manifest_kind = [ ... | PackageJson | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'ExceededSizeLimit' + return 'PackageJson' @staticmethod def to_json() -> Any: - return 'exceeded_size_limit' + return 'PackageJson' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class AnalysisFailedParserOrInternalError: - """Original type: skip_reason = [ ... | Analysis_failed_parser_or_internal_error | ... ]""" +@dataclass(frozen=True) +class Gemfile: + """Original type: manifest_kind = [ ... | Gemfile | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'AnalysisFailedParserOrInternalError' + return 'Gemfile' @staticmethod def to_json() -> Any: - return 'analysis_failed_parser_or_internal_error' + return 'Gemfile' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class ExcludedByConfig: - """Original type: skip_reason = [ ... | Excluded_by_config | ... ]""" +@dataclass(frozen=True) +class GoMod: + """Original type: manifest_kind = [ ... | GoMod | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'ExcludedByConfig' + return 'GoMod' @staticmethod def to_json() -> Any: - return 'excluded_by_config' + return 'GoMod' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class WrongLanguage: - """Original type: skip_reason = [ ... | Wrong_language | ... ]""" +@dataclass(frozen=True) +class CargoToml: + """Original type: manifest_kind = [ ... | CargoToml | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'WrongLanguage' + return 'CargoToml' @staticmethod def to_json() -> Any: - return 'wrong_language' + return 'CargoToml' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class TooBig: - """Original type: skip_reason = [ ... | Too_big | ... ]""" +@dataclass(frozen=True) +class PomXml: + """Original type: manifest_kind = [ ... | PomXml | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'TooBig' + return 'PomXml' @staticmethod def to_json() -> Any: - return 'too_big' + return 'PomXml' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class Minified: - """Original type: skip_reason = [ ... | Minified | ... ]""" +@dataclass(frozen=True) +class BuildGradle: + """Original type: manifest_kind = [ ... | BuildGradle | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Minified' + return 'BuildGradle' @staticmethod def to_json() -> Any: - return 'minified' + return 'BuildGradle' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class Binary: - """Original type: skip_reason = [ ... | Binary | ... ]""" +@dataclass(frozen=True) +class SettingsGradle: + """Original type: manifest_kind = [ ... | SettingsGradle | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Binary' + return 'SettingsGradle' @staticmethod def to_json() -> Any: - return 'binary' + return 'SettingsGradle' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class IrrelevantRule: - """Original type: skip_reason = [ ... | Irrelevant_rule | ... ]""" +@dataclass(frozen=True) +class ComposerJson: + """Original type: manifest_kind = [ ... | ComposerJson | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'IrrelevantRule' + return 'ComposerJson' @staticmethod def to_json() -> Any: - return 'irrelevant_rule' + return 'ComposerJson' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class TooManyMatches: - """Original type: skip_reason = [ ... | Too_many_matches | ... ]""" +@dataclass(frozen=True) +class NugetManifestJson: + """Original type: manifest_kind = [ ... | NugetManifestJson | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'TooManyMatches' + return 'NugetManifestJson' @staticmethod def to_json() -> Any: - return 'too_many_matches' + return 'NugetManifestJson' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class GitignorePatternsMatch: - """Original type: skip_reason = [ ... | Gitignore_patterns_match | ... ]""" +@dataclass(frozen=True) +class PubspecYaml: + """Original type: manifest_kind = [ ... | PubspecYaml | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'GitignorePatternsMatch' + return 'PubspecYaml' @staticmethod def to_json() -> Any: - return 'Gitignore_patterns_match' + return 'PubspecYaml' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class Dotfile: - """Original type: skip_reason = [ ... | Dotfile | ... ]""" +@dataclass(frozen=True) +class PackageSwift: + """Original type: manifest_kind = [ ... | PackageSwift | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Dotfile' + return 'PackageSwift' @staticmethod def to_json() -> Any: - return 'Dotfile' + return 'PackageSwift' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class NonexistentFile: - """Original type: skip_reason = [ ... | Nonexistent_file | ... ]""" +@dataclass(frozen=True) +class MixExs: + """Original type: manifest_kind = [ ... | MixExs | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'NonexistentFile' + return 'MixExs' @staticmethod def to_json() -> Any: - return 'Nonexistent_file' + return 'MixExs' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class InsufficientPermissions: - """Original type: skip_reason = [ ... | Insufficient_permissions | ... ]""" +@dataclass(frozen=True) +class Pipfile: + """Original type: manifest_kind = [ ... | Pipfile | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'InsufficientPermissions' + return 'Pipfile' @staticmethod def to_json() -> Any: - return 'insufficient_permissions' + return 'Pipfile' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class SkipReason: - """Original type: skip_reason = [ ... ]""" - - value: Union[AlwaysSkipped, SemgrepignorePatternsMatch, CliIncludeFlagsDoNotMatch, CliExcludeFlagsMatch, ExceededSizeLimit, AnalysisFailedParserOrInternalError, ExcludedByConfig, WrongLanguage, TooBig, Minified, Binary, IrrelevantRule, TooManyMatches, GitignorePatternsMatch, Dotfile, NonexistentFile, InsufficientPermissions] +@dataclass(frozen=True) +class PyprojectToml: + """Original type: manifest_kind = [ ... | PyprojectToml | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return self.value.kind - - @classmethod - def from_json(cls, x: Any) -> 'SkipReason': - if isinstance(x, str): - if x == 'always_skipped': - return cls(AlwaysSkipped()) - if x == 'semgrepignore_patterns_match': - return cls(SemgrepignorePatternsMatch()) - if x == 'cli_include_flags_do_not_match': - return cls(CliIncludeFlagsDoNotMatch()) - if x == 'cli_exclude_flags_match': - return cls(CliExcludeFlagsMatch()) - if x == 'exceeded_size_limit': - return cls(ExceededSizeLimit()) - if x == 'analysis_failed_parser_or_internal_error': - return cls(AnalysisFailedParserOrInternalError()) - if x == 'excluded_by_config': - return cls(ExcludedByConfig()) - if x == 'wrong_language': - return cls(WrongLanguage()) - if x == 'too_big': - return cls(TooBig()) - if x == 'minified': - return cls(Minified()) - if x == 'binary': - return cls(Binary()) - if x == 'irrelevant_rule': - return cls(IrrelevantRule()) - if x == 'too_many_matches': - return cls(TooManyMatches()) - if x == 'Gitignore_patterns_match': - return cls(GitignorePatternsMatch()) - if x == 'Dotfile': - return cls(Dotfile()) - if x == 'Nonexistent_file': - return cls(NonexistentFile()) - if x == 'insufficient_permissions': - return cls(InsufficientPermissions()) - _atd_bad_json('SkipReason', x) - _atd_bad_json('SkipReason', x) - - def to_json(self) -> Any: - return self.value.to_json() + return 'PyprojectToml' - @classmethod - def from_json_string(cls, x: str) -> 'SkipReason': - return cls.from_json(json.loads(x)) + @staticmethod + def to_json() -> Any: + return 'PyprojectToml' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class SkippedTarget: - """Original type: skipped_target = { ... }""" +@dataclass(frozen=True) +class ManifestKind: + """Original type: manifest_kind = [ ... ]""" - path: Fpath - reason: SkipReason - details: Optional[str] = None - rule_id: Optional[RuleId] = None + value: Union[RequirementsIn, PackageJson, Gemfile, GoMod, CargoToml, PomXml, BuildGradle, SettingsGradle, ComposerJson, NugetManifestJson, PubspecYaml, PackageSwift, MixExs, Pipfile, PyprojectToml] - @classmethod - def from_json(cls, x: Any) -> 'SkippedTarget': - if isinstance(x, dict): - return cls( - path=Fpath.from_json(x['path']) if 'path' in x else _atd_missing_json_field('SkippedTarget', 'path'), - reason=SkipReason.from_json(x['reason']) if 'reason' in x else _atd_missing_json_field('SkippedTarget', 'reason'), - details=_atd_read_string(x['details']) if 'details' in x else None, - rule_id=RuleId.from_json(x['rule_id']) if 'rule_id' in x else None, - ) - else: - _atd_bad_json('SkippedTarget', x) + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return self.value.kind - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['path'] = (lambda x: x.to_json())(self.path) - res['reason'] = (lambda x: x.to_json())(self.reason) - if self.details is not None: - res['details'] = _atd_write_string(self.details) - if self.rule_id is not None: - res['rule_id'] = (lambda x: x.to_json())(self.rule_id) - return res + @classmethod + def from_json(cls, x: Any) -> 'ManifestKind': + if isinstance(x, str): + if x == 'RequirementsIn': + return cls(RequirementsIn()) + if x == 'PackageJson': + return cls(PackageJson()) + if x == 'Gemfile': + return cls(Gemfile()) + if x == 'GoMod': + return cls(GoMod()) + if x == 'CargoToml': + return cls(CargoToml()) + if x == 'PomXml': + return cls(PomXml()) + if x == 'BuildGradle': + return cls(BuildGradle()) + if x == 'SettingsGradle': + return cls(SettingsGradle()) + if x == 'ComposerJson': + return cls(ComposerJson()) + if x == 'NugetManifestJson': + return cls(NugetManifestJson()) + if x == 'PubspecYaml': + return cls(PubspecYaml()) + if x == 'PackageSwift': + return cls(PackageSwift()) + if x == 'MixExs': + return cls(MixExs()) + if x == 'Pipfile': + return cls(Pipfile()) + if x == 'PyprojectToml': + return cls(PyprojectToml()) + _atd_bad_json('ManifestKind', x) + _atd_bad_json('ManifestKind', x) + + def to_json(self) -> Any: + return self.value.to_json() @classmethod - def from_json_string(cls, x: str) -> 'SkippedTarget': + def from_json_string(cls, x: str) -> 'ManifestKind': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class SkippedRule: - """Original type: skipped_rule = { ... }""" - - rule_id: RuleId - details: str - position: Position - - @classmethod - def from_json(cls, x: Any) -> 'SkippedRule': - if isinstance(x, dict): - return cls( - rule_id=RuleId.from_json(x['rule_id']) if 'rule_id' in x else _atd_missing_json_field('SkippedRule', 'rule_id'), - details=_atd_read_string(x['details']) if 'details' in x else _atd_missing_json_field('SkippedRule', 'details'), - position=Position.from_json(x['position']) if 'position' in x else _atd_missing_json_field('SkippedRule', 'position'), - ) - else: - _atd_bad_json('SkippedRule', x) +@dataclass(frozen=True) +class PipRequirementsTxt: + """Original type: lockfile_kind = [ ... | PipRequirementsTxt | ... ]""" - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['rule_id'] = (lambda x: x.to_json())(self.rule_id) - res['details'] = _atd_write_string(self.details) - res['position'] = (lambda x: x.to_json())(self.position) - return res + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'PipRequirementsTxt' - @classmethod - def from_json_string(cls, x: str) -> 'SkippedRule': - return cls.from_json(json.loads(x)) + @staticmethod + def to_json() -> Any: + return 'PipRequirementsTxt' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class ScannedAndSkipped: - """Original type: scanned_and_skipped = { ... }""" - - scanned: List[Fpath] - skipped: Optional[List[SkippedTarget]] = None - - @classmethod - def from_json(cls, x: Any) -> 'ScannedAndSkipped': - if isinstance(x, dict): - return cls( - scanned=_atd_read_list(Fpath.from_json)(x['scanned']) if 'scanned' in x else _atd_missing_json_field('ScannedAndSkipped', 'scanned'), - skipped=_atd_read_list(SkippedTarget.from_json)(x['skipped']) if 'skipped' in x else None, - ) - else: - _atd_bad_json('ScannedAndSkipped', x) +@dataclass(frozen=True) +class PoetryLock: + """Original type: lockfile_kind = [ ... | PoetryLock | ... ]""" - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['scanned'] = _atd_write_list((lambda x: x.to_json()))(self.scanned) - if self.skipped is not None: - res['skipped'] = _atd_write_list((lambda x: x.to_json()))(self.skipped) - return res + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'PoetryLock' - @classmethod - def from_json_string(cls, x: str) -> 'ScannedAndSkipped': - return cls.from_json(json.loads(x)) + @staticmethod + def to_json() -> Any: + return 'PoetryLock' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class SAST: - """Original type: product = [ ... | SAST | ... ]""" +class PipfileLock: + """Original type: lockfile_kind = [ ... | PipfileLock | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'SAST' + return 'PipfileLock' @staticmethod def to_json() -> Any: - return 'sast' + return 'PipfileLock' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class SCA: - """Original type: product = [ ... | SCA | ... ]""" +class NpmPackageLockJson: + """Original type: lockfile_kind = [ ... | NpmPackageLockJson | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'SCA' + return 'NpmPackageLockJson' @staticmethod def to_json() -> Any: - return 'sca' + return 'NpmPackageLockJson' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class Secrets: - """Original type: product = [ ... | Secrets | ... ]""" +class YarnLock: + """Original type: lockfile_kind = [ ... | YarnLock | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Secrets' + return 'YarnLock' @staticmethod def to_json() -> Any: - return 'secrets' + return 'YarnLock' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class Product: - """Original type: product = [ ... ]""" - - value: Union[SAST, SCA, Secrets] +class PnpmLock: + """Original type: lockfile_kind = [ ... | PnpmLock | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return self.value.kind - - @classmethod - def from_json(cls, x: Any) -> 'Product': - if isinstance(x, str): - if x == 'sast': - return cls(SAST()) - if x == 'sca': - return cls(SCA()) - if x == 'secrets': - return cls(Secrets()) - _atd_bad_json('Product', x) - _atd_bad_json('Product', x) - - def to_json(self) -> Any: - return self.value.to_json() + return 'PnpmLock' - @classmethod - def from_json_string(cls, x: str) -> 'Product': - return cls.from_json(json.loads(x)) + @staticmethod + def to_json() -> Any: + return 'PnpmLock' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class ScanInfo: - """Original type: scan_info = { ... }""" - - enabled_products: List[Product] - deployment_id: int - deployment_name: str - id: Optional[int] = None - - @classmethod - def from_json(cls, x: Any) -> 'ScanInfo': - if isinstance(x, dict): - return cls( - enabled_products=_atd_read_list(Product.from_json)(x['enabled_products']) if 'enabled_products' in x else _atd_missing_json_field('ScanInfo', 'enabled_products'), - deployment_id=_atd_read_int(x['deployment_id']) if 'deployment_id' in x else _atd_missing_json_field('ScanInfo', 'deployment_id'), - deployment_name=_atd_read_string(x['deployment_name']) if 'deployment_name' in x else _atd_missing_json_field('ScanInfo', 'deployment_name'), - id=_atd_read_int(x['id']) if 'id' in x else None, - ) - else: - _atd_bad_json('ScanInfo', x) +@dataclass(frozen=True) +class GemfileLock: + """Original type: lockfile_kind = [ ... | GemfileLock | ... ]""" - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['enabled_products'] = _atd_write_list((lambda x: x.to_json()))(self.enabled_products) - res['deployment_id'] = _atd_write_int(self.deployment_id) - res['deployment_name'] = _atd_write_string(self.deployment_name) - if self.id is not None: - res['id'] = _atd_write_int(self.id) - return res + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'GemfileLock' - @classmethod - def from_json_string(cls, x: str) -> 'ScanInfo': - return cls.from_json(json.loads(x)) + @staticmethod + def to_json() -> Any: + return 'GemfileLock' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class ScanConfiguration: - """Original type: scan_configuration = { ... }""" - - rules: RawJson - triage_ignored_syntactic_ids: List[str] = field(default_factory=lambda: []) - triage_ignored_match_based_ids: List[str] = field(default_factory=lambda: []) - - @classmethod - def from_json(cls, x: Any) -> 'ScanConfiguration': - if isinstance(x, dict): - return cls( - rules=RawJson.from_json(x['rules']) if 'rules' in x else _atd_missing_json_field('ScanConfiguration', 'rules'), - triage_ignored_syntactic_ids=_atd_read_list(_atd_read_string)(x['triage_ignored_syntactic_ids']) if 'triage_ignored_syntactic_ids' in x else [], - triage_ignored_match_based_ids=_atd_read_list(_atd_read_string)(x['triage_ignored_match_based_ids']) if 'triage_ignored_match_based_ids' in x else [], - ) - else: - _atd_bad_json('ScanConfiguration', x) +@dataclass(frozen=True) +class GoMod_: + """Original type: lockfile_kind = [ ... | GoMod | ... ]""" - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['rules'] = (lambda x: x.to_json())(self.rules) - res['triage_ignored_syntactic_ids'] = _atd_write_list(_atd_write_string)(self.triage_ignored_syntactic_ids) - res['triage_ignored_match_based_ids'] = _atd_write_list(_atd_write_string)(self.triage_ignored_match_based_ids) - return res + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'GoMod_' - @classmethod - def from_json_string(cls, x: str) -> 'ScanConfiguration': - return cls.from_json(json.loads(x)) + @staticmethod + def to_json() -> Any: + return 'GoMod' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class Glob: - """Original type: glob""" +@dataclass(frozen=True) +class CargoLock: + """Original type: lockfile_kind = [ ... | CargoLock | ... ]""" - value: str + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'CargoLock' - @classmethod - def from_json(cls, x: Any) -> 'Glob': - return cls(_atd_read_string(x)) + @staticmethod + def to_json() -> Any: + return 'CargoLock' - def to_json(self) -> Any: - return _atd_write_string(self.value) + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) - @classmethod - def from_json_string(cls, x: str) -> 'Glob': - return cls.from_json(json.loads(x)) + +@dataclass(frozen=True) +class MavenDepTree: + """Original type: lockfile_kind = [ ... | MavenDepTree | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'MavenDepTree' + + @staticmethod + def to_json() -> Any: + return 'MavenDepTree' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class ProductIgnoredFiles: - """Original type: product_ignored_files""" +@dataclass(frozen=True) +class GradleLockfile: + """Original type: lockfile_kind = [ ... | GradleLockfile | ... ]""" - value: Dict[Product, List[Glob]] + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'GradleLockfile' - @classmethod - def from_json(cls, x: Any) -> 'ProductIgnoredFiles': - return cls(_atd_read_assoc_array_into_dict(Product.from_json, _atd_read_list(Glob.from_json))(x)) + @staticmethod + def to_json() -> Any: + return 'GradleLockfile' - def to_json(self) -> Any: - return _atd_write_assoc_dict_to_array((lambda x: x.to_json()), _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) - @classmethod - def from_json_string(cls, x: str) -> 'ProductIgnoredFiles': - return cls.from_json(json.loads(x)) + +@dataclass(frozen=True) +class ComposerLock: + """Original type: lockfile_kind = [ ... | ComposerLock | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'ComposerLock' + + @staticmethod + def to_json() -> Any: + return 'ComposerLock' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class HistoricalConfiguration: - """Original type: historical_configuration = { ... }""" +@dataclass(frozen=True) +class NugetPackagesLockJson: + """Original type: lockfile_kind = [ ... | NugetPackagesLockJson | ... ]""" - enabled: bool - lookback_days: Optional[int] = None + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'NugetPackagesLockJson' - @classmethod - def from_json(cls, x: Any) -> 'HistoricalConfiguration': - if isinstance(x, dict): - return cls( - enabled=_atd_read_bool(x['enabled']) if 'enabled' in x else _atd_missing_json_field('HistoricalConfiguration', 'enabled'), - lookback_days=_atd_read_int(x['lookback_days']) if 'lookback_days' in x else None, - ) - else: - _atd_bad_json('HistoricalConfiguration', x) + @staticmethod + def to_json() -> Any: + return 'NugetPackagesLockJson' - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['enabled'] = _atd_write_bool(self.enabled) - if self.lookback_days is not None: - res['lookback_days'] = _atd_write_int(self.lookback_days) - return res + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) - @classmethod - def from_json_string(cls, x: str) -> 'HistoricalConfiguration': - return cls.from_json(json.loads(x)) + +@dataclass(frozen=True) +class PubspecLock: + """Original type: lockfile_kind = [ ... | PubspecLock | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'PubspecLock' + + @staticmethod + def to_json() -> Any: + return 'PubspecLock' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class EngineConfiguration: - """Original type: engine_configuration = { ... }""" +@dataclass(frozen=True) +class SwiftPackageResolved: + """Original type: lockfile_kind = [ ... | SwiftPackageResolved | ... ]""" - autofix: bool = field(default_factory=lambda: False) - deepsemgrep: bool = field(default_factory=lambda: False) - dependency_query: bool = field(default_factory=lambda: False) - path_to_transitivity: bool = field(default_factory=lambda: False) - ignored_files: List[str] = field(default_factory=lambda: []) - product_ignored_files: Optional[ProductIgnoredFiles] = None - generic_slow_rollout: bool = field(default_factory=lambda: False) - historical_config: Optional[HistoricalConfiguration] = None - always_suppress_errors: bool = field(default_factory=lambda: False) + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'SwiftPackageResolved' - @classmethod - def from_json(cls, x: Any) -> 'EngineConfiguration': - if isinstance(x, dict): - return cls( - autofix=_atd_read_bool(x['autofix']) if 'autofix' in x else False, - deepsemgrep=_atd_read_bool(x['deepsemgrep']) if 'deepsemgrep' in x else False, - dependency_query=_atd_read_bool(x['dependency_query']) if 'dependency_query' in x else False, - path_to_transitivity=_atd_read_bool(x['path_to_transitivity']) if 'path_to_transitivity' in x else False, - ignored_files=_atd_read_list(_atd_read_string)(x['ignored_files']) if 'ignored_files' in x else [], - product_ignored_files=ProductIgnoredFiles.from_json(x['product_ignored_files']) if 'product_ignored_files' in x else None, - generic_slow_rollout=_atd_read_bool(x['generic_slow_rollout']) if 'generic_slow_rollout' in x else False, - historical_config=HistoricalConfiguration.from_json(x['historical_config']) if 'historical_config' in x else None, - always_suppress_errors=_atd_read_bool(x['always_suppress_errors']) if 'always_suppress_errors' in x else False, - ) - else: - _atd_bad_json('EngineConfiguration', x) + @staticmethod + def to_json() -> Any: + return 'SwiftPackageResolved' - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['autofix'] = _atd_write_bool(self.autofix) - res['deepsemgrep'] = _atd_write_bool(self.deepsemgrep) - res['dependency_query'] = _atd_write_bool(self.dependency_query) - res['path_to_transitivity'] = _atd_write_bool(self.path_to_transitivity) - res['ignored_files'] = _atd_write_list(_atd_write_string)(self.ignored_files) - if self.product_ignored_files is not None: - res['product_ignored_files'] = (lambda x: x.to_json())(self.product_ignored_files) - res['generic_slow_rollout'] = _atd_write_bool(self.generic_slow_rollout) - if self.historical_config is not None: - res['historical_config'] = (lambda x: x.to_json())(self.historical_config) - res['always_suppress_errors'] = _atd_write_bool(self.always_suppress_errors) - return res + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) - @classmethod - def from_json_string(cls, x: str) -> 'EngineConfiguration': - return cls.from_json(json.loads(x)) + +@dataclass(frozen=True) +class MixLock: + """Original type: lockfile_kind = [ ... | MixLock | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'MixLock' + + @staticmethod + def to_json() -> Any: + return 'MixLock' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class ScanResponse: - """Original type: scan_response = { ... }""" +@dataclass(frozen=True) +class LockfileKind: + """Original type: lockfile_kind = [ ... ]""" - info: ScanInfo - config: ScanConfiguration - engine_params: EngineConfiguration + value: Union[PipRequirementsTxt, PoetryLock, PipfileLock, NpmPackageLockJson, YarnLock, PnpmLock, GemfileLock, GoMod_, CargoLock, MavenDepTree, GradleLockfile, ComposerLock, NugetPackagesLockJson, PubspecLock, SwiftPackageResolved, MixLock] + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return self.value.kind @classmethod - def from_json(cls, x: Any) -> 'ScanResponse': - if isinstance(x, dict): - return cls( - info=ScanInfo.from_json(x['info']) if 'info' in x else _atd_missing_json_field('ScanResponse', 'info'), - config=ScanConfiguration.from_json(x['config']) if 'config' in x else _atd_missing_json_field('ScanResponse', 'config'), - engine_params=EngineConfiguration.from_json(x['engine_params']) if 'engine_params' in x else _atd_missing_json_field('ScanResponse', 'engine_params'), - ) - else: - _atd_bad_json('ScanResponse', x) + def from_json(cls, x: Any) -> 'LockfileKind': + if isinstance(x, str): + if x == 'PipRequirementsTxt': + return cls(PipRequirementsTxt()) + if x == 'PoetryLock': + return cls(PoetryLock()) + if x == 'PipfileLock': + return cls(PipfileLock()) + if x == 'NpmPackageLockJson': + return cls(NpmPackageLockJson()) + if x == 'YarnLock': + return cls(YarnLock()) + if x == 'PnpmLock': + return cls(PnpmLock()) + if x == 'GemfileLock': + return cls(GemfileLock()) + if x == 'GoMod': + return cls(GoMod_()) + if x == 'CargoLock': + return cls(CargoLock()) + if x == 'MavenDepTree': + return cls(MavenDepTree()) + if x == 'GradleLockfile': + return cls(GradleLockfile()) + if x == 'ComposerLock': + return cls(ComposerLock()) + if x == 'NugetPackagesLockJson': + return cls(NugetPackagesLockJson()) + if x == 'PubspecLock': + return cls(PubspecLock()) + if x == 'SwiftPackageResolved': + return cls(SwiftPackageResolved()) + if x == 'MixLock': + return cls(MixLock()) + _atd_bad_json('LockfileKind', x) + _atd_bad_json('LockfileKind', x) def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['info'] = (lambda x: x.to_json())(self.info) - res['config'] = (lambda x: x.to_json())(self.config) - res['engine_params'] = (lambda x: x.to_json())(self.engine_params) - return res + return self.value.to_json() @classmethod - def from_json_string(cls, x: str) -> 'ScanResponse': + def from_json_string(cls, x: str) -> 'LockfileKind': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class ScanMetadata: - """Original type: scan_metadata = { ... }""" +@dataclass(frozen=True) +class Npm: + """Original type: ecosystem = [ ... | Npm | ... ]""" - cli_version: Version - unique_id: Uuid - requested_products: List[Product] - dry_run: bool = field(default_factory=lambda: False) - sms_scan_id: Optional[str] = None + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'Npm' - @classmethod - def from_json(cls, x: Any) -> 'ScanMetadata': - if isinstance(x, dict): - return cls( - cli_version=Version.from_json(x['cli_version']) if 'cli_version' in x else _atd_missing_json_field('ScanMetadata', 'cli_version'), - unique_id=Uuid.from_json(x['unique_id']) if 'unique_id' in x else _atd_missing_json_field('ScanMetadata', 'unique_id'), - requested_products=_atd_read_list(Product.from_json)(x['requested_products']) if 'requested_products' in x else _atd_missing_json_field('ScanMetadata', 'requested_products'), - dry_run=_atd_read_bool(x['dry_run']) if 'dry_run' in x else False, - sms_scan_id=_atd_read_string(x['sms_scan_id']) if 'sms_scan_id' in x else None, - ) - else: - _atd_bad_json('ScanMetadata', x) + @staticmethod + def to_json() -> Any: + return 'npm' - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['cli_version'] = (lambda x: x.to_json())(self.cli_version) - res['unique_id'] = (lambda x: x.to_json())(self.unique_id) - res['requested_products'] = _atd_write_list((lambda x: x.to_json()))(self.requested_products) - res['dry_run'] = _atd_write_bool(self.dry_run) - if self.sms_scan_id is not None: - res['sms_scan_id'] = _atd_write_string(self.sms_scan_id) - return res + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) - @classmethod - def from_json_string(cls, x: str) -> 'ScanMetadata': - return cls.from_json(json.loads(x)) + +@dataclass(frozen=True) +class Pypi: + """Original type: ecosystem = [ ... | Pypi | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'Pypi' + + @staticmethod + def to_json() -> Any: + return 'pypi' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class ProjectMetadata: - """Original type: project_metadata = { ... }""" +@dataclass(frozen=True) +class Gem: + """Original type: ecosystem = [ ... | Gem | ... ]""" - semgrep_version: Version - scan_environment: str - repository: str - repo_url: Optional[Uri] - branch: Optional[str] - commit: Optional[Sha1] - commit_title: Optional[str] - commit_author_email: Optional[str] - commit_author_name: Optional[str] - commit_author_username: Optional[str] - commit_author_image_url: Optional[Uri] - ci_job_url: Optional[Uri] - on: str - pull_request_author_username: Optional[str] - pull_request_author_image_url: Optional[Uri] - pull_request_id: Optional[str] - pull_request_title: Optional[str] - is_full_scan: bool - repo_id: Optional[str] = None - org_id: Optional[str] = None - repo_display_name: Optional[str] = None - commit_timestamp: Optional[Datetime] = None - base_sha: Optional[Sha1] = None - start_sha: Optional[Sha1] = None - is_sca_scan: Optional[bool] = None - is_code_scan: Optional[bool] = None - is_secrets_scan: Optional[bool] = None + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'Gem' - @classmethod - def from_json(cls, x: Any) -> 'ProjectMetadata': - if isinstance(x, dict): - return cls( - semgrep_version=Version.from_json(x['semgrep_version']) if 'semgrep_version' in x else _atd_missing_json_field('ProjectMetadata', 'semgrep_version'), - scan_environment=_atd_read_string(x['scan_environment']) if 'scan_environment' in x else _atd_missing_json_field('ProjectMetadata', 'scan_environment'), - repository=_atd_read_string(x['repository']) if 'repository' in x else _atd_missing_json_field('ProjectMetadata', 'repository'), - repo_url=_atd_read_nullable(Uri.from_json)(x['repo_url']) if 'repo_url' in x else _atd_missing_json_field('ProjectMetadata', 'repo_url'), - branch=_atd_read_nullable(_atd_read_string)(x['branch']) if 'branch' in x else _atd_missing_json_field('ProjectMetadata', 'branch'), - commit=_atd_read_nullable(Sha1.from_json)(x['commit']) if 'commit' in x else _atd_missing_json_field('ProjectMetadata', 'commit'), - commit_title=_atd_read_nullable(_atd_read_string)(x['commit_title']) if 'commit_title' in x else _atd_missing_json_field('ProjectMetadata', 'commit_title'), - commit_author_email=_atd_read_nullable(_atd_read_string)(x['commit_author_email']) if 'commit_author_email' in x else _atd_missing_json_field('ProjectMetadata', 'commit_author_email'), - commit_author_name=_atd_read_nullable(_atd_read_string)(x['commit_author_name']) if 'commit_author_name' in x else _atd_missing_json_field('ProjectMetadata', 'commit_author_name'), - commit_author_username=_atd_read_nullable(_atd_read_string)(x['commit_author_username']) if 'commit_author_username' in x else _atd_missing_json_field('ProjectMetadata', 'commit_author_username'), - commit_author_image_url=_atd_read_nullable(Uri.from_json)(x['commit_author_image_url']) if 'commit_author_image_url' in x else _atd_missing_json_field('ProjectMetadata', 'commit_author_image_url'), - ci_job_url=_atd_read_nullable(Uri.from_json)(x['ci_job_url']) if 'ci_job_url' in x else _atd_missing_json_field('ProjectMetadata', 'ci_job_url'), - on=_atd_read_string(x['on']) if 'on' in x else _atd_missing_json_field('ProjectMetadata', 'on'), - pull_request_author_username=_atd_read_nullable(_atd_read_string)(x['pull_request_author_username']) if 'pull_request_author_username' in x else _atd_missing_json_field('ProjectMetadata', 'pull_request_author_username'), - pull_request_author_image_url=_atd_read_nullable(Uri.from_json)(x['pull_request_author_image_url']) if 'pull_request_author_image_url' in x else _atd_missing_json_field('ProjectMetadata', 'pull_request_author_image_url'), - pull_request_id=_atd_read_nullable(_atd_read_string)(x['pull_request_id']) if 'pull_request_id' in x else _atd_missing_json_field('ProjectMetadata', 'pull_request_id'), - pull_request_title=_atd_read_nullable(_atd_read_string)(x['pull_request_title']) if 'pull_request_title' in x else _atd_missing_json_field('ProjectMetadata', 'pull_request_title'), - is_full_scan=_atd_read_bool(x['is_full_scan']) if 'is_full_scan' in x else _atd_missing_json_field('ProjectMetadata', 'is_full_scan'), - repo_id=_atd_read_string(x['repo_id']) if 'repo_id' in x else None, - org_id=_atd_read_string(x['org_id']) if 'org_id' in x else None, - repo_display_name=_atd_read_string(x['repo_display_name']) if 'repo_display_name' in x else None, - commit_timestamp=Datetime.from_json(x['commit_timestamp']) if 'commit_timestamp' in x else None, - base_sha=Sha1.from_json(x['base_sha']) if 'base_sha' in x else None, - start_sha=Sha1.from_json(x['start_sha']) if 'start_sha' in x else None, - is_sca_scan=_atd_read_bool(x['is_sca_scan']) if 'is_sca_scan' in x else None, - is_code_scan=_atd_read_bool(x['is_code_scan']) if 'is_code_scan' in x else None, - is_secrets_scan=_atd_read_bool(x['is_secrets_scan']) if 'is_secrets_scan' in x else None, - ) - else: - _atd_bad_json('ProjectMetadata', x) + @staticmethod + def to_json() -> Any: + return 'gem' - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['semgrep_version'] = (lambda x: x.to_json())(self.semgrep_version) - res['scan_environment'] = _atd_write_string(self.scan_environment) - res['repository'] = _atd_write_string(self.repository) - res['repo_url'] = _atd_write_nullable((lambda x: x.to_json()))(self.repo_url) - res['branch'] = _atd_write_nullable(_atd_write_string)(self.branch) - res['commit'] = _atd_write_nullable((lambda x: x.to_json()))(self.commit) - res['commit_title'] = _atd_write_nullable(_atd_write_string)(self.commit_title) - res['commit_author_email'] = _atd_write_nullable(_atd_write_string)(self.commit_author_email) - res['commit_author_name'] = _atd_write_nullable(_atd_write_string)(self.commit_author_name) - res['commit_author_username'] = _atd_write_nullable(_atd_write_string)(self.commit_author_username) - res['commit_author_image_url'] = _atd_write_nullable((lambda x: x.to_json()))(self.commit_author_image_url) - res['ci_job_url'] = _atd_write_nullable((lambda x: x.to_json()))(self.ci_job_url) - res['on'] = _atd_write_string(self.on) - res['pull_request_author_username'] = _atd_write_nullable(_atd_write_string)(self.pull_request_author_username) - res['pull_request_author_image_url'] = _atd_write_nullable((lambda x: x.to_json()))(self.pull_request_author_image_url) - res['pull_request_id'] = _atd_write_nullable(_atd_write_string)(self.pull_request_id) - res['pull_request_title'] = _atd_write_nullable(_atd_write_string)(self.pull_request_title) - res['is_full_scan'] = _atd_write_bool(self.is_full_scan) - if self.repo_id is not None: - res['repo_id'] = _atd_write_string(self.repo_id) - if self.org_id is not None: - res['org_id'] = _atd_write_string(self.org_id) - if self.repo_display_name is not None: - res['repo_display_name'] = _atd_write_string(self.repo_display_name) - if self.commit_timestamp is not None: - res['commit_timestamp'] = (lambda x: x.to_json())(self.commit_timestamp) - if self.base_sha is not None: - res['base_sha'] = (lambda x: x.to_json())(self.base_sha) - if self.start_sha is not None: - res['start_sha'] = (lambda x: x.to_json())(self.start_sha) - if self.is_sca_scan is not None: - res['is_sca_scan'] = _atd_write_bool(self.is_sca_scan) - if self.is_code_scan is not None: - res['is_code_scan'] = _atd_write_bool(self.is_code_scan) - if self.is_secrets_scan is not None: - res['is_secrets_scan'] = _atd_write_bool(self.is_secrets_scan) - return res + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) - @classmethod - def from_json_string(cls, x: str) -> 'ProjectMetadata': - return cls.from_json(json.loads(x)) + +@dataclass(frozen=True) +class Gomod: + """Original type: ecosystem = [ ... | Gomod | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'Gomod' + + @staticmethod + def to_json() -> Any: + return 'gomod' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class CiConfigFromRepo: - """Original type: ci_config_from_repo = { ... }""" +@dataclass(frozen=True) +class Cargo: + """Original type: ecosystem = [ ... | Cargo | ... ]""" - version: Version = field(default_factory=lambda: Version('v1')) - tags: Optional[List[Tag]] = None + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'Cargo' - @classmethod - def from_json(cls, x: Any) -> 'CiConfigFromRepo': - if isinstance(x, dict): - return cls( - version=Version.from_json(x['version']) if 'version' in x else Version('v1'), - tags=_atd_read_list(Tag.from_json)(x['tags']) if 'tags' in x else None, - ) - else: - _atd_bad_json('CiConfigFromRepo', x) + @staticmethod + def to_json() -> Any: + return 'cargo' - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['version'] = (lambda x: x.to_json())(self.version) - if self.tags is not None: - res['tags'] = _atd_write_list((lambda x: x.to_json()))(self.tags) - return res + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) - @classmethod - def from_json_string(cls, x: str) -> 'CiConfigFromRepo': - return cls.from_json(json.loads(x)) + +@dataclass(frozen=True) +class Maven: + """Original type: ecosystem = [ ... | Maven | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'Maven' + + @staticmethod + def to_json() -> Any: + return 'maven' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class ScanRequest: - """Original type: scan_request = { ... }""" +@dataclass(frozen=True) +class Composer: + """Original type: ecosystem = [ ... | Composer | ... ]""" - meta: RawJson - project_metadata: Optional[ProjectMetadata] = None - project_config: Optional[CiConfigFromRepo] = None - scan_metadata: Optional[ScanMetadata] = None + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'Composer' - @classmethod - def from_json(cls, x: Any) -> 'ScanRequest': - if isinstance(x, dict): - return cls( - meta=RawJson.from_json(x['meta']) if 'meta' in x else _atd_missing_json_field('ScanRequest', 'meta'), - project_metadata=ProjectMetadata.from_json(x['project_metadata']) if 'project_metadata' in x else None, - project_config=CiConfigFromRepo.from_json(x['project_config']) if 'project_config' in x else None, - scan_metadata=ScanMetadata.from_json(x['scan_metadata']) if 'scan_metadata' in x else None, - ) - else: - _atd_bad_json('ScanRequest', x) + @staticmethod + def to_json() -> Any: + return 'composer' - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['meta'] = (lambda x: x.to_json())(self.meta) - if self.project_metadata is not None: - res['project_metadata'] = (lambda x: x.to_json())(self.project_metadata) - if self.project_config is not None: - res['project_config'] = (lambda x: x.to_json())(self.project_config) - if self.scan_metadata is not None: - res['scan_metadata'] = (lambda x: x.to_json())(self.scan_metadata) - return res + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) - @classmethod - def from_json_string(cls, x: str) -> 'ScanRequest': - return cls.from_json(json.loads(x)) + +@dataclass(frozen=True) +class Nuget: + """Original type: ecosystem = [ ... | Nuget | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'Nuget' + + @staticmethod + def to_json() -> Any: + return 'nuget' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class CiEnv: - """Original type: ci_env""" +@dataclass(frozen=True) +class Pub: + """Original type: ecosystem = [ ... | Pub | ... ]""" - value: Dict[str, str] + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'Pub' - @classmethod - def from_json(cls, x: Any) -> 'CiEnv': - return cls(_atd_read_assoc_object_into_dict(_atd_read_string)(x)) + @staticmethod + def to_json() -> Any: + return 'pub' - def to_json(self) -> Any: - return _atd_write_assoc_dict_to_object(_atd_write_string)(self.value) + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) - @classmethod - def from_json_string(cls, x: str) -> 'CiEnv': - return cls.from_json(json.loads(x)) + +@dataclass(frozen=True) +class SwiftPM: + """Original type: ecosystem = [ ... | SwiftPM | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'SwiftPM' + + @staticmethod + def to_json() -> Any: + return 'swiftpm' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class CiConfig: - """Original type: ci_config = { ... }""" +@dataclass(frozen=True) +class Mix: + """Original type: ecosystem = [ ... | Mix | ... ]""" - env: CiEnv - enabled_products: List[Product] - ignored_files: List[str] - autofix: bool = field(default_factory=lambda: False) - deepsemgrep: bool = field(default_factory=lambda: False) - dependency_query: bool = field(default_factory=lambda: False) - path_to_transitivity: bool = field(default_factory=lambda: False) + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'Mix' - @classmethod - def from_json(cls, x: Any) -> 'CiConfig': - if isinstance(x, dict): - return cls( - env=CiEnv.from_json(x['env']) if 'env' in x else _atd_missing_json_field('CiConfig', 'env'), - enabled_products=_atd_read_list(Product.from_json)(x['enabled_products']) if 'enabled_products' in x else _atd_missing_json_field('CiConfig', 'enabled_products'), - ignored_files=_atd_read_list(_atd_read_string)(x['ignored_files']) if 'ignored_files' in x else _atd_missing_json_field('CiConfig', 'ignored_files'), - autofix=_atd_read_bool(x['autofix']) if 'autofix' in x else False, - deepsemgrep=_atd_read_bool(x['deepsemgrep']) if 'deepsemgrep' in x else False, - dependency_query=_atd_read_bool(x['dependency_query']) if 'dependency_query' in x else False, - path_to_transitivity=_atd_read_bool(x['path_to_transitivity']) if 'path_to_transitivity' in x else False, - ) - else: - _atd_bad_json('CiConfig', x) + @staticmethod + def to_json() -> Any: + return 'mix' + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass(frozen=True) +class Hex: + """Original type: ecosystem = [ ... | Hex | ... ]""" - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['env'] = (lambda x: x.to_json())(self.env) - res['enabled_products'] = _atd_write_list((lambda x: x.to_json()))(self.enabled_products) - res['ignored_files'] = _atd_write_list(_atd_write_string)(self.ignored_files) - res['autofix'] = _atd_write_bool(self.autofix) - res['deepsemgrep'] = _atd_write_bool(self.deepsemgrep) - res['dependency_query'] = _atd_write_bool(self.dependency_query) - res['path_to_transitivity'] = _atd_write_bool(self.path_to_transitivity) - return res + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'Hex' - @classmethod - def from_json_string(cls, x: str) -> 'CiConfig': - return cls.from_json(json.loads(x)) + @staticmethod + def to_json() -> Any: + return 'hex' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class Message: - """Original type: action = [ ... | Message of ... | ... ]""" +@dataclass(frozen=True) +class Ecosystem: + """Original type: ecosystem = [ ... ]""" - value: str + value: Union[Npm, Pypi, Gem, Gomod, Cargo, Maven, Composer, Nuget, Pub, SwiftPM, Mix, Hex] @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Message' + return self.value.kind + + @classmethod + def from_json(cls, x: Any) -> 'Ecosystem': + if isinstance(x, str): + if x == 'npm': + return cls(Npm()) + if x == 'pypi': + return cls(Pypi()) + if x == 'gem': + return cls(Gem()) + if x == 'gomod': + return cls(Gomod()) + if x == 'cargo': + return cls(Cargo()) + if x == 'maven': + return cls(Maven()) + if x == 'composer': + return cls(Composer()) + if x == 'nuget': + return cls(Nuget()) + if x == 'pub': + return cls(Pub()) + if x == 'swiftpm': + return cls(SwiftPM()) + if x == 'mix': + return cls(Mix()) + if x == 'hex': + return cls(Hex()) + _atd_bad_json('Ecosystem', x) + _atd_bad_json('Ecosystem', x) def to_json(self) -> Any: - return ['Message', _atd_write_string(self.value)] + return self.value.to_json() + + @classmethod + def from_json_string(cls, x: str) -> 'Ecosystem': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class Delay: - """Original type: action = [ ... | Delay of ... | ... ]""" +@dataclass(frozen=True) +class Lockfile_: + """Original type: dependency_source_file_kind = [ ... | Lockfile of ... | ... ]""" - value: float + value: LockfileKind @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Delay' + return 'Lockfile_' def to_json(self) -> Any: - return ['Delay', _atd_write_float(self.value)] + return ['Lockfile', (lambda x: x.to_json())(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class Exit: - """Original type: action = [ ... | Exit of ... | ... ]""" +@dataclass(frozen=True) +class Manifest_: + """Original type: dependency_source_file_kind = [ ... | Manifest of ... | ... ]""" - value: int + value: ManifestKind @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Exit' + return 'Manifest_' def to_json(self) -> Any: - return ['Exit', _atd_write_int(self.value)] + return ['Manifest', (lambda x: x.to_json())(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class Action: - """Original type: action = [ ... ]""" +@dataclass(frozen=True) +class DependencySourceFileKind: + """Original type: dependency_source_file_kind = [ ... ]""" - value: Union[Message, Delay, Exit] + value: Union[Lockfile_, Manifest_] @property def kind(self) -> str: @@ -3653,23 +3532,21 @@ def kind(self) -> str: return self.value.kind @classmethod - def from_json(cls, x: Any) -> 'Action': + def from_json(cls, x: Any) -> 'DependencySourceFileKind': if isinstance(x, List) and len(x) == 2: cons = x[0] - if cons == 'Message': - return cls(Message(_atd_read_string(x[1]))) - if cons == 'Delay': - return cls(Delay(_atd_read_float(x[1]))) - if cons == 'Exit': - return cls(Exit(_atd_read_int(x[1]))) - _atd_bad_json('Action', x) - _atd_bad_json('Action', x) + if cons == 'Lockfile': + return cls(Lockfile_(LockfileKind.from_json(x[1]))) + if cons == 'Manifest': + return cls(Manifest_(ManifestKind.from_json(x[1]))) + _atd_bad_json('DependencySourceFileKind', x) + _atd_bad_json('DependencySourceFileKind', x) def to_json(self) -> Any: return self.value.to_json() @classmethod - def from_json_string(cls, x: str) -> 'Action': + def from_json_string(cls, x: str) -> 'DependencySourceFileKind': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: @@ -3677,38 +3554,30 @@ def to_json_string(self, **kw: Any) -> str: @dataclass -class CiConfigFromCloud: - """Original type: ci_config_from_cloud = { ... }""" +class DependencySourceFile: + """Original type: dependency_source_file = { ... }""" - repo_config: CiConfig - org_config: Optional[CiConfig] = None - dirs_config: Optional[List[Tuple[Fpath, CiConfig]]] = None - actions: List[Action] = field(default_factory=lambda: []) + kind: DependencySourceFileKind + path: Fpath @classmethod - def from_json(cls, x: Any) -> 'CiConfigFromCloud': + def from_json(cls, x: Any) -> 'DependencySourceFile': if isinstance(x, dict): return cls( - repo_config=CiConfig.from_json(x['repo_config']) if 'repo_config' in x else _atd_missing_json_field('CiConfigFromCloud', 'repo_config'), - org_config=CiConfig.from_json(x['org_config']) if 'org_config' in x else None, - dirs_config=_atd_read_list((lambda x: (Fpath.from_json(x[0]), CiConfig.from_json(x[1])) if isinstance(x, list) and len(x) == 2 else _atd_bad_json('array of length 2', x)))(x['dirs_config']) if 'dirs_config' in x else None, - actions=_atd_read_list(Action.from_json)(x['actions']) if 'actions' in x else [], + kind=DependencySourceFileKind.from_json(x['kind']) if 'kind' in x else _atd_missing_json_field('DependencySourceFile', 'kind'), + path=Fpath.from_json(x['path']) if 'path' in x else _atd_missing_json_field('DependencySourceFile', 'path'), ) else: - _atd_bad_json('CiConfigFromCloud', x) + _atd_bad_json('DependencySourceFile', x) def to_json(self) -> Any: res: Dict[str, Any] = {} - res['repo_config'] = (lambda x: x.to_json())(self.repo_config) - if self.org_config is not None: - res['org_config'] = (lambda x: x.to_json())(self.org_config) - if self.dirs_config is not None: - res['dirs_config'] = _atd_write_list((lambda x: [(lambda x: x.to_json())(x[0]), (lambda x: x.to_json())(x[1])] if isinstance(x, tuple) and len(x) == 2 else _atd_bad_python('tuple of length 2', x)))(self.dirs_config) - res['actions'] = _atd_write_list((lambda x: x.to_json()))(self.actions) + res['kind'] = (lambda x: x.to_json())(self.kind) + res['path'] = (lambda x: x.to_json())(self.path) return res @classmethod - def from_json_string(cls, x: str) -> 'CiConfigFromCloud': + def from_json_string(cls, x: str) -> 'DependencySourceFile': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: @@ -3716,68 +3585,33 @@ def to_json_string(self, **kw: Any) -> str: @dataclass -class ScanConfig: - """Original type: scan_config = { ... }""" +class DependencyResolutionStats: + """Original type: dependency_resolution_stats = { ... }""" - deployment_id: int - deployment_name: str - policy_names: List[str] - rule_config: str - ci_config_from_cloud: Optional[CiConfigFromCloud] = None - autofix: bool = field(default_factory=lambda: False) - deepsemgrep: bool = field(default_factory=lambda: False) - dependency_query: bool = field(default_factory=lambda: False) - path_to_transitivity: bool = field(default_factory=lambda: False) - triage_ignored_syntactic_ids: List[str] = field(default_factory=lambda: []) - triage_ignored_match_based_ids: List[str] = field(default_factory=lambda: []) - ignored_files: List[str] = field(default_factory=lambda: []) - enabled_products: Optional[List[Product]] = None - actions: List[Action] = field(default_factory=lambda: []) + resolution_method: ResolutionMethod + dependency_count: int + ecosystem: Ecosystem @classmethod - def from_json(cls, x: Any) -> 'ScanConfig': + def from_json(cls, x: Any) -> 'DependencyResolutionStats': if isinstance(x, dict): return cls( - deployment_id=_atd_read_int(x['deployment_id']) if 'deployment_id' in x else _atd_missing_json_field('ScanConfig', 'deployment_id'), - deployment_name=_atd_read_string(x['deployment_name']) if 'deployment_name' in x else _atd_missing_json_field('ScanConfig', 'deployment_name'), - policy_names=_atd_read_list(_atd_read_string)(x['policy_names']) if 'policy_names' in x else _atd_missing_json_field('ScanConfig', 'policy_names'), - rule_config=_atd_read_string(x['rule_config']) if 'rule_config' in x else _atd_missing_json_field('ScanConfig', 'rule_config'), - ci_config_from_cloud=CiConfigFromCloud.from_json(x['ci_config_from_cloud']) if 'ci_config_from_cloud' in x else None, - autofix=_atd_read_bool(x['autofix']) if 'autofix' in x else False, - deepsemgrep=_atd_read_bool(x['deepsemgrep']) if 'deepsemgrep' in x else False, - dependency_query=_atd_read_bool(x['dependency_query']) if 'dependency_query' in x else False, - path_to_transitivity=_atd_read_bool(x['path_to_transitivity']) if 'path_to_transitivity' in x else False, - triage_ignored_syntactic_ids=_atd_read_list(_atd_read_string)(x['triage_ignored_syntactic_ids']) if 'triage_ignored_syntactic_ids' in x else [], - triage_ignored_match_based_ids=_atd_read_list(_atd_read_string)(x['triage_ignored_match_based_ids']) if 'triage_ignored_match_based_ids' in x else [], - ignored_files=_atd_read_list(_atd_read_string)(x['ignored_files']) if 'ignored_files' in x else [], - enabled_products=_atd_read_list(Product.from_json)(x['enabled_products']) if 'enabled_products' in x else None, - actions=_atd_read_list(Action.from_json)(x['actions']) if 'actions' in x else [], + resolution_method=ResolutionMethod.from_json(x['resolution_method']) if 'resolution_method' in x else _atd_missing_json_field('DependencyResolutionStats', 'resolution_method'), + dependency_count=_atd_read_int(x['dependency_count']) if 'dependency_count' in x else _atd_missing_json_field('DependencyResolutionStats', 'dependency_count'), + ecosystem=Ecosystem.from_json(x['ecosystem']) if 'ecosystem' in x else _atd_missing_json_field('DependencyResolutionStats', 'ecosystem'), ) else: - _atd_bad_json('ScanConfig', x) + _atd_bad_json('DependencyResolutionStats', x) def to_json(self) -> Any: res: Dict[str, Any] = {} - res['deployment_id'] = _atd_write_int(self.deployment_id) - res['deployment_name'] = _atd_write_string(self.deployment_name) - res['policy_names'] = _atd_write_list(_atd_write_string)(self.policy_names) - res['rule_config'] = _atd_write_string(self.rule_config) - if self.ci_config_from_cloud is not None: - res['ci_config_from_cloud'] = (lambda x: x.to_json())(self.ci_config_from_cloud) - res['autofix'] = _atd_write_bool(self.autofix) - res['deepsemgrep'] = _atd_write_bool(self.deepsemgrep) - res['dependency_query'] = _atd_write_bool(self.dependency_query) - res['path_to_transitivity'] = _atd_write_bool(self.path_to_transitivity) - res['triage_ignored_syntactic_ids'] = _atd_write_list(_atd_write_string)(self.triage_ignored_syntactic_ids) - res['triage_ignored_match_based_ids'] = _atd_write_list(_atd_write_string)(self.triage_ignored_match_based_ids) - res['ignored_files'] = _atd_write_list(_atd_write_string)(self.ignored_files) - if self.enabled_products is not None: - res['enabled_products'] = _atd_write_list((lambda x: x.to_json()))(self.enabled_products) - res['actions'] = _atd_write_list((lambda x: x.to_json()))(self.actions) + res['resolution_method'] = (lambda x: x.to_json())(self.resolution_method) + res['dependency_count'] = _atd_write_int(self.dependency_count) + res['ecosystem'] = (lambda x: x.to_json())(self.ecosystem) return res @classmethod - def from_json_string(cls, x: str) -> 'ScanConfig': + def from_json_string(cls, x: str) -> 'DependencyResolutionStats': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: @@ -3785,350 +3619,362 @@ def to_json_string(self, **kw: Any) -> str: @dataclass -class GemfileLock: - """Original type: sca_parser_name = [ ... | Gemfile_lock | ... ]""" - - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'GemfileLock' - - @staticmethod - def to_json() -> Any: - return 'gemfile_lock' - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) +class SubprojectStats: + """Original type: subproject_stats = { ... }""" + subproject_id: str + dependency_sources: List[DependencySourceFile] + resolved_stats: Optional[DependencyResolutionStats] = None -@dataclass -class GoMod: - """Original type: sca_parser_name = [ ... | Go_mod | ... ]""" + @classmethod + def from_json(cls, x: Any) -> 'SubprojectStats': + if isinstance(x, dict): + return cls( + subproject_id=_atd_read_string(x['subproject_id']) if 'subproject_id' in x else _atd_missing_json_field('SubprojectStats', 'subproject_id'), + dependency_sources=_atd_read_list(DependencySourceFile.from_json)(x['dependency_sources']) if 'dependency_sources' in x else _atd_missing_json_field('SubprojectStats', 'dependency_sources'), + resolved_stats=DependencyResolutionStats.from_json(x['resolved_stats']) if 'resolved_stats' in x else None, + ) + else: + _atd_bad_json('SubprojectStats', x) - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'GoMod' + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['subproject_id'] = _atd_write_string(self.subproject_id) + res['dependency_sources'] = _atd_write_list((lambda x: x.to_json()))(self.dependency_sources) + if self.resolved_stats is not None: + res['resolved_stats'] = (lambda x: x.to_json())(self.resolved_stats) + return res - @staticmethod - def to_json() -> Any: - return 'go_mod' + @classmethod + def from_json_string(cls, x: str) -> 'SubprojectStats': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class GoSum: - """Original type: sca_parser_name = [ ... | Go_sum | ... ]""" +class SupplyChainStats: + """Original type: supply_chain_stats = { ... }""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'GoSum' + subprojects_stats: List[SubprojectStats] - @staticmethod - def to_json() -> Any: - return 'go_sum' + @classmethod + def from_json(cls, x: Any) -> 'SupplyChainStats': + if isinstance(x, dict): + return cls( + subprojects_stats=_atd_read_list(SubprojectStats.from_json)(x['subprojects_stats']) if 'subprojects_stats' in x else _atd_missing_json_field('SupplyChainStats', 'subprojects_stats'), + ) + else: + _atd_bad_json('SupplyChainStats', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['subprojects_stats'] = _atd_write_list((lambda x: x.to_json()))(self.subprojects_stats) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'SupplyChainStats': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class GradleLockfile: - """Original type: sca_parser_name = [ ... | Gradle_lockfile | ... ]""" +class AlwaysSkipped: + """Original type: skip_reason = [ ... | Always_skipped | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'GradleLockfile' + return 'AlwaysSkipped' @staticmethod def to_json() -> Any: - return 'gradle_lockfile' + return 'always_skipped' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class GradleBuild: - """Original type: sca_parser_name = [ ... | Gradle_build | ... ]""" +class SemgrepignorePatternsMatch: + """Original type: skip_reason = [ ... | Semgrepignore_patterns_match | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'GradleBuild' + return 'SemgrepignorePatternsMatch' @staticmethod def to_json() -> Any: - return 'gradle_build' + return 'semgrepignore_patterns_match' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class Jsondoc: - """Original type: sca_parser_name = [ ... | Jsondoc | ... ]""" +class CliIncludeFlagsDoNotMatch: + """Original type: skip_reason = [ ... | Cli_include_flags_do_not_match | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Jsondoc' + return 'CliIncludeFlagsDoNotMatch' @staticmethod def to_json() -> Any: - return 'jsondoc' + return 'cli_include_flags_do_not_match' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class Pipfile: - """Original type: sca_parser_name = [ ... | Pipfile | ... ]""" +class CliExcludeFlagsMatch: + """Original type: skip_reason = [ ... | Cli_exclude_flags_match | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Pipfile' + return 'CliExcludeFlagsMatch' @staticmethod def to_json() -> Any: - return 'pipfile' + return 'cli_exclude_flags_match' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class PnpmLock: - """Original type: sca_parser_name = [ ... | Pnpm_lock | ... ]""" +class ExceededSizeLimit: + """Original type: skip_reason = [ ... | Exceeded_size_limit | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'PnpmLock' + return 'ExceededSizeLimit' @staticmethod def to_json() -> Any: - return 'pnpm_lock' + return 'exceeded_size_limit' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class PoetryLock: - """Original type: sca_parser_name = [ ... | Poetry_lock | ... ]""" +class AnalysisFailedParserOrInternalError: + """Original type: skip_reason = [ ... | Analysis_failed_parser_or_internal_error | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'PoetryLock' + return 'AnalysisFailedParserOrInternalError' @staticmethod def to_json() -> Any: - return 'poetry_lock' + return 'analysis_failed_parser_or_internal_error' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class PyprojectToml: - """Original type: sca_parser_name = [ ... | Pyproject_toml | ... ]""" +class ExcludedByConfig: + """Original type: skip_reason = [ ... | Excluded_by_config | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'PyprojectToml' + return 'ExcludedByConfig' @staticmethod def to_json() -> Any: - return 'pyproject_toml' + return 'excluded_by_config' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class Requirements: - """Original type: sca_parser_name = [ ... | Requirements | ... ]""" +class WrongLanguage: + """Original type: skip_reason = [ ... | Wrong_language | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Requirements' + return 'WrongLanguage' @staticmethod def to_json() -> Any: - return 'requirements' + return 'wrong_language' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class Yarn1: - """Original type: sca_parser_name = [ ... | Yarn_1 | ... ]""" +class TooBig: + """Original type: skip_reason = [ ... | Too_big | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Yarn1' + return 'TooBig' @staticmethod def to_json() -> Any: - return 'yarn_1' + return 'too_big' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class Yarn2: - """Original type: sca_parser_name = [ ... | Yarn_2 | ... ]""" +class Minified: + """Original type: skip_reason = [ ... | Minified | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Yarn2' + return 'Minified' @staticmethod def to_json() -> Any: - return 'yarn_2' + return 'minified' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class Pomtree: - """Original type: sca_parser_name = [ ... | Pomtree | ... ]""" +class Binary: + """Original type: skip_reason = [ ... | Binary | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Pomtree' + return 'Binary' @staticmethod def to_json() -> Any: - return 'pomtree' + return 'binary' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class CargoParser: - """Original type: sca_parser_name = [ ... | Cargo_parser | ... ]""" +class IrrelevantRule: + """Original type: skip_reason = [ ... | Irrelevant_rule | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'CargoParser' + return 'IrrelevantRule' @staticmethod def to_json() -> Any: - return 'cargo' + return 'irrelevant_rule' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class ComposerLock: - """Original type: sca_parser_name = [ ... | Composer_lock | ... ]""" +class TooManyMatches: + """Original type: skip_reason = [ ... | Too_many_matches | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'ComposerLock' + return 'TooManyMatches' @staticmethod def to_json() -> Any: - return 'composer_lock' + return 'too_many_matches' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class PubspecLock: - """Original type: sca_parser_name = [ ... | Pubspec_lock | ... ]""" +class GitignorePatternsMatch: + """Original type: skip_reason = [ ... | Gitignore_patterns_match | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'PubspecLock' + return 'GitignorePatternsMatch' @staticmethod def to_json() -> Any: - return 'pubspec_lock' + return 'Gitignore_patterns_match' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class PackageSwift: - """Original type: sca_parser_name = [ ... | Package_swift | ... ]""" +class Dotfile: + """Original type: skip_reason = [ ... | Dotfile | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'PackageSwift' + return 'Dotfile' @staticmethod def to_json() -> Any: - return 'package_swift' + return 'Dotfile' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class PackageResolved: - """Original type: sca_parser_name = [ ... | Package_resolved | ... ]""" +class NonexistentFile: + """Original type: skip_reason = [ ... | Nonexistent_file | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'PackageResolved' + return 'NonexistentFile' @staticmethod def to_json() -> Any: - return 'package_resolved' + return 'Nonexistent_file' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class MixLock: - """Original type: sca_parser_name = [ ... | Mix_lock | ... ]""" +class InsufficientPermissions: + """Original type: skip_reason = [ ... | Insufficient_permissions | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'MixLock' + return 'InsufficientPermissions' @staticmethod def to_json() -> Any: - return 'mix_lock' + return 'insufficient_permissions' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass -class ScaParserName: - """Original type: sca_parser_name = [ ... ]""" +class SkipReason: + """Original type: skip_reason = [ ... ]""" - value: Union[GemfileLock, GoMod, GoSum, GradleLockfile, GradleBuild, Jsondoc, Pipfile, PnpmLock, PoetryLock, PyprojectToml, Requirements, Yarn1, Yarn2, Pomtree, CargoParser, ComposerLock, PubspecLock, PackageSwift, PackageResolved, MixLock] + value: Union[AlwaysSkipped, SemgrepignorePatternsMatch, CliIncludeFlagsDoNotMatch, CliExcludeFlagsMatch, ExceededSizeLimit, AnalysisFailedParserOrInternalError, ExcludedByConfig, WrongLanguage, TooBig, Minified, Binary, IrrelevantRule, TooManyMatches, GitignorePatternsMatch, Dotfile, NonexistentFile, InsufficientPermissions] @property def kind(self) -> str: @@ -4136,343 +3982,474 @@ def kind(self) -> str: return self.value.kind @classmethod - def from_json(cls, x: Any) -> 'ScaParserName': + def from_json(cls, x: Any) -> 'SkipReason': if isinstance(x, str): - if x == 'gemfile_lock': - return cls(GemfileLock()) - if x == 'go_mod': - return cls(GoMod()) - if x == 'go_sum': - return cls(GoSum()) - if x == 'gradle_lockfile': - return cls(GradleLockfile()) - if x == 'gradle_build': - return cls(GradleBuild()) - if x == 'jsondoc': - return cls(Jsondoc()) - if x == 'pipfile': - return cls(Pipfile()) - if x == 'pnpm_lock': - return cls(PnpmLock()) - if x == 'poetry_lock': - return cls(PoetryLock()) - if x == 'pyproject_toml': - return cls(PyprojectToml()) - if x == 'requirements': - return cls(Requirements()) - if x == 'yarn_1': - return cls(Yarn1()) - if x == 'yarn_2': - return cls(Yarn2()) - if x == 'pomtree': - return cls(Pomtree()) - if x == 'cargo': - return cls(CargoParser()) - if x == 'composer_lock': - return cls(ComposerLock()) - if x == 'pubspec_lock': - return cls(PubspecLock()) - if x == 'package_swift': - return cls(PackageSwift()) - if x == 'package_resolved': - return cls(PackageResolved()) - if x == 'mix_lock': - return cls(MixLock()) - _atd_bad_json('ScaParserName', x) - _atd_bad_json('ScaParserName', x) + if x == 'always_skipped': + return cls(AlwaysSkipped()) + if x == 'semgrepignore_patterns_match': + return cls(SemgrepignorePatternsMatch()) + if x == 'cli_include_flags_do_not_match': + return cls(CliIncludeFlagsDoNotMatch()) + if x == 'cli_exclude_flags_match': + return cls(CliExcludeFlagsMatch()) + if x == 'exceeded_size_limit': + return cls(ExceededSizeLimit()) + if x == 'analysis_failed_parser_or_internal_error': + return cls(AnalysisFailedParserOrInternalError()) + if x == 'excluded_by_config': + return cls(ExcludedByConfig()) + if x == 'wrong_language': + return cls(WrongLanguage()) + if x == 'too_big': + return cls(TooBig()) + if x == 'minified': + return cls(Minified()) + if x == 'binary': + return cls(Binary()) + if x == 'irrelevant_rule': + return cls(IrrelevantRule()) + if x == 'too_many_matches': + return cls(TooManyMatches()) + if x == 'Gitignore_patterns_match': + return cls(GitignorePatternsMatch()) + if x == 'Dotfile': + return cls(Dotfile()) + if x == 'Nonexistent_file': + return cls(NonexistentFile()) + if x == 'insufficient_permissions': + return cls(InsufficientPermissions()) + _atd_bad_json('SkipReason', x) + _atd_bad_json('SkipReason', x) + + def to_json(self) -> Any: + return self.value.to_json() + + @classmethod + def from_json_string(cls, x: str) -> 'SkipReason': + return cls.from_json(json.loads(x)) + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass +class SkippedTarget: + """Original type: skipped_target = { ... }""" + + path: Fpath + reason: SkipReason + details: Optional[str] = None + rule_id: Optional[RuleId] = None + + @classmethod + def from_json(cls, x: Any) -> 'SkippedTarget': + if isinstance(x, dict): + return cls( + path=Fpath.from_json(x['path']) if 'path' in x else _atd_missing_json_field('SkippedTarget', 'path'), + reason=SkipReason.from_json(x['reason']) if 'reason' in x else _atd_missing_json_field('SkippedTarget', 'reason'), + details=_atd_read_string(x['details']) if 'details' in x else None, + rule_id=RuleId.from_json(x['rule_id']) if 'rule_id' in x else None, + ) + else: + _atd_bad_json('SkippedTarget', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['path'] = (lambda x: x.to_json())(self.path) + res['reason'] = (lambda x: x.to_json())(self.reason) + if self.details is not None: + res['details'] = _atd_write_string(self.details) + if self.rule_id is not None: + res['rule_id'] = (lambda x: x.to_json())(self.rule_id) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'SkippedTarget': + return cls.from_json(json.loads(x)) + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass +class SkippedRule: + """Original type: skipped_rule = { ... }""" + + rule_id: RuleId + details: str + position: Position + + @classmethod + def from_json(cls, x: Any) -> 'SkippedRule': + if isinstance(x, dict): + return cls( + rule_id=RuleId.from_json(x['rule_id']) if 'rule_id' in x else _atd_missing_json_field('SkippedRule', 'rule_id'), + details=_atd_read_string(x['details']) if 'details' in x else _atd_missing_json_field('SkippedRule', 'details'), + position=Position.from_json(x['position']) if 'position' in x else _atd_missing_json_field('SkippedRule', 'position'), + ) + else: + _atd_bad_json('SkippedRule', x) def to_json(self) -> Any: - return self.value.to_json() + res: Dict[str, Any] = {} + res['rule_id'] = (lambda x: x.to_json())(self.rule_id) + res['details'] = _atd_write_string(self.details) + res['position'] = (lambda x: x.to_json())(self.position) + return res @classmethod - def from_json_string(cls, x: str) -> 'ScaParserName': + def from_json_string(cls, x: str) -> 'SkippedRule': 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 Npm: - """Original type: ecosystem = [ ... | Npm | ... ]""" - - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'Npm' - - @staticmethod - def to_json() -> Any: - return 'npm' - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) +@dataclass +class ScannedAndSkipped: + """Original type: scanned_and_skipped = { ... }""" + scanned: List[Fpath] + skipped: Optional[List[SkippedTarget]] = None -@dataclass(frozen=True) -class Pypi: - """Original type: ecosystem = [ ... | Pypi | ... ]""" + @classmethod + def from_json(cls, x: Any) -> 'ScannedAndSkipped': + if isinstance(x, dict): + return cls( + scanned=_atd_read_list(Fpath.from_json)(x['scanned']) if 'scanned' in x else _atd_missing_json_field('ScannedAndSkipped', 'scanned'), + skipped=_atd_read_list(SkippedTarget.from_json)(x['skipped']) if 'skipped' in x else None, + ) + else: + _atd_bad_json('ScannedAndSkipped', x) - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'Pypi' + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['scanned'] = _atd_write_list((lambda x: x.to_json()))(self.scanned) + if self.skipped is not None: + res['skipped'] = _atd_write_list((lambda x: x.to_json()))(self.skipped) + return res - @staticmethod - def to_json() -> Any: - return 'pypi' + @classmethod + def from_json_string(cls, x: str) -> 'ScannedAndSkipped': + 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 Gem: - """Original type: ecosystem = [ ... | Gem | ... ]""" +class SAST: + """Original type: product = [ ... | SAST | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Gem' + return 'SAST' @staticmethod def to_json() -> Any: - return 'gem' + return 'sast' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class Gomod: - """Original type: ecosystem = [ ... | Gomod | ... ]""" +class SCA: + """Original type: product = [ ... | SCA | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Gomod' + return 'SCA' @staticmethod def to_json() -> Any: - return 'gomod' + return 'sca' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class Cargo: - """Original type: ecosystem = [ ... | Cargo | ... ]""" +class Secrets: + """Original type: product = [ ... | Secrets | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Cargo' + return 'Secrets' @staticmethod def to_json() -> Any: - return 'cargo' + return 'secrets' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class Maven: - """Original type: ecosystem = [ ... | Maven | ... ]""" +class Product: + """Original type: product = [ ... ]""" + + value: Union[SAST, SCA, Secrets] @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Maven' - - @staticmethod - def to_json() -> Any: - return 'maven' - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - + return self.value.kind -@dataclass(frozen=True) -class Composer: - """Original type: ecosystem = [ ... | Composer | ... ]""" + @classmethod + def from_json(cls, x: Any) -> 'Product': + if isinstance(x, str): + if x == 'sast': + return cls(SAST()) + if x == 'sca': + return cls(SCA()) + if x == 'secrets': + return cls(Secrets()) + _atd_bad_json('Product', x) + _atd_bad_json('Product', x) - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'Composer' + def to_json(self) -> Any: + return self.value.to_json() - @staticmethod - def to_json() -> Any: - return 'composer' + @classmethod + def from_json_string(cls, x: str) -> 'Product': + 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 Nuget: - """Original type: ecosystem = [ ... | Nuget | ... ]""" +@dataclass +class ScanInfo: + """Original type: scan_info = { ... }""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'Nuget' + enabled_products: List[Product] + deployment_id: int + deployment_name: str + id: Optional[int] = None - @staticmethod - def to_json() -> Any: - return 'nuget' + @classmethod + def from_json(cls, x: Any) -> 'ScanInfo': + if isinstance(x, dict): + return cls( + enabled_products=_atd_read_list(Product.from_json)(x['enabled_products']) if 'enabled_products' in x else _atd_missing_json_field('ScanInfo', 'enabled_products'), + deployment_id=_atd_read_int(x['deployment_id']) if 'deployment_id' in x else _atd_missing_json_field('ScanInfo', 'deployment_id'), + deployment_name=_atd_read_string(x['deployment_name']) if 'deployment_name' in x else _atd_missing_json_field('ScanInfo', 'deployment_name'), + id=_atd_read_int(x['id']) if 'id' in x else None, + ) + else: + _atd_bad_json('ScanInfo', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['enabled_products'] = _atd_write_list((lambda x: x.to_json()))(self.enabled_products) + res['deployment_id'] = _atd_write_int(self.deployment_id) + res['deployment_name'] = _atd_write_string(self.deployment_name) + if self.id is not None: + res['id'] = _atd_write_int(self.id) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'ScanInfo': + 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 Pub: - """Original type: ecosystem = [ ... | Pub | ... ]""" +@dataclass +class ScanConfiguration: + """Original type: scan_configuration = { ... }""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'Pub' + rules: RawJson + triage_ignored_syntactic_ids: List[str] = field(default_factory=lambda: []) + triage_ignored_match_based_ids: List[str] = field(default_factory=lambda: []) - @staticmethod - def to_json() -> Any: - return 'pub' + @classmethod + def from_json(cls, x: Any) -> 'ScanConfiguration': + if isinstance(x, dict): + return cls( + rules=RawJson.from_json(x['rules']) if 'rules' in x else _atd_missing_json_field('ScanConfiguration', 'rules'), + triage_ignored_syntactic_ids=_atd_read_list(_atd_read_string)(x['triage_ignored_syntactic_ids']) if 'triage_ignored_syntactic_ids' in x else [], + triage_ignored_match_based_ids=_atd_read_list(_atd_read_string)(x['triage_ignored_match_based_ids']) if 'triage_ignored_match_based_ids' in x else [], + ) + else: + _atd_bad_json('ScanConfiguration', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['rules'] = (lambda x: x.to_json())(self.rules) + res['triage_ignored_syntactic_ids'] = _atd_write_list(_atd_write_string)(self.triage_ignored_syntactic_ids) + res['triage_ignored_match_based_ids'] = _atd_write_list(_atd_write_string)(self.triage_ignored_match_based_ids) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'ScanConfiguration': + 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 SwiftPM: - """Original type: ecosystem = [ ... | SwiftPM | ... ]""" +@dataclass +class Glob: + """Original type: glob""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'SwiftPM' + value: str - @staticmethod - def to_json() -> Any: - return 'swiftpm' + @classmethod + def from_json(cls, x: Any) -> 'Glob': + return cls(_atd_read_string(x)) + + def to_json(self) -> Any: + return _atd_write_string(self.value) + + @classmethod + def from_json_string(cls, x: str) -> 'Glob': + 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 Mix: - """Original type: ecosystem = [ ... | Mix | ... ]""" +@dataclass +class ProductIgnoredFiles: + """Original type: product_ignored_files""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'Mix' + value: Dict[Product, List[Glob]] - @staticmethod - def to_json() -> Any: - return 'mix' + @classmethod + def from_json(cls, x: Any) -> 'ProductIgnoredFiles': + return cls(_atd_read_assoc_array_into_dict(Product.from_json, _atd_read_list(Glob.from_json))(x)) + + def to_json(self) -> Any: + return _atd_write_assoc_dict_to_array((lambda x: x.to_json()), _atd_write_list((lambda x: x.to_json())))(self.value) + + @classmethod + def from_json_string(cls, x: str) -> 'ProductIgnoredFiles': + 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 Hex: - """Original type: ecosystem = [ ... | Hex | ... ]""" +@dataclass +class HistoricalConfiguration: + """Original type: historical_configuration = { ... }""" + + enabled: bool + lookback_days: Optional[int] = None + + @classmethod + def from_json(cls, x: Any) -> 'HistoricalConfiguration': + if isinstance(x, dict): + return cls( + enabled=_atd_read_bool(x['enabled']) if 'enabled' in x else _atd_missing_json_field('HistoricalConfiguration', 'enabled'), + lookback_days=_atd_read_int(x['lookback_days']) if 'lookback_days' in x else None, + ) + else: + _atd_bad_json('HistoricalConfiguration', x) - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'Hex' + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['enabled'] = _atd_write_bool(self.enabled) + if self.lookback_days is not None: + res['lookback_days'] = _atd_write_int(self.lookback_days) + return res - @staticmethod - def to_json() -> Any: - return 'hex' + @classmethod + def from_json_string(cls, x: str) -> 'HistoricalConfiguration': + 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 Ecosystem: - """Original type: ecosystem = [ ... ]""" - - value: Union[Npm, Pypi, Gem, Gomod, Cargo, Maven, Composer, Nuget, Pub, SwiftPM, Mix, Hex] +@dataclass +class EngineConfiguration: + """Original type: engine_configuration = { ... }""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return self.value.kind + autofix: bool = field(default_factory=lambda: False) + deepsemgrep: bool = field(default_factory=lambda: False) + dependency_query: bool = field(default_factory=lambda: False) + path_to_transitivity: bool = field(default_factory=lambda: False) + ignored_files: List[str] = field(default_factory=lambda: []) + product_ignored_files: Optional[ProductIgnoredFiles] = None + generic_slow_rollout: bool = field(default_factory=lambda: False) + historical_config: Optional[HistoricalConfiguration] = None + always_suppress_errors: bool = field(default_factory=lambda: False) @classmethod - def from_json(cls, x: Any) -> 'Ecosystem': - if isinstance(x, str): - if x == 'npm': - return cls(Npm()) - if x == 'pypi': - return cls(Pypi()) - if x == 'gem': - return cls(Gem()) - if x == 'gomod': - return cls(Gomod()) - if x == 'cargo': - return cls(Cargo()) - if x == 'maven': - return cls(Maven()) - if x == 'composer': - return cls(Composer()) - if x == 'nuget': - return cls(Nuget()) - if x == 'pub': - return cls(Pub()) - if x == 'swiftpm': - return cls(SwiftPM()) - if x == 'mix': - return cls(Mix()) - if x == 'hex': - return cls(Hex()) - _atd_bad_json('Ecosystem', x) - _atd_bad_json('Ecosystem', x) + def from_json(cls, x: Any) -> 'EngineConfiguration': + if isinstance(x, dict): + return cls( + autofix=_atd_read_bool(x['autofix']) if 'autofix' in x else False, + deepsemgrep=_atd_read_bool(x['deepsemgrep']) if 'deepsemgrep' in x else False, + dependency_query=_atd_read_bool(x['dependency_query']) if 'dependency_query' in x else False, + path_to_transitivity=_atd_read_bool(x['path_to_transitivity']) if 'path_to_transitivity' in x else False, + ignored_files=_atd_read_list(_atd_read_string)(x['ignored_files']) if 'ignored_files' in x else [], + product_ignored_files=ProductIgnoredFiles.from_json(x['product_ignored_files']) if 'product_ignored_files' in x else None, + generic_slow_rollout=_atd_read_bool(x['generic_slow_rollout']) if 'generic_slow_rollout' in x else False, + historical_config=HistoricalConfiguration.from_json(x['historical_config']) if 'historical_config' in x else None, + always_suppress_errors=_atd_read_bool(x['always_suppress_errors']) if 'always_suppress_errors' in x else False, + ) + else: + _atd_bad_json('EngineConfiguration', x) def to_json(self) -> Any: - return self.value.to_json() + res: Dict[str, Any] = {} + res['autofix'] = _atd_write_bool(self.autofix) + res['deepsemgrep'] = _atd_write_bool(self.deepsemgrep) + res['dependency_query'] = _atd_write_bool(self.dependency_query) + res['path_to_transitivity'] = _atd_write_bool(self.path_to_transitivity) + res['ignored_files'] = _atd_write_list(_atd_write_string)(self.ignored_files) + if self.product_ignored_files is not None: + res['product_ignored_files'] = (lambda x: x.to_json())(self.product_ignored_files) + res['generic_slow_rollout'] = _atd_write_bool(self.generic_slow_rollout) + if self.historical_config is not None: + res['historical_config'] = (lambda x: x.to_json())(self.historical_config) + res['always_suppress_errors'] = _atd_write_bool(self.always_suppress_errors) + return res @classmethod - def from_json_string(cls, x: str) -> 'Ecosystem': + def from_json_string(cls, x: str) -> 'EngineConfiguration': 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 DependencyChild: - """Original type: dependency_child = { ... }""" +@dataclass +class ScanResponse: + """Original type: scan_response = { ... }""" - package: str - version: str + info: ScanInfo + config: ScanConfiguration + engine_params: EngineConfiguration @classmethod - def from_json(cls, x: Any) -> 'DependencyChild': + def from_json(cls, x: Any) -> 'ScanResponse': if isinstance(x, dict): return cls( - package=_atd_read_string(x['package']) if 'package' in x else _atd_missing_json_field('DependencyChild', 'package'), - version=_atd_read_string(x['version']) if 'version' in x else _atd_missing_json_field('DependencyChild', 'version'), + info=ScanInfo.from_json(x['info']) if 'info' in x else _atd_missing_json_field('ScanResponse', 'info'), + config=ScanConfiguration.from_json(x['config']) if 'config' in x else _atd_missing_json_field('ScanResponse', 'config'), + engine_params=EngineConfiguration.from_json(x['engine_params']) if 'engine_params' in x else _atd_missing_json_field('ScanResponse', 'engine_params'), ) else: - _atd_bad_json('DependencyChild', x) + _atd_bad_json('ScanResponse', x) def to_json(self) -> Any: res: Dict[str, Any] = {} - res['package'] = _atd_write_string(self.package) - res['version'] = _atd_write_string(self.version) + res['info'] = (lambda x: x.to_json())(self.info) + res['config'] = (lambda x: x.to_json())(self.config) + res['engine_params'] = (lambda x: x.to_json())(self.engine_params) return res @classmethod - def from_json_string(cls, x: str) -> 'DependencyChild': + def from_json_string(cls, x: str) -> 'ScanResponse': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: @@ -4480,63 +4457,40 @@ def to_json_string(self, **kw: Any) -> str: @dataclass -class FoundDependency: - """Original type: found_dependency = { ... }""" +class ScanMetadata: + """Original type: scan_metadata = { ... }""" - package: str - version: str - ecosystem: Ecosystem - allowed_hashes: Dict[str, List[str]] - transitivity: Transitivity - resolved_url: Optional[str] = None - manifest_path: Optional[Fpath] = None - lockfile_path: Optional[Fpath] = None - line_number: Optional[int] = None - children: Optional[List[DependencyChild]] = None - git_ref: Optional[str] = None + cli_version: Version + unique_id: Uuid + requested_products: List[Product] + dry_run: bool = field(default_factory=lambda: False) + sms_scan_id: Optional[str] = None @classmethod - def from_json(cls, x: Any) -> 'FoundDependency': + def from_json(cls, x: Any) -> 'ScanMetadata': if isinstance(x, dict): return cls( - package=_atd_read_string(x['package']) if 'package' in x else _atd_missing_json_field('FoundDependency', 'package'), - version=_atd_read_string(x['version']) if 'version' in x else _atd_missing_json_field('FoundDependency', 'version'), - ecosystem=Ecosystem.from_json(x['ecosystem']) if 'ecosystem' in x else _atd_missing_json_field('FoundDependency', 'ecosystem'), - allowed_hashes=_atd_read_assoc_object_into_dict(_atd_read_list(_atd_read_string))(x['allowed_hashes']) if 'allowed_hashes' in x else _atd_missing_json_field('FoundDependency', 'allowed_hashes'), - transitivity=Transitivity.from_json(x['transitivity']) if 'transitivity' in x else _atd_missing_json_field('FoundDependency', 'transitivity'), - resolved_url=_atd_read_string(x['resolved_url']) if 'resolved_url' in x else None, - manifest_path=Fpath.from_json(x['manifest_path']) if 'manifest_path' in x else None, - lockfile_path=Fpath.from_json(x['lockfile_path']) if 'lockfile_path' in x else None, - line_number=_atd_read_int(x['line_number']) if 'line_number' in x else None, - children=_atd_read_list(DependencyChild.from_json)(x['children']) if 'children' in x else None, - git_ref=_atd_read_string(x['git_ref']) if 'git_ref' in x else None, + cli_version=Version.from_json(x['cli_version']) if 'cli_version' in x else _atd_missing_json_field('ScanMetadata', 'cli_version'), + unique_id=Uuid.from_json(x['unique_id']) if 'unique_id' in x else _atd_missing_json_field('ScanMetadata', 'unique_id'), + requested_products=_atd_read_list(Product.from_json)(x['requested_products']) if 'requested_products' in x else _atd_missing_json_field('ScanMetadata', 'requested_products'), + dry_run=_atd_read_bool(x['dry_run']) if 'dry_run' in x else False, + sms_scan_id=_atd_read_string(x['sms_scan_id']) if 'sms_scan_id' in x else None, ) else: - _atd_bad_json('FoundDependency', x) + _atd_bad_json('ScanMetadata', x) def to_json(self) -> Any: res: Dict[str, Any] = {} - res['package'] = _atd_write_string(self.package) - res['version'] = _atd_write_string(self.version) - res['ecosystem'] = (lambda x: x.to_json())(self.ecosystem) - res['allowed_hashes'] = _atd_write_assoc_dict_to_object(_atd_write_list(_atd_write_string))(self.allowed_hashes) - res['transitivity'] = (lambda x: x.to_json())(self.transitivity) - if self.resolved_url is not None: - res['resolved_url'] = _atd_write_string(self.resolved_url) - if self.manifest_path is not None: - res['manifest_path'] = (lambda x: x.to_json())(self.manifest_path) - if self.lockfile_path is not None: - res['lockfile_path'] = (lambda x: x.to_json())(self.lockfile_path) - if self.line_number is not None: - res['line_number'] = _atd_write_int(self.line_number) - if self.children is not None: - res['children'] = _atd_write_list((lambda x: x.to_json()))(self.children) - if self.git_ref is not None: - res['git_ref'] = _atd_write_string(self.git_ref) + res['cli_version'] = (lambda x: x.to_json())(self.cli_version) + res['unique_id'] = (lambda x: x.to_json())(self.unique_id) + res['requested_products'] = _atd_write_list((lambda x: x.to_json()))(self.requested_products) + res['dry_run'] = _atd_write_bool(self.dry_run) + if self.sms_scan_id is not None: + res['sms_scan_id'] = _atd_write_string(self.sms_scan_id) return res @classmethod - def from_json_string(cls, x: str) -> 'FoundDependency': + def from_json_string(cls, x: str) -> 'ScanMetadata': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: @@ -4544,33 +4498,114 @@ def to_json_string(self, **kw: Any) -> str: @dataclass -class DependencyPattern: - """Original type: dependency_pattern = { ... }""" +class ProjectMetadata: + """Original type: project_metadata = { ... }""" - ecosystem: Ecosystem - package: str - semver_range: str + semgrep_version: Version + scan_environment: str + repository: str + repo_url: Optional[Uri] + branch: Optional[str] + commit: Optional[Sha1] + commit_title: Optional[str] + commit_author_email: Optional[str] + commit_author_name: Optional[str] + commit_author_username: Optional[str] + commit_author_image_url: Optional[Uri] + ci_job_url: Optional[Uri] + on: str + pull_request_author_username: Optional[str] + pull_request_author_image_url: Optional[Uri] + pull_request_id: Optional[str] + pull_request_title: Optional[str] + is_full_scan: bool + repo_id: Optional[str] = None + org_id: Optional[str] = None + repo_display_name: Optional[str] = None + commit_timestamp: Optional[Datetime] = None + base_sha: Optional[Sha1] = None + start_sha: Optional[Sha1] = None + is_sca_scan: Optional[bool] = None + is_code_scan: Optional[bool] = None + is_secrets_scan: Optional[bool] = None @classmethod - def from_json(cls, x: Any) -> 'DependencyPattern': + def from_json(cls, x: Any) -> 'ProjectMetadata': if isinstance(x, dict): return cls( - ecosystem=Ecosystem.from_json(x['ecosystem']) if 'ecosystem' in x else _atd_missing_json_field('DependencyPattern', 'ecosystem'), - package=_atd_read_string(x['package']) if 'package' in x else _atd_missing_json_field('DependencyPattern', 'package'), - semver_range=_atd_read_string(x['semver_range']) if 'semver_range' in x else _atd_missing_json_field('DependencyPattern', 'semver_range'), + semgrep_version=Version.from_json(x['semgrep_version']) if 'semgrep_version' in x else _atd_missing_json_field('ProjectMetadata', 'semgrep_version'), + scan_environment=_atd_read_string(x['scan_environment']) if 'scan_environment' in x else _atd_missing_json_field('ProjectMetadata', 'scan_environment'), + repository=_atd_read_string(x['repository']) if 'repository' in x else _atd_missing_json_field('ProjectMetadata', 'repository'), + repo_url=_atd_read_nullable(Uri.from_json)(x['repo_url']) if 'repo_url' in x else _atd_missing_json_field('ProjectMetadata', 'repo_url'), + branch=_atd_read_nullable(_atd_read_string)(x['branch']) if 'branch' in x else _atd_missing_json_field('ProjectMetadata', 'branch'), + commit=_atd_read_nullable(Sha1.from_json)(x['commit']) if 'commit' in x else _atd_missing_json_field('ProjectMetadata', 'commit'), + commit_title=_atd_read_nullable(_atd_read_string)(x['commit_title']) if 'commit_title' in x else _atd_missing_json_field('ProjectMetadata', 'commit_title'), + commit_author_email=_atd_read_nullable(_atd_read_string)(x['commit_author_email']) if 'commit_author_email' in x else _atd_missing_json_field('ProjectMetadata', 'commit_author_email'), + commit_author_name=_atd_read_nullable(_atd_read_string)(x['commit_author_name']) if 'commit_author_name' in x else _atd_missing_json_field('ProjectMetadata', 'commit_author_name'), + commit_author_username=_atd_read_nullable(_atd_read_string)(x['commit_author_username']) if 'commit_author_username' in x else _atd_missing_json_field('ProjectMetadata', 'commit_author_username'), + commit_author_image_url=_atd_read_nullable(Uri.from_json)(x['commit_author_image_url']) if 'commit_author_image_url' in x else _atd_missing_json_field('ProjectMetadata', 'commit_author_image_url'), + ci_job_url=_atd_read_nullable(Uri.from_json)(x['ci_job_url']) if 'ci_job_url' in x else _atd_missing_json_field('ProjectMetadata', 'ci_job_url'), + on=_atd_read_string(x['on']) if 'on' in x else _atd_missing_json_field('ProjectMetadata', 'on'), + pull_request_author_username=_atd_read_nullable(_atd_read_string)(x['pull_request_author_username']) if 'pull_request_author_username' in x else _atd_missing_json_field('ProjectMetadata', 'pull_request_author_username'), + pull_request_author_image_url=_atd_read_nullable(Uri.from_json)(x['pull_request_author_image_url']) if 'pull_request_author_image_url' in x else _atd_missing_json_field('ProjectMetadata', 'pull_request_author_image_url'), + pull_request_id=_atd_read_nullable(_atd_read_string)(x['pull_request_id']) if 'pull_request_id' in x else _atd_missing_json_field('ProjectMetadata', 'pull_request_id'), + pull_request_title=_atd_read_nullable(_atd_read_string)(x['pull_request_title']) if 'pull_request_title' in x else _atd_missing_json_field('ProjectMetadata', 'pull_request_title'), + is_full_scan=_atd_read_bool(x['is_full_scan']) if 'is_full_scan' in x else _atd_missing_json_field('ProjectMetadata', 'is_full_scan'), + repo_id=_atd_read_string(x['repo_id']) if 'repo_id' in x else None, + org_id=_atd_read_string(x['org_id']) if 'org_id' in x else None, + repo_display_name=_atd_read_string(x['repo_display_name']) if 'repo_display_name' in x else None, + commit_timestamp=Datetime.from_json(x['commit_timestamp']) if 'commit_timestamp' in x else None, + base_sha=Sha1.from_json(x['base_sha']) if 'base_sha' in x else None, + start_sha=Sha1.from_json(x['start_sha']) if 'start_sha' in x else None, + is_sca_scan=_atd_read_bool(x['is_sca_scan']) if 'is_sca_scan' in x else None, + is_code_scan=_atd_read_bool(x['is_code_scan']) if 'is_code_scan' in x else None, + is_secrets_scan=_atd_read_bool(x['is_secrets_scan']) if 'is_secrets_scan' in x else None, ) else: - _atd_bad_json('DependencyPattern', x) + _atd_bad_json('ProjectMetadata', x) def to_json(self) -> Any: res: Dict[str, Any] = {} - res['ecosystem'] = (lambda x: x.to_json())(self.ecosystem) - res['package'] = _atd_write_string(self.package) - res['semver_range'] = _atd_write_string(self.semver_range) + res['semgrep_version'] = (lambda x: x.to_json())(self.semgrep_version) + res['scan_environment'] = _atd_write_string(self.scan_environment) + res['repository'] = _atd_write_string(self.repository) + res['repo_url'] = _atd_write_nullable((lambda x: x.to_json()))(self.repo_url) + res['branch'] = _atd_write_nullable(_atd_write_string)(self.branch) + res['commit'] = _atd_write_nullable((lambda x: x.to_json()))(self.commit) + res['commit_title'] = _atd_write_nullable(_atd_write_string)(self.commit_title) + res['commit_author_email'] = _atd_write_nullable(_atd_write_string)(self.commit_author_email) + res['commit_author_name'] = _atd_write_nullable(_atd_write_string)(self.commit_author_name) + res['commit_author_username'] = _atd_write_nullable(_atd_write_string)(self.commit_author_username) + res['commit_author_image_url'] = _atd_write_nullable((lambda x: x.to_json()))(self.commit_author_image_url) + res['ci_job_url'] = _atd_write_nullable((lambda x: x.to_json()))(self.ci_job_url) + res['on'] = _atd_write_string(self.on) + res['pull_request_author_username'] = _atd_write_nullable(_atd_write_string)(self.pull_request_author_username) + res['pull_request_author_image_url'] = _atd_write_nullable((lambda x: x.to_json()))(self.pull_request_author_image_url) + res['pull_request_id'] = _atd_write_nullable(_atd_write_string)(self.pull_request_id) + res['pull_request_title'] = _atd_write_nullable(_atd_write_string)(self.pull_request_title) + res['is_full_scan'] = _atd_write_bool(self.is_full_scan) + if self.repo_id is not None: + res['repo_id'] = _atd_write_string(self.repo_id) + if self.org_id is not None: + res['org_id'] = _atd_write_string(self.org_id) + if self.repo_display_name is not None: + res['repo_display_name'] = _atd_write_string(self.repo_display_name) + if self.commit_timestamp is not None: + res['commit_timestamp'] = (lambda x: x.to_json())(self.commit_timestamp) + if self.base_sha is not None: + res['base_sha'] = (lambda x: x.to_json())(self.base_sha) + if self.start_sha is not None: + res['start_sha'] = (lambda x: x.to_json())(self.start_sha) + if self.is_sca_scan is not None: + res['is_sca_scan'] = _atd_write_bool(self.is_sca_scan) + if self.is_code_scan is not None: + res['is_code_scan'] = _atd_write_bool(self.is_code_scan) + if self.is_secrets_scan is not None: + res['is_secrets_scan'] = _atd_write_bool(self.is_secrets_scan) return res @classmethod - def from_json_string(cls, x: str) -> 'DependencyPattern': + def from_json_string(cls, x: str) -> 'ProjectMetadata': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: @@ -4578,33 +4613,31 @@ def to_json_string(self, **kw: Any) -> str: @dataclass -class DependencyMatch: - """Original type: dependency_match = { ... }""" +class CiConfigFromRepo: + """Original type: ci_config_from_repo = { ... }""" - dependency_pattern: DependencyPattern - found_dependency: FoundDependency - lockfile: str + version: Version = field(default_factory=lambda: Version('v1')) + tags: Optional[List[Tag]] = None @classmethod - def from_json(cls, x: Any) -> 'DependencyMatch': + def from_json(cls, x: Any) -> 'CiConfigFromRepo': if isinstance(x, dict): return cls( - dependency_pattern=DependencyPattern.from_json(x['dependency_pattern']) if 'dependency_pattern' in x else _atd_missing_json_field('DependencyMatch', 'dependency_pattern'), - found_dependency=FoundDependency.from_json(x['found_dependency']) if 'found_dependency' in x else _atd_missing_json_field('DependencyMatch', 'found_dependency'), - lockfile=_atd_read_string(x['lockfile']) if 'lockfile' in x else _atd_missing_json_field('DependencyMatch', 'lockfile'), + version=Version.from_json(x['version']) if 'version' in x else Version('v1'), + tags=_atd_read_list(Tag.from_json)(x['tags']) if 'tags' in x else None, ) else: - _atd_bad_json('DependencyMatch', x) + _atd_bad_json('CiConfigFromRepo', x) def to_json(self) -> Any: res: Dict[str, Any] = {} - res['dependency_pattern'] = (lambda x: x.to_json())(self.dependency_pattern) - res['found_dependency'] = (lambda x: x.to_json())(self.found_dependency) - res['lockfile'] = _atd_write_string(self.lockfile) + res['version'] = (lambda x: x.to_json())(self.version) + if self.tags is not None: + res['tags'] = _atd_write_list((lambda x: x.to_json()))(self.tags) return res @classmethod - def from_json_string(cls, x: str) -> 'DependencyMatch': + def from_json_string(cls, x: str) -> 'CiConfigFromRepo': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: @@ -4612,834 +4645,973 @@ def to_json_string(self, **kw: Any) -> str: @dataclass -class ScaInfo: - """Original type: sca_info = { ... }""" +class ScanRequest: + """Original type: scan_request = { ... }""" - reachable: bool - reachability_rule: bool - sca_finding_schema: int - dependency_match: DependencyMatch + meta: RawJson + project_metadata: Optional[ProjectMetadata] = None + project_config: Optional[CiConfigFromRepo] = None + scan_metadata: Optional[ScanMetadata] = None @classmethod - def from_json(cls, x: Any) -> 'ScaInfo': + def from_json(cls, x: Any) -> 'ScanRequest': if isinstance(x, dict): return cls( - reachable=_atd_read_bool(x['reachable']) if 'reachable' in x else _atd_missing_json_field('ScaInfo', 'reachable'), - reachability_rule=_atd_read_bool(x['reachability_rule']) if 'reachability_rule' in x else _atd_missing_json_field('ScaInfo', 'reachability_rule'), - sca_finding_schema=_atd_read_int(x['sca_finding_schema']) if 'sca_finding_schema' in x else _atd_missing_json_field('ScaInfo', 'sca_finding_schema'), - dependency_match=DependencyMatch.from_json(x['dependency_match']) if 'dependency_match' in x else _atd_missing_json_field('ScaInfo', 'dependency_match'), + meta=RawJson.from_json(x['meta']) if 'meta' in x else _atd_missing_json_field('ScanRequest', 'meta'), + project_metadata=ProjectMetadata.from_json(x['project_metadata']) if 'project_metadata' in x else None, + project_config=CiConfigFromRepo.from_json(x['project_config']) if 'project_config' in x else None, + scan_metadata=ScanMetadata.from_json(x['scan_metadata']) if 'scan_metadata' in x else None, ) else: - _atd_bad_json('ScaInfo', x) + _atd_bad_json('ScanRequest', x) def to_json(self) -> Any: res: Dict[str, Any] = {} - res['reachable'] = _atd_write_bool(self.reachable) - res['reachability_rule'] = _atd_write_bool(self.reachability_rule) - res['sca_finding_schema'] = _atd_write_int(self.sca_finding_schema) - res['dependency_match'] = (lambda x: x.to_json())(self.dependency_match) + res['meta'] = (lambda x: x.to_json())(self.meta) + if self.project_metadata is not None: + res['project_metadata'] = (lambda x: x.to_json())(self.project_metadata) + if self.project_config is not None: + res['project_config'] = (lambda x: x.to_json())(self.project_config) + if self.scan_metadata is not None: + res['scan_metadata'] = (lambda x: x.to_json())(self.scan_metadata) return res @classmethod - def from_json_string(cls, x: str) -> 'ScaInfo': + def from_json_string(cls, x: str) -> 'ScanRequest': 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 SarifFormatReturn: - """Original type: sarif_format_return = { ... }""" +@dataclass +class CiEnv: + """Original type: ci_env""" - output: str - format_time_seconds: float + value: Dict[str, str] @classmethod - def from_json(cls, x: Any) -> 'SarifFormatReturn': - if isinstance(x, dict): - return cls( - output=_atd_read_string(x['output']) if 'output' in x else _atd_missing_json_field('SarifFormatReturn', 'output'), - format_time_seconds=_atd_read_float(x['format_time_seconds']) if 'format_time_seconds' in x else _atd_missing_json_field('SarifFormatReturn', 'format_time_seconds'), - ) - else: - _atd_bad_json('SarifFormatReturn', x) + def from_json(cls, x: Any) -> 'CiEnv': + return cls(_atd_read_assoc_object_into_dict(_atd_read_string)(x)) def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['output'] = _atd_write_string(self.output) - res['format_time_seconds'] = _atd_write_float(self.format_time_seconds) - return res + return _atd_write_assoc_dict_to_object(_atd_write_string)(self.value) @classmethod - def from_json_string(cls, x: str) -> 'SarifFormatReturn': + def from_json_string(cls, x: str) -> 'CiEnv': 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 ResolutionCmdFailed: - """Original type: resolution_cmd_failed = { ... }""" +@dataclass +class CiConfig: + """Original type: ci_config = { ... }""" - command: str - message: str + env: CiEnv + enabled_products: List[Product] + ignored_files: List[str] + autofix: bool = field(default_factory=lambda: False) + deepsemgrep: bool = field(default_factory=lambda: False) + dependency_query: bool = field(default_factory=lambda: False) + path_to_transitivity: bool = field(default_factory=lambda: False) @classmethod - def from_json(cls, x: Any) -> 'ResolutionCmdFailed': + def from_json(cls, x: Any) -> 'CiConfig': if isinstance(x, dict): return cls( - command=_atd_read_string(x['command']) if 'command' in x else _atd_missing_json_field('ResolutionCmdFailed', 'command'), - message=_atd_read_string(x['message']) if 'message' in x else _atd_missing_json_field('ResolutionCmdFailed', 'message'), + env=CiEnv.from_json(x['env']) if 'env' in x else _atd_missing_json_field('CiConfig', 'env'), + enabled_products=_atd_read_list(Product.from_json)(x['enabled_products']) if 'enabled_products' in x else _atd_missing_json_field('CiConfig', 'enabled_products'), + ignored_files=_atd_read_list(_atd_read_string)(x['ignored_files']) if 'ignored_files' in x else _atd_missing_json_field('CiConfig', 'ignored_files'), + autofix=_atd_read_bool(x['autofix']) if 'autofix' in x else False, + deepsemgrep=_atd_read_bool(x['deepsemgrep']) if 'deepsemgrep' in x else False, + dependency_query=_atd_read_bool(x['dependency_query']) if 'dependency_query' in x else False, + path_to_transitivity=_atd_read_bool(x['path_to_transitivity']) if 'path_to_transitivity' in x else False, ) else: - _atd_bad_json('ResolutionCmdFailed', x) + _atd_bad_json('CiConfig', x) def to_json(self) -> Any: res: Dict[str, Any] = {} - res['command'] = _atd_write_string(self.command) - res['message'] = _atd_write_string(self.message) + res['env'] = (lambda x: x.to_json())(self.env) + res['enabled_products'] = _atd_write_list((lambda x: x.to_json()))(self.enabled_products) + res['ignored_files'] = _atd_write_list(_atd_write_string)(self.ignored_files) + res['autofix'] = _atd_write_bool(self.autofix) + res['deepsemgrep'] = _atd_write_bool(self.deepsemgrep) + res['dependency_query'] = _atd_write_bool(self.dependency_query) + res['path_to_transitivity'] = _atd_write_bool(self.path_to_transitivity) return res @classmethod - def from_json_string(cls, x: str) -> 'ResolutionCmdFailed': + def from_json_string(cls, x: str) -> 'CiConfig': 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 UnsupportedManifest: - """Original type: resolution_error = [ ... | UnsupportedManifest | ... ]""" +@dataclass +class Message: + """Original type: action = [ ... | Message of ... | ... ]""" + + value: str @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'UnsupportedManifest' + return 'Message' - @staticmethod - def to_json() -> Any: - return 'UnsupportedManifest' + def to_json(self) -> Any: + return ['Message', _atd_write_string(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True) -class MissingRequirement: - """Original type: resolution_error = [ ... | MissingRequirement of ... | ... ]""" +@dataclass +class Delay: + """Original type: action = [ ... | Delay of ... | ... ]""" - value: str + value: float @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'MissingRequirement' + return 'Delay' def to_json(self) -> Any: - return ['MissingRequirement', _atd_write_string(self.value)] + return ['Delay', _atd_write_float(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True) -class ResolutionCmdFailed_: - """Original type: resolution_error = [ ... | ResolutionCmdFailed of ... | ... ]""" +@dataclass +class Exit: + """Original type: action = [ ... | Exit of ... | ... ]""" - value: ResolutionCmdFailed + value: int @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'ResolutionCmdFailed_' + return 'Exit' def to_json(self) -> Any: - return ['ResolutionCmdFailed', (lambda x: x.to_json())(self.value)] + return ['Exit', _atd_write_int(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True) -class ParseDependenciesFailed: - """Original type: resolution_error = [ ... | ParseDependenciesFailed of ... | ... ]""" +@dataclass +class Action: + """Original type: action = [ ... ]""" - value: str + value: Union[Message, Delay, Exit] @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'ParseDependenciesFailed' + return self.value.kind + + @classmethod + def from_json(cls, x: Any) -> 'Action': + if isinstance(x, List) and len(x) == 2: + cons = x[0] + if cons == 'Message': + return cls(Message(_atd_read_string(x[1]))) + if cons == 'Delay': + return cls(Delay(_atd_read_float(x[1]))) + if cons == 'Exit': + return cls(Exit(_atd_read_int(x[1]))) + _atd_bad_json('Action', x) + _atd_bad_json('Action', x) def to_json(self) -> Any: - return ['ParseDependenciesFailed', _atd_write_string(self.value)] + return self.value.to_json() + + @classmethod + def from_json_string(cls, x: str) -> 'Action': + 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 ResolutionError: - """Original type: resolution_error = [ ... ]""" - - value: Union[UnsupportedManifest, MissingRequirement, ResolutionCmdFailed_, ParseDependenciesFailed] +@dataclass +class CiConfigFromCloud: + """Original type: ci_config_from_cloud = { ... }""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return self.value.kind + repo_config: CiConfig + org_config: Optional[CiConfig] = None + dirs_config: Optional[List[Tuple[Fpath, CiConfig]]] = None + actions: List[Action] = field(default_factory=lambda: []) @classmethod - def from_json(cls, x: Any) -> 'ResolutionError': - if isinstance(x, str): - if x == 'UnsupportedManifest': - return cls(UnsupportedManifest()) - _atd_bad_json('ResolutionError', x) - if isinstance(x, List) and len(x) == 2: - cons = x[0] - if cons == 'MissingRequirement': - return cls(MissingRequirement(_atd_read_string(x[1]))) - if cons == 'ResolutionCmdFailed': - return cls(ResolutionCmdFailed_(ResolutionCmdFailed.from_json(x[1]))) - if cons == 'ParseDependenciesFailed': - return cls(ParseDependenciesFailed(_atd_read_string(x[1]))) - _atd_bad_json('ResolutionError', x) - _atd_bad_json('ResolutionError', x) + def from_json(cls, x: Any) -> 'CiConfigFromCloud': + if isinstance(x, dict): + return cls( + repo_config=CiConfig.from_json(x['repo_config']) if 'repo_config' in x else _atd_missing_json_field('CiConfigFromCloud', 'repo_config'), + org_config=CiConfig.from_json(x['org_config']) if 'org_config' in x else None, + dirs_config=_atd_read_list((lambda x: (Fpath.from_json(x[0]), CiConfig.from_json(x[1])) if isinstance(x, list) and len(x) == 2 else _atd_bad_json('array of length 2', x)))(x['dirs_config']) if 'dirs_config' in x else None, + actions=_atd_read_list(Action.from_json)(x['actions']) if 'actions' in x else [], + ) + else: + _atd_bad_json('CiConfigFromCloud', x) def to_json(self) -> Any: - return self.value.to_json() + res: Dict[str, Any] = {} + res['repo_config'] = (lambda x: x.to_json())(self.repo_config) + if self.org_config is not None: + res['org_config'] = (lambda x: x.to_json())(self.org_config) + if self.dirs_config is not None: + res['dirs_config'] = _atd_write_list((lambda x: [(lambda x: x.to_json())(x[0]), (lambda x: x.to_json())(x[1])] if isinstance(x, tuple) and len(x) == 2 else _atd_bad_python('tuple of length 2', x)))(self.dirs_config) + res['actions'] = _atd_write_list((lambda x: x.to_json()))(self.actions) + return res @classmethod - def from_json_string(cls, x: str) -> 'ResolutionError': + def from_json_string(cls, x: str) -> 'CiConfigFromCloud': 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 IncompatibleRule: - """Original type: incompatible_rule = { ... }""" +@dataclass +class ScanConfig: + """Original type: scan_config = { ... }""" - rule_id: RuleId - this_version: Version - min_version: Optional[Version] = None - max_version: Optional[Version] = None + deployment_id: int + deployment_name: str + policy_names: List[str] + rule_config: str + ci_config_from_cloud: Optional[CiConfigFromCloud] = None + autofix: bool = field(default_factory=lambda: False) + deepsemgrep: bool = field(default_factory=lambda: False) + dependency_query: bool = field(default_factory=lambda: False) + path_to_transitivity: bool = field(default_factory=lambda: False) + triage_ignored_syntactic_ids: List[str] = field(default_factory=lambda: []) + triage_ignored_match_based_ids: List[str] = field(default_factory=lambda: []) + ignored_files: List[str] = field(default_factory=lambda: []) + enabled_products: Optional[List[Product]] = None + actions: List[Action] = field(default_factory=lambda: []) @classmethod - def from_json(cls, x: Any) -> 'IncompatibleRule': + def from_json(cls, x: Any) -> 'ScanConfig': if isinstance(x, dict): return cls( - rule_id=RuleId.from_json(x['rule_id']) if 'rule_id' in x else _atd_missing_json_field('IncompatibleRule', 'rule_id'), - this_version=Version.from_json(x['this_version']) if 'this_version' in x else _atd_missing_json_field('IncompatibleRule', 'this_version'), - min_version=Version.from_json(x['min_version']) if 'min_version' in x else None, - max_version=Version.from_json(x['max_version']) if 'max_version' in x else None, + deployment_id=_atd_read_int(x['deployment_id']) if 'deployment_id' in x else _atd_missing_json_field('ScanConfig', 'deployment_id'), + deployment_name=_atd_read_string(x['deployment_name']) if 'deployment_name' in x else _atd_missing_json_field('ScanConfig', 'deployment_name'), + policy_names=_atd_read_list(_atd_read_string)(x['policy_names']) if 'policy_names' in x else _atd_missing_json_field('ScanConfig', 'policy_names'), + rule_config=_atd_read_string(x['rule_config']) if 'rule_config' in x else _atd_missing_json_field('ScanConfig', 'rule_config'), + ci_config_from_cloud=CiConfigFromCloud.from_json(x['ci_config_from_cloud']) if 'ci_config_from_cloud' in x else None, + autofix=_atd_read_bool(x['autofix']) if 'autofix' in x else False, + deepsemgrep=_atd_read_bool(x['deepsemgrep']) if 'deepsemgrep' in x else False, + dependency_query=_atd_read_bool(x['dependency_query']) if 'dependency_query' in x else False, + path_to_transitivity=_atd_read_bool(x['path_to_transitivity']) if 'path_to_transitivity' in x else False, + triage_ignored_syntactic_ids=_atd_read_list(_atd_read_string)(x['triage_ignored_syntactic_ids']) if 'triage_ignored_syntactic_ids' in x else [], + triage_ignored_match_based_ids=_atd_read_list(_atd_read_string)(x['triage_ignored_match_based_ids']) if 'triage_ignored_match_based_ids' in x else [], + ignored_files=_atd_read_list(_atd_read_string)(x['ignored_files']) if 'ignored_files' in x else [], + enabled_products=_atd_read_list(Product.from_json)(x['enabled_products']) if 'enabled_products' in x else None, + actions=_atd_read_list(Action.from_json)(x['actions']) if 'actions' in x else [], ) else: - _atd_bad_json('IncompatibleRule', x) + _atd_bad_json('ScanConfig', x) def to_json(self) -> Any: res: Dict[str, Any] = {} - res['rule_id'] = (lambda x: x.to_json())(self.rule_id) - res['this_version'] = (lambda x: x.to_json())(self.this_version) - if self.min_version is not None: - res['min_version'] = (lambda x: x.to_json())(self.min_version) - if self.max_version is not None: - res['max_version'] = (lambda x: x.to_json())(self.max_version) + res['deployment_id'] = _atd_write_int(self.deployment_id) + res['deployment_name'] = _atd_write_string(self.deployment_name) + res['policy_names'] = _atd_write_list(_atd_write_string)(self.policy_names) + res['rule_config'] = _atd_write_string(self.rule_config) + if self.ci_config_from_cloud is not None: + res['ci_config_from_cloud'] = (lambda x: x.to_json())(self.ci_config_from_cloud) + res['autofix'] = _atd_write_bool(self.autofix) + res['deepsemgrep'] = _atd_write_bool(self.deepsemgrep) + res['dependency_query'] = _atd_write_bool(self.dependency_query) + res['path_to_transitivity'] = _atd_write_bool(self.path_to_transitivity) + res['triage_ignored_syntactic_ids'] = _atd_write_list(_atd_write_string)(self.triage_ignored_syntactic_ids) + res['triage_ignored_match_based_ids'] = _atd_write_list(_atd_write_string)(self.triage_ignored_match_based_ids) + res['ignored_files'] = _atd_write_list(_atd_write_string)(self.ignored_files) + if self.enabled_products is not None: + res['enabled_products'] = _atd_write_list((lambda x: x.to_json()))(self.enabled_products) + res['actions'] = _atd_write_list((lambda x: x.to_json()))(self.actions) return res @classmethod - def from_json_string(cls, x: str) -> 'IncompatibleRule': + def from_json_string(cls, x: str) -> 'ScanConfig': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class LexicalError: - """Original type: error_type = [ ... | LexicalError | ... ]""" +@dataclass +class GemfileLock_: + """Original type: sca_parser_name = [ ... | Gemfile_lock | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'LexicalError' + return 'GemfileLock_' @staticmethod def to_json() -> Any: - return 'Lexical error' + return 'gemfile_lock' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class ParseError: - """Original type: error_type = [ ... | ParseError | ... ]""" +@dataclass +class GoMod2: + """Original type: sca_parser_name = [ ... | Go_mod | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'ParseError' + return 'GoMod2' @staticmethod def to_json() -> Any: - return 'Syntax error' + return 'go_mod' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class OtherParseError: - """Original type: error_type = [ ... | OtherParseError | ... ]""" +@dataclass +class GoSum: + """Original type: sca_parser_name = [ ... | Go_sum | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'OtherParseError' + return 'GoSum' @staticmethod def to_json() -> Any: - return 'Other syntax error' + return 'go_sum' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class AstBuilderError: - """Original type: error_type = [ ... | AstBuilderError | ... ]""" +@dataclass +class GradleLockfile_: + """Original type: sca_parser_name = [ ... | Gradle_lockfile | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'AstBuilderError' + return 'GradleLockfile_' @staticmethod def to_json() -> Any: - return 'AST builder error' + return 'gradle_lockfile' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class RuleParseError: - """Original type: error_type = [ ... | RuleParseError | ... ]""" +@dataclass +class GradleBuild: + """Original type: sca_parser_name = [ ... | Gradle_build | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'RuleParseError' + return 'GradleBuild' @staticmethod def to_json() -> Any: - return 'Rule parse error' + return 'gradle_build' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class SemgrepWarning: - """Original type: error_type = [ ... | SemgrepWarning | ... ]""" +@dataclass +class Jsondoc: + """Original type: sca_parser_name = [ ... | Jsondoc | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'SemgrepWarning' + return 'Jsondoc' @staticmethod def to_json() -> Any: - return 'SemgrepWarning' + return 'jsondoc' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class SemgrepError: - """Original type: error_type = [ ... | SemgrepError | ... ]""" +@dataclass +class Pipfile_: + """Original type: sca_parser_name = [ ... | Pipfile | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'SemgrepError' + return 'Pipfile_' @staticmethod def to_json() -> Any: - return 'SemgrepError' + return 'pipfile' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class InvalidRuleSchemaError: - """Original type: error_type = [ ... | InvalidRuleSchemaError | ... ]""" +@dataclass +class PnpmLock_: + """Original type: sca_parser_name = [ ... | Pnpm_lock | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'InvalidRuleSchemaError' + return 'PnpmLock_' @staticmethod def to_json() -> Any: - return 'InvalidRuleSchemaError' + return 'pnpm_lock' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class UnknownLanguageError: - """Original type: error_type = [ ... | UnknownLanguageError | ... ]""" +@dataclass +class PoetryLock_: + """Original type: sca_parser_name = [ ... | Poetry_lock | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'UnknownLanguageError' + return 'PoetryLock_' @staticmethod def to_json() -> Any: - return 'UnknownLanguageError' + return 'poetry_lock' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class InvalidYaml: - """Original type: error_type = [ ... | InvalidYaml | ... ]""" +@dataclass +class PyprojectToml_: + """Original type: sca_parser_name = [ ... | Pyproject_toml | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'InvalidYaml' + return 'PyprojectToml_' @staticmethod def to_json() -> Any: - return 'Invalid YAML' + return 'pyproject_toml' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class MatchingError: - """Original type: error_type = [ ... | MatchingError | ... ]""" +@dataclass +class Requirements: + """Original type: sca_parser_name = [ ... | Requirements | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'MatchingError' + return 'Requirements' @staticmethod def to_json() -> Any: - return 'Internal matching error' + return 'requirements' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class SemgrepMatchFound: - """Original type: error_type = [ ... | SemgrepMatchFound | ... ]""" +@dataclass +class Yarn1: + """Original type: sca_parser_name = [ ... | Yarn_1 | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'SemgrepMatchFound' + return 'Yarn1' @staticmethod def to_json() -> Any: - return 'Semgrep match found' + return 'yarn_1' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class TooManyMatches_: - """Original type: error_type = [ ... | TooManyMatches | ... ]""" +@dataclass +class Yarn2: + """Original type: sca_parser_name = [ ... | Yarn_2 | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'Yarn2' + + @staticmethod + def to_json() -> Any: + return 'yarn_2' + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass +class Pomtree: + """Original type: sca_parser_name = [ ... | Pomtree | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'TooManyMatches_' + return 'Pomtree' @staticmethod def to_json() -> Any: - return 'Too many matches' + return 'pomtree' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class FatalError: - """Original type: error_type = [ ... | FatalError | ... ]""" +@dataclass +class CargoParser: + """Original type: sca_parser_name = [ ... | Cargo_parser | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'FatalError' + return 'CargoParser' @staticmethod def to_json() -> Any: - return 'Fatal error' + return 'cargo' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class Timeout: - """Original type: error_type = [ ... | Timeout | ... ]""" +@dataclass +class ComposerLock_: + """Original type: sca_parser_name = [ ... | Composer_lock | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Timeout' + return 'ComposerLock_' @staticmethod def to_json() -> Any: - return 'Timeout' + return 'composer_lock' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class OutOfMemory: - """Original type: error_type = [ ... | OutOfMemory | ... ]""" +@dataclass +class PubspecLock_: + """Original type: sca_parser_name = [ ... | Pubspec_lock | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'OutOfMemory' + return 'PubspecLock_' @staticmethod def to_json() -> Any: - return 'Out of memory' + return 'pubspec_lock' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class StackOverflow: - """Original type: error_type = [ ... | StackOverflow | ... ]""" +@dataclass +class PackageSwift_: + """Original type: sca_parser_name = [ ... | Package_swift | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'StackOverflow' + return 'PackageSwift_' @staticmethod def to_json() -> Any: - return 'Stack overflow' + return 'package_swift' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class TimeoutDuringInterfile: - """Original type: error_type = [ ... | TimeoutDuringInterfile | ... ]""" +@dataclass +class PackageResolved: + """Original type: sca_parser_name = [ ... | Package_resolved | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'TimeoutDuringInterfile' + return 'PackageResolved' @staticmethod def to_json() -> Any: - return 'Timeout during interfile analysis' + return 'package_resolved' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class OutOfMemoryDuringInterfile: - """Original type: error_type = [ ... | OutOfMemoryDuringInterfile | ... ]""" +@dataclass +class MixLock_: + """Original type: sca_parser_name = [ ... | Mix_lock | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'OutOfMemoryDuringInterfile' + return 'MixLock_' @staticmethod def to_json() -> Any: - return 'OOM during interfile analysis' + return 'mix_lock' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class MissingPlugin: - """Original type: error_type = [ ... | MissingPlugin | ... ]""" +@dataclass +class ScaParserName: + """Original type: sca_parser_name = [ ... ]""" + + value: Union[GemfileLock_, GoMod2, GoSum, GradleLockfile_, GradleBuild, Jsondoc, Pipfile_, PnpmLock_, PoetryLock_, PyprojectToml_, Requirements, Yarn1, Yarn2, Pomtree, CargoParser, ComposerLock_, PubspecLock_, PackageSwift_, PackageResolved, MixLock_] @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'MissingPlugin' + return self.value.kind - @staticmethod - def to_json() -> Any: - return 'Missing plugin' + @classmethod + def from_json(cls, x: Any) -> 'ScaParserName': + if isinstance(x, str): + if x == 'gemfile_lock': + return cls(GemfileLock_()) + if x == 'go_mod': + return cls(GoMod2()) + if x == 'go_sum': + return cls(GoSum()) + if x == 'gradle_lockfile': + return cls(GradleLockfile_()) + if x == 'gradle_build': + return cls(GradleBuild()) + if x == 'jsondoc': + return cls(Jsondoc()) + if x == 'pipfile': + return cls(Pipfile_()) + if x == 'pnpm_lock': + return cls(PnpmLock_()) + if x == 'poetry_lock': + return cls(PoetryLock_()) + if x == 'pyproject_toml': + return cls(PyprojectToml_()) + if x == 'requirements': + return cls(Requirements()) + if x == 'yarn_1': + return cls(Yarn1()) + if x == 'yarn_2': + return cls(Yarn2()) + if x == 'pomtree': + return cls(Pomtree()) + if x == 'cargo': + return cls(CargoParser()) + if x == 'composer_lock': + return cls(ComposerLock_()) + if x == 'pubspec_lock': + return cls(PubspecLock_()) + if x == 'package_swift': + return cls(PackageSwift_()) + if x == 'package_resolved': + return cls(PackageResolved()) + if x == 'mix_lock': + return cls(MixLock_()) + _atd_bad_json('ScaParserName', x) + _atd_bad_json('ScaParserName', x) + + def to_json(self) -> Any: + return self.value.to_json() + + @classmethod + def from_json_string(cls, x: str) -> 'ScaParserName': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class PatternParseError: - """Original type: error_type = [ ... | PatternParseError of ... | ... ]""" +@dataclass(frozen=True) +class DependencyChild: + """Original type: dependency_child = { ... }""" - value: List[str] + package: str + version: str - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'PatternParseError' + @classmethod + def from_json(cls, x: Any) -> 'DependencyChild': + if isinstance(x, dict): + return cls( + package=_atd_read_string(x['package']) if 'package' in x else _atd_missing_json_field('DependencyChild', 'package'), + version=_atd_read_string(x['version']) if 'version' in x else _atd_missing_json_field('DependencyChild', 'version'), + ) + else: + _atd_bad_json('DependencyChild', x) def to_json(self) -> Any: - return ['PatternParseError', _atd_write_list(_atd_write_string)(self.value)] + res: Dict[str, Any] = {} + res['package'] = _atd_write_string(self.package) + res['version'] = _atd_write_string(self.version) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'DependencyChild': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class PartialParsing: - """Original type: error_type = [ ... | PartialParsing of ... | ... ]""" +@dataclass +class FoundDependency: + """Original type: found_dependency = { ... }""" - value: List[Location] + package: str + version: str + ecosystem: Ecosystem + allowed_hashes: Dict[str, List[str]] + transitivity: Transitivity + resolved_url: Optional[str] = None + manifest_path: Optional[Fpath] = None + lockfile_path: Optional[Fpath] = None + line_number: Optional[int] = None + children: Optional[List[DependencyChild]] = None + git_ref: Optional[str] = None - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'PartialParsing' + @classmethod + def from_json(cls, x: Any) -> 'FoundDependency': + if isinstance(x, dict): + return cls( + package=_atd_read_string(x['package']) if 'package' in x else _atd_missing_json_field('FoundDependency', 'package'), + version=_atd_read_string(x['version']) if 'version' in x else _atd_missing_json_field('FoundDependency', 'version'), + ecosystem=Ecosystem.from_json(x['ecosystem']) if 'ecosystem' in x else _atd_missing_json_field('FoundDependency', 'ecosystem'), + allowed_hashes=_atd_read_assoc_object_into_dict(_atd_read_list(_atd_read_string))(x['allowed_hashes']) if 'allowed_hashes' in x else _atd_missing_json_field('FoundDependency', 'allowed_hashes'), + transitivity=Transitivity.from_json(x['transitivity']) if 'transitivity' in x else _atd_missing_json_field('FoundDependency', 'transitivity'), + resolved_url=_atd_read_string(x['resolved_url']) if 'resolved_url' in x else None, + manifest_path=Fpath.from_json(x['manifest_path']) if 'manifest_path' in x else None, + lockfile_path=Fpath.from_json(x['lockfile_path']) if 'lockfile_path' in x else None, + line_number=_atd_read_int(x['line_number']) if 'line_number' in x else None, + children=_atd_read_list(DependencyChild.from_json)(x['children']) if 'children' in x else None, + git_ref=_atd_read_string(x['git_ref']) if 'git_ref' in x else None, + ) + else: + _atd_bad_json('FoundDependency', x) def to_json(self) -> Any: - return ['PartialParsing', _atd_write_list((lambda x: x.to_json()))(self.value)] + res: Dict[str, Any] = {} + res['package'] = _atd_write_string(self.package) + res['version'] = _atd_write_string(self.version) + res['ecosystem'] = (lambda x: x.to_json())(self.ecosystem) + res['allowed_hashes'] = _atd_write_assoc_dict_to_object(_atd_write_list(_atd_write_string))(self.allowed_hashes) + res['transitivity'] = (lambda x: x.to_json())(self.transitivity) + if self.resolved_url is not None: + res['resolved_url'] = _atd_write_string(self.resolved_url) + if self.manifest_path is not None: + res['manifest_path'] = (lambda x: x.to_json())(self.manifest_path) + if self.lockfile_path is not None: + res['lockfile_path'] = (lambda x: x.to_json())(self.lockfile_path) + if self.line_number is not None: + res['line_number'] = _atd_write_int(self.line_number) + if self.children is not None: + res['children'] = _atd_write_list((lambda x: x.to_json()))(self.children) + if self.git_ref is not None: + res['git_ref'] = _atd_write_string(self.git_ref) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'FoundDependency': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class IncompatibleRule_: - """Original type: error_type = [ ... | IncompatibleRule of ... | ... ]""" +@dataclass +class DependencyPattern: + """Original type: dependency_pattern = { ... }""" - value: IncompatibleRule + ecosystem: Ecosystem + package: str + semver_range: str - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'IncompatibleRule_' + @classmethod + def from_json(cls, x: Any) -> 'DependencyPattern': + if isinstance(x, dict): + return cls( + ecosystem=Ecosystem.from_json(x['ecosystem']) if 'ecosystem' in x else _atd_missing_json_field('DependencyPattern', 'ecosystem'), + package=_atd_read_string(x['package']) if 'package' in x else _atd_missing_json_field('DependencyPattern', 'package'), + semver_range=_atd_read_string(x['semver_range']) if 'semver_range' in x else _atd_missing_json_field('DependencyPattern', 'semver_range'), + ) + else: + _atd_bad_json('DependencyPattern', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['ecosystem'] = (lambda x: x.to_json())(self.ecosystem) + res['package'] = _atd_write_string(self.package) + res['semver_range'] = _atd_write_string(self.semver_range) + return res - def to_json(self) -> Any: - return ['IncompatibleRule', (lambda x: x.to_json())(self.value)] + @classmethod + def from_json_string(cls, x: str) -> 'DependencyPattern': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class PatternParseError0: - """Original type: error_type = [ ... | PatternParseError0 | ... ]""" - - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'PatternParseError0' - - @staticmethod - def to_json() -> Any: - return 'Pattern parse error' - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) +@dataclass +class DependencyMatch: + """Original type: dependency_match = { ... }""" + dependency_pattern: DependencyPattern + found_dependency: FoundDependency + lockfile: str -@dataclass(frozen=True, order=True) -class IncompatibleRule0: - """Original type: error_type = [ ... | IncompatibleRule0 | ... ]""" + @classmethod + def from_json(cls, x: Any) -> 'DependencyMatch': + if isinstance(x, dict): + return cls( + dependency_pattern=DependencyPattern.from_json(x['dependency_pattern']) if 'dependency_pattern' in x else _atd_missing_json_field('DependencyMatch', 'dependency_pattern'), + found_dependency=FoundDependency.from_json(x['found_dependency']) if 'found_dependency' in x else _atd_missing_json_field('DependencyMatch', 'found_dependency'), + lockfile=_atd_read_string(x['lockfile']) if 'lockfile' in x else _atd_missing_json_field('DependencyMatch', 'lockfile'), + ) + else: + _atd_bad_json('DependencyMatch', x) - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'IncompatibleRule0' + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['dependency_pattern'] = (lambda x: x.to_json())(self.dependency_pattern) + res['found_dependency'] = (lambda x: x.to_json())(self.found_dependency) + res['lockfile'] = _atd_write_string(self.lockfile) + return res - @staticmethod - def to_json() -> Any: - return 'Incompatible rule' + @classmethod + def from_json_string(cls, x: str) -> 'DependencyMatch': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class DependencyResolutionError: - """Original type: error_type = [ ... | DependencyResolutionError of ... | ... ]""" +@dataclass +class ScaInfo: + """Original type: sca_info = { ... }""" - value: ResolutionError + reachable: bool + reachability_rule: bool + sca_finding_schema: int + dependency_match: DependencyMatch - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'DependencyResolutionError' + @classmethod + def from_json(cls, x: Any) -> 'ScaInfo': + if isinstance(x, dict): + return cls( + reachable=_atd_read_bool(x['reachable']) if 'reachable' in x else _atd_missing_json_field('ScaInfo', 'reachable'), + reachability_rule=_atd_read_bool(x['reachability_rule']) if 'reachability_rule' in x else _atd_missing_json_field('ScaInfo', 'reachability_rule'), + sca_finding_schema=_atd_read_int(x['sca_finding_schema']) if 'sca_finding_schema' in x else _atd_missing_json_field('ScaInfo', 'sca_finding_schema'), + dependency_match=DependencyMatch.from_json(x['dependency_match']) if 'dependency_match' in x else _atd_missing_json_field('ScaInfo', 'dependency_match'), + ) + else: + _atd_bad_json('ScaInfo', x) def to_json(self) -> Any: - return ['DependencyResolutionError', (lambda x: x.to_json())(self.value)] + res: Dict[str, Any] = {} + res['reachable'] = _atd_write_bool(self.reachable) + res['reachability_rule'] = _atd_write_bool(self.reachability_rule) + res['sca_finding_schema'] = _atd_write_int(self.sca_finding_schema) + res['dependency_match'] = (lambda x: x.to_json())(self.dependency_match) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'ScaInfo': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True, order=True) -class ErrorType: - """Original type: error_type = [ ... ]""" - - value: Union[LexicalError, ParseError, OtherParseError, AstBuilderError, RuleParseError, SemgrepWarning, SemgrepError, InvalidRuleSchemaError, UnknownLanguageError, InvalidYaml, MatchingError, SemgrepMatchFound, TooManyMatches_, FatalError, Timeout, OutOfMemory, StackOverflow, TimeoutDuringInterfile, OutOfMemoryDuringInterfile, MissingPlugin, PatternParseError, PartialParsing, IncompatibleRule_, PatternParseError0, IncompatibleRule0, DependencyResolutionError] +@dataclass(frozen=True) +class SarifFormatReturn: + """Original type: sarif_format_return = { ... }""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return self.value.kind + output: str + format_time_seconds: float @classmethod - def from_json(cls, x: Any) -> 'ErrorType': - if isinstance(x, str): - if x == 'Lexical error': - return cls(LexicalError()) - if x == 'Syntax error': - return cls(ParseError()) - if x == 'Other syntax error': - return cls(OtherParseError()) - if x == 'AST builder error': - return cls(AstBuilderError()) - if x == 'Rule parse error': - return cls(RuleParseError()) - if x == 'SemgrepWarning': - return cls(SemgrepWarning()) - if x == 'SemgrepError': - return cls(SemgrepError()) - if x == 'InvalidRuleSchemaError': - return cls(InvalidRuleSchemaError()) - if x == 'UnknownLanguageError': - return cls(UnknownLanguageError()) - if x == 'Invalid YAML': - return cls(InvalidYaml()) - if x == 'Internal matching error': - return cls(MatchingError()) - if x == 'Semgrep match found': - return cls(SemgrepMatchFound()) - if x == 'Too many matches': - return cls(TooManyMatches_()) - if x == 'Fatal error': - return cls(FatalError()) - if x == 'Timeout': - return cls(Timeout()) - if x == 'Out of memory': - return cls(OutOfMemory()) - if x == 'Stack overflow': - return cls(StackOverflow()) - if x == 'Timeout during interfile analysis': - return cls(TimeoutDuringInterfile()) - if x == 'OOM during interfile analysis': - return cls(OutOfMemoryDuringInterfile()) - if x == 'Missing plugin': - return cls(MissingPlugin()) - if x == 'Pattern parse error': - return cls(PatternParseError0()) - if x == 'Incompatible rule': - return cls(IncompatibleRule0()) - _atd_bad_json('ErrorType', x) - if isinstance(x, List) and len(x) == 2: - cons = x[0] - if cons == 'PatternParseError': - return cls(PatternParseError(_atd_read_list(_atd_read_string)(x[1]))) - if cons == 'PartialParsing': - return cls(PartialParsing(_atd_read_list(Location.from_json)(x[1]))) - if cons == 'IncompatibleRule': - return cls(IncompatibleRule_(IncompatibleRule.from_json(x[1]))) - if cons == 'DependencyResolutionError': - return cls(DependencyResolutionError(ResolutionError.from_json(x[1]))) - _atd_bad_json('ErrorType', x) - _atd_bad_json('ErrorType', x) + def from_json(cls, x: Any) -> 'SarifFormatReturn': + if isinstance(x, dict): + return cls( + output=_atd_read_string(x['output']) if 'output' in x else _atd_missing_json_field('SarifFormatReturn', 'output'), + format_time_seconds=_atd_read_float(x['format_time_seconds']) if 'format_time_seconds' in x else _atd_missing_json_field('SarifFormatReturn', 'format_time_seconds'), + ) + else: + _atd_bad_json('SarifFormatReturn', x) def to_json(self) -> Any: - return self.value.to_json() + res: Dict[str, Any] = {} + res['output'] = _atd_write_string(self.output) + res['format_time_seconds'] = _atd_write_float(self.format_time_seconds) + return res @classmethod - def from_json_string(cls, x: str) -> 'ErrorType': + def from_json_string(cls, x: str) -> 'SarifFormatReturn': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class ErrorSpan: - """Original type: error_span = { ... }""" +@dataclass(frozen=True) +class ResolutionCmdFailed: + """Original type: resolution_cmd_failed = { ... }""" - file: Fpath - start: Position - end: Position - source_hash: Optional[str] = None - config_start: Optional[Optional[Position]] = None - config_end: Optional[Optional[Position]] = None - config_path: Optional[Optional[List[str]]] = None - context_start: Optional[Optional[Position]] = None - context_end: Optional[Optional[Position]] = None + command: str + message: str @classmethod - def from_json(cls, x: Any) -> 'ErrorSpan': + def from_json(cls, x: Any) -> 'ResolutionCmdFailed': if isinstance(x, dict): return cls( - file=Fpath.from_json(x['file']) if 'file' in x else _atd_missing_json_field('ErrorSpan', 'file'), - start=Position.from_json(x['start']) if 'start' in x else _atd_missing_json_field('ErrorSpan', 'start'), - end=Position.from_json(x['end']) if 'end' in x else _atd_missing_json_field('ErrorSpan', 'end'), - source_hash=_atd_read_string(x['source_hash']) if 'source_hash' in x else None, - config_start=_atd_read_nullable(Position.from_json)(x['config_start']) if 'config_start' in x else None, - config_end=_atd_read_nullable(Position.from_json)(x['config_end']) if 'config_end' in x else None, - config_path=_atd_read_nullable(_atd_read_list(_atd_read_string))(x['config_path']) if 'config_path' in x else None, - context_start=_atd_read_nullable(Position.from_json)(x['context_start']) if 'context_start' in x else None, - context_end=_atd_read_nullable(Position.from_json)(x['context_end']) if 'context_end' in x else None, + command=_atd_read_string(x['command']) if 'command' in x else _atd_missing_json_field('ResolutionCmdFailed', 'command'), + message=_atd_read_string(x['message']) if 'message' in x else _atd_missing_json_field('ResolutionCmdFailed', 'message'), ) else: - _atd_bad_json('ErrorSpan', x) + _atd_bad_json('ResolutionCmdFailed', x) def to_json(self) -> Any: res: Dict[str, Any] = {} - res['file'] = (lambda x: x.to_json())(self.file) - res['start'] = (lambda x: x.to_json())(self.start) - res['end'] = (lambda x: x.to_json())(self.end) - if self.source_hash is not None: - res['source_hash'] = _atd_write_string(self.source_hash) - if self.config_start is not None: - res['config_start'] = _atd_write_nullable((lambda x: x.to_json()))(self.config_start) - if self.config_end is not None: - res['config_end'] = _atd_write_nullable((lambda x: x.to_json()))(self.config_end) - if self.config_path is not None: - res['config_path'] = _atd_write_nullable(_atd_write_list(_atd_write_string))(self.config_path) - if self.context_start is not None: - res['context_start'] = _atd_write_nullable((lambda x: x.to_json()))(self.context_start) - if self.context_end is not None: - res['context_end'] = _atd_write_nullable((lambda x: x.to_json()))(self.context_end) + res['command'] = _atd_write_string(self.command) + res['message'] = _atd_write_string(self.message) return res @classmethod - def from_json_string(cls, x: str) -> 'ErrorSpan': + def from_json_string(cls, x: str) -> 'ResolutionCmdFailed': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: @@ -5447,61 +5619,81 @@ def to_json_string(self, **kw: Any) -> str: @dataclass(frozen=True) -class Error_: - """Original type: error_severity = [ ... | Error | ... ]""" +class UnsupportedManifest: + """Original type: resolution_error = [ ... | UnsupportedManifest | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Error_' + return 'UnsupportedManifest' @staticmethod def to_json() -> Any: - return 'error' + return 'UnsupportedManifest' + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass(frozen=True) +class MissingRequirement: + """Original type: resolution_error = [ ... | MissingRequirement of ... | ... ]""" + + value: str + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'MissingRequirement' + + def to_json(self) -> Any: + return ['MissingRequirement', _atd_write_string(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class Warning_: - """Original type: error_severity = [ ... | Warning | ... ]""" +class ResolutionCmdFailed_: + """Original type: resolution_error = [ ... | ResolutionCmdFailed of ... | ... ]""" + + value: ResolutionCmdFailed @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Warning_' + return 'ResolutionCmdFailed_' - @staticmethod - def to_json() -> Any: - return 'warn' + def to_json(self) -> Any: + return ['ResolutionCmdFailed', (lambda x: x.to_json())(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class Info_: - """Original type: error_severity = [ ... | Info | ... ]""" +class ParseDependenciesFailed: + """Original type: resolution_error = [ ... | ParseDependenciesFailed of ... | ... ]""" + + value: str @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Info_' + return 'ParseDependenciesFailed' - @staticmethod - def to_json() -> Any: - return 'info' + def to_json(self) -> Any: + return ['ParseDependenciesFailed', _atd_write_string(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class ErrorSeverity: - """Original type: error_severity = [ ... ]""" +class ResolutionError: + """Original type: resolution_error = [ ... ]""" - value: Union[Error_, Warning_, Info_] + value: Union[UnsupportedManifest, MissingRequirement, ResolutionCmdFailed_, ParseDependenciesFailed] @property def kind(self) -> str: @@ -5509,853 +5701,595 @@ def kind(self) -> str: return self.value.kind @classmethod - def from_json(cls, x: Any) -> 'ErrorSeverity': + def from_json(cls, x: Any) -> 'ResolutionError': if isinstance(x, str): - if x == 'error': - return cls(Error_()) - if x == 'warn': - return cls(Warning_()) - if x == 'info': - return cls(Info_()) - _atd_bad_json('ErrorSeverity', x) - _atd_bad_json('ErrorSeverity', x) + if x == 'UnsupportedManifest': + return cls(UnsupportedManifest()) + _atd_bad_json('ResolutionError', x) + if isinstance(x, List) and len(x) == 2: + cons = x[0] + if cons == 'MissingRequirement': + return cls(MissingRequirement(_atd_read_string(x[1]))) + if cons == 'ResolutionCmdFailed': + return cls(ResolutionCmdFailed_(ResolutionCmdFailed.from_json(x[1]))) + if cons == 'ParseDependenciesFailed': + return cls(ParseDependenciesFailed(_atd_read_string(x[1]))) + _atd_bad_json('ResolutionError', x) + _atd_bad_json('ResolutionError', x) def to_json(self) -> Any: return self.value.to_json() @classmethod - def from_json_string(cls, x: str) -> 'ErrorSeverity': + def from_json_string(cls, x: str) -> 'ResolutionError': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class CliMatchExtra: - """Original type: cli_match_extra = { ... }""" +@dataclass(frozen=True) +class IncompatibleRule: + """Original type: incompatible_rule = { ... }""" - message: str - metadata: RawJson - severity: MatchSeverity - fingerprint: str - lines: str - metavars: Optional[Metavars] = None - fix: Optional[str] = None - fixed_lines: Optional[List[str]] = None - is_ignored: Optional[bool] = None - sca_info: Optional[ScaInfo] = None - dataflow_trace: Optional[MatchDataflowTrace] = None - engine_kind: Optional[EngineOfFinding] = None - validation_state: Optional[ValidationState] = None - historical_info: Optional[HistoricalInfo] = None - extra_extra: Optional[RawJson] = None + rule_id: RuleId + this_version: Version + min_version: Optional[Version] = None + max_version: Optional[Version] = None @classmethod - def from_json(cls, x: Any) -> 'CliMatchExtra': + def from_json(cls, x: Any) -> 'IncompatibleRule': if isinstance(x, dict): return cls( - message=_atd_read_string(x['message']) if 'message' in x else _atd_missing_json_field('CliMatchExtra', 'message'), - metadata=RawJson.from_json(x['metadata']) if 'metadata' in x else _atd_missing_json_field('CliMatchExtra', 'metadata'), - severity=MatchSeverity.from_json(x['severity']) if 'severity' in x else _atd_missing_json_field('CliMatchExtra', 'severity'), - fingerprint=_atd_read_string(x['fingerprint']) if 'fingerprint' in x else _atd_missing_json_field('CliMatchExtra', 'fingerprint'), - lines=_atd_read_string(x['lines']) if 'lines' in x else _atd_missing_json_field('CliMatchExtra', 'lines'), - metavars=Metavars.from_json(x['metavars']) if 'metavars' in x else None, - fix=_atd_read_string(x['fix']) if 'fix' in x else None, - fixed_lines=_atd_read_list(_atd_read_string)(x['fixed_lines']) if 'fixed_lines' in x else None, - is_ignored=_atd_read_bool(x['is_ignored']) if 'is_ignored' in x else None, - sca_info=ScaInfo.from_json(x['sca_info']) if 'sca_info' in x else None, - dataflow_trace=MatchDataflowTrace.from_json(x['dataflow_trace']) if 'dataflow_trace' in x else None, - engine_kind=EngineOfFinding.from_json(x['engine_kind']) if 'engine_kind' in x else None, - validation_state=ValidationState.from_json(x['validation_state']) if 'validation_state' in x else None, - historical_info=HistoricalInfo.from_json(x['historical_info']) if 'historical_info' in x else None, - extra_extra=RawJson.from_json(x['extra_extra']) if 'extra_extra' in x else None, + rule_id=RuleId.from_json(x['rule_id']) if 'rule_id' in x else _atd_missing_json_field('IncompatibleRule', 'rule_id'), + this_version=Version.from_json(x['this_version']) if 'this_version' in x else _atd_missing_json_field('IncompatibleRule', 'this_version'), + min_version=Version.from_json(x['min_version']) if 'min_version' in x else None, + max_version=Version.from_json(x['max_version']) if 'max_version' in x else None, ) else: - _atd_bad_json('CliMatchExtra', x) + _atd_bad_json('IncompatibleRule', x) def to_json(self) -> Any: res: Dict[str, Any] = {} - res['message'] = _atd_write_string(self.message) - res['metadata'] = (lambda x: x.to_json())(self.metadata) - res['severity'] = (lambda x: x.to_json())(self.severity) - res['fingerprint'] = _atd_write_string(self.fingerprint) - res['lines'] = _atd_write_string(self.lines) - if self.metavars is not None: - res['metavars'] = (lambda x: x.to_json())(self.metavars) - if self.fix is not None: - res['fix'] = _atd_write_string(self.fix) - if self.fixed_lines is not None: - res['fixed_lines'] = _atd_write_list(_atd_write_string)(self.fixed_lines) - if self.is_ignored is not None: - res['is_ignored'] = _atd_write_bool(self.is_ignored) - if self.sca_info is not None: - res['sca_info'] = (lambda x: x.to_json())(self.sca_info) - if self.dataflow_trace is not None: - res['dataflow_trace'] = (lambda x: x.to_json())(self.dataflow_trace) - if self.engine_kind is not None: - res['engine_kind'] = (lambda x: x.to_json())(self.engine_kind) - if self.validation_state is not None: - res['validation_state'] = (lambda x: x.to_json())(self.validation_state) - if self.historical_info is not None: - res['historical_info'] = (lambda x: x.to_json())(self.historical_info) - if self.extra_extra is not None: - res['extra_extra'] = (lambda x: x.to_json())(self.extra_extra) + res['rule_id'] = (lambda x: x.to_json())(self.rule_id) + res['this_version'] = (lambda x: x.to_json())(self.this_version) + if self.min_version is not None: + res['min_version'] = (lambda x: x.to_json())(self.min_version) + if self.max_version is not None: + res['max_version'] = (lambda x: x.to_json())(self.max_version) return res @classmethod - def from_json_string(cls, x: str) -> 'CliMatchExtra': + def from_json_string(cls, x: str) -> 'IncompatibleRule': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class CliMatch: - """Original type: cli_match = { ... }""" - - check_id: RuleId - path: Fpath - start: Position - end: Position - extra: CliMatchExtra - - @classmethod - def from_json(cls, x: Any) -> 'CliMatch': - if isinstance(x, dict): - return cls( - check_id=RuleId.from_json(x['check_id']) if 'check_id' in x else _atd_missing_json_field('CliMatch', 'check_id'), - path=Fpath.from_json(x['path']) if 'path' in x else _atd_missing_json_field('CliMatch', 'path'), - start=Position.from_json(x['start']) if 'start' in x else _atd_missing_json_field('CliMatch', 'start'), - end=Position.from_json(x['end']) if 'end' in x else _atd_missing_json_field('CliMatch', 'end'), - extra=CliMatchExtra.from_json(x['extra']) if 'extra' in x else _atd_missing_json_field('CliMatch', 'extra'), - ) - else: - _atd_bad_json('CliMatch', x) +@dataclass(frozen=True, order=True) +class LexicalError: + """Original type: error_type = [ ... | LexicalError | ... ]""" - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['check_id'] = (lambda x: x.to_json())(self.check_id) - res['path'] = (lambda x: x.to_json())(self.path) - res['start'] = (lambda x: x.to_json())(self.start) - res['end'] = (lambda x: x.to_json())(self.end) - res['extra'] = (lambda x: x.to_json())(self.extra) - return res + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'LexicalError' - @classmethod - def from_json_string(cls, x: str) -> 'CliMatch': - return cls.from_json(json.loads(x)) + @staticmethod + def to_json() -> Any: + return 'Lexical error' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class CliError: - """Original type: cli_error = { ... }""" +@dataclass(frozen=True, order=True) +class ParseError: + """Original type: error_type = [ ... | ParseError | ... ]""" - code: int - level: ErrorSeverity - type_: ErrorType - rule_id: Optional[RuleId] = None - message: Optional[str] = None - path: Optional[Fpath] = None - long_msg: Optional[str] = None - short_msg: Optional[str] = None - spans: Optional[List[ErrorSpan]] = None - help: Optional[str] = None + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'ParseError' - @classmethod - def from_json(cls, x: Any) -> 'CliError': - if isinstance(x, dict): - return cls( - code=_atd_read_int(x['code']) if 'code' in x else _atd_missing_json_field('CliError', 'code'), - level=ErrorSeverity.from_json(x['level']) if 'level' in x else _atd_missing_json_field('CliError', 'level'), - type_=ErrorType.from_json(x['type']) if 'type' in x else _atd_missing_json_field('CliError', 'type'), - rule_id=RuleId.from_json(x['rule_id']) if 'rule_id' in x else None, - message=_atd_read_string(x['message']) if 'message' in x else None, - path=Fpath.from_json(x['path']) if 'path' in x else None, - long_msg=_atd_read_string(x['long_msg']) if 'long_msg' in x else None, - short_msg=_atd_read_string(x['short_msg']) if 'short_msg' in x else None, - spans=_atd_read_list(ErrorSpan.from_json)(x['spans']) if 'spans' in x else None, - help=_atd_read_string(x['help']) if 'help' in x else None, - ) - else: - _atd_bad_json('CliError', x) + @staticmethod + def to_json() -> Any: + return 'Syntax error' - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['code'] = _atd_write_int(self.code) - res['level'] = (lambda x: x.to_json())(self.level) - res['type'] = (lambda x: x.to_json())(self.type_) - if self.rule_id is not None: - res['rule_id'] = (lambda x: x.to_json())(self.rule_id) - if self.message is not None: - res['message'] = _atd_write_string(self.message) - if self.path is not None: - res['path'] = (lambda x: x.to_json())(self.path) - if self.long_msg is not None: - res['long_msg'] = _atd_write_string(self.long_msg) - if self.short_msg is not None: - res['short_msg'] = _atd_write_string(self.short_msg) - if self.spans is not None: - res['spans'] = _atd_write_list((lambda x: x.to_json()))(self.spans) - if self.help is not None: - res['help'] = _atd_write_string(self.help) - return res + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass(frozen=True, order=True) +class OtherParseError: + """Original type: error_type = [ ... | OtherParseError | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'OtherParseError' - @classmethod - def from_json_string(cls, x: str) -> 'CliError': - return cls.from_json(json.loads(x)) + @staticmethod + def to_json() -> Any: + return 'Other syntax error' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True) -class SarifFormatParams: - """Original type: sarif_format_params = { ... }""" - - hide_nudge: bool - engine_label: str - rules: Fpath - cli_matches: List[CliMatch] - cli_errors: List[CliError] - show_dataflow_traces: Optional[bool] = None - - @classmethod - def from_json(cls, x: Any) -> 'SarifFormatParams': - if isinstance(x, dict): - return cls( - hide_nudge=_atd_read_bool(x['hide_nudge']) if 'hide_nudge' in x else _atd_missing_json_field('SarifFormatParams', 'hide_nudge'), - engine_label=_atd_read_string(x['engine_label']) if 'engine_label' in x else _atd_missing_json_field('SarifFormatParams', 'engine_label'), - rules=Fpath.from_json(x['rules']) if 'rules' in x else _atd_missing_json_field('SarifFormatParams', 'rules'), - cli_matches=_atd_read_list(CliMatch.from_json)(x['cli_matches']) if 'cli_matches' in x else _atd_missing_json_field('SarifFormatParams', 'cli_matches'), - cli_errors=_atd_read_list(CliError.from_json)(x['cli_errors']) if 'cli_errors' in x else _atd_missing_json_field('SarifFormatParams', 'cli_errors'), - show_dataflow_traces=_atd_read_bool(x['show_dataflow_traces']) if 'show_dataflow_traces' in x else None, - ) - else: - _atd_bad_json('SarifFormatParams', x) +@dataclass(frozen=True, order=True) +class AstBuilderError: + """Original type: error_type = [ ... | AstBuilderError | ... ]""" - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['hide_nudge'] = _atd_write_bool(self.hide_nudge) - res['engine_label'] = _atd_write_string(self.engine_label) - res['rules'] = (lambda x: x.to_json())(self.rules) - res['cli_matches'] = _atd_write_list((lambda x: x.to_json()))(self.cli_matches) - res['cli_errors'] = _atd_write_list((lambda x: x.to_json()))(self.cli_errors) - if self.show_dataflow_traces is not None: - res['show_dataflow_traces'] = _atd_write_bool(self.show_dataflow_traces) - return res + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'AstBuilderError' - @classmethod - def from_json_string(cls, x: str) -> 'SarifFormatParams': - return cls.from_json(json.loads(x)) + @staticmethod + def to_json() -> Any: + return 'AST builder error' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True) -class OSS_: - """Original type: engine_kind = [ ... | OSS | ... ]""" +@dataclass(frozen=True, order=True) +class RuleParseError: + """Original type: error_type = [ ... | RuleParseError | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'OSS_' + return 'RuleParseError' @staticmethod def to_json() -> Any: - return 'OSS' + return 'Rule parse error' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True) -class PRO_: - """Original type: engine_kind = [ ... | PRO | ... ]""" +@dataclass(frozen=True, order=True) +class SemgrepWarning: + """Original type: error_type = [ ... | SemgrepWarning | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'PRO_' + return 'SemgrepWarning' @staticmethod def to_json() -> Any: - return 'PRO' + return 'SemgrepWarning' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True) -class EngineKind: - """Original type: engine_kind = [ ... ]""" - - value: Union[OSS_, PRO_] +@dataclass(frozen=True, order=True) +class SemgrepError: + """Original type: error_type = [ ... | SemgrepError | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return self.value.kind - - @classmethod - def from_json(cls, x: Any) -> 'EngineKind': - if isinstance(x, str): - if x == 'OSS': - return cls(OSS_()) - if x == 'PRO': - return cls(PRO_()) - _atd_bad_json('EngineKind', x) - _atd_bad_json('EngineKind', x) - - def to_json(self) -> Any: - return self.value.to_json() + return 'SemgrepError' - @classmethod - def from_json_string(cls, x: str) -> 'EngineKind': - return cls.from_json(json.loads(x)) + @staticmethod + def to_json() -> Any: + return 'SemgrepError' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True) -class RuleIdAndEngineKind: - """Original type: rule_id_and_engine_kind""" - - value: Tuple[RuleId, EngineKind] - - @classmethod - def from_json(cls, x: Any) -> 'RuleIdAndEngineKind': - return cls((lambda x: (RuleId.from_json(x[0]), EngineKind.from_json(x[1])) if isinstance(x, list) and len(x) == 2 else _atd_bad_json('array of length 2', x))(x)) +@dataclass(frozen=True, order=True) +class InvalidRuleSchemaError: + """Original type: error_type = [ ... | InvalidRuleSchemaError | ... ]""" - def to_json(self) -> Any: - return (lambda x: [(lambda x: x.to_json())(x[0]), (lambda x: x.to_json())(x[1])] if isinstance(x, tuple) and len(x) == 2 else _atd_bad_python('tuple of length 2', x))(self.value) + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'InvalidRuleSchemaError' - @classmethod - def from_json_string(cls, x: str) -> 'RuleIdAndEngineKind': - return cls.from_json(json.loads(x)) + @staticmethod + def to_json() -> Any: + return 'InvalidRuleSchemaError' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class ResolutionOk: - """Original type: resolution_result = [ ... | ResolutionOk of ... | ... ]""" - - value: Tuple[List[FoundDependency], List[ResolutionError]] +@dataclass(frozen=True, order=True) +class UnknownLanguageError: + """Original type: error_type = [ ... | UnknownLanguageError | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'ResolutionOk' + return 'UnknownLanguageError' - def to_json(self) -> Any: - return ['ResolutionOk', (lambda x: [_atd_write_list((lambda x: x.to_json()))(x[0]), _atd_write_list((lambda x: x.to_json()))(x[1])] if isinstance(x, tuple) and len(x) == 2 else _atd_bad_python('tuple of length 2', x))(self.value)] + @staticmethod + def to_json() -> Any: + return 'UnknownLanguageError' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class ResolutionError_: - """Original type: resolution_result = [ ... | ResolutionError of ... | ... ]""" - - value: List[ResolutionError] +@dataclass(frozen=True, order=True) +class InvalidYaml: + """Original type: error_type = [ ... | InvalidYaml | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'ResolutionError_' + return 'InvalidYaml' - def to_json(self) -> Any: - return ['ResolutionError', _atd_write_list((lambda x: x.to_json()))(self.value)] + @staticmethod + def to_json() -> Any: + return 'Invalid YAML' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class ResolutionResult: - """Original type: resolution_result = [ ... ]""" - - value: Union[ResolutionOk, ResolutionError_] +@dataclass(frozen=True, order=True) +class MatchingError: + """Original type: error_type = [ ... | MatchingError | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return self.value.kind + return 'MatchingError' - @classmethod - def from_json(cls, x: Any) -> 'ResolutionResult': - if isinstance(x, List) and len(x) == 2: - cons = x[0] - if cons == 'ResolutionOk': - return cls(ResolutionOk((lambda x: (_atd_read_list(FoundDependency.from_json)(x[0]), _atd_read_list(ResolutionError.from_json)(x[1])) if isinstance(x, list) and len(x) == 2 else _atd_bad_json('array of length 2', x))(x[1]))) - if cons == 'ResolutionError': - return cls(ResolutionError_(_atd_read_list(ResolutionError.from_json)(x[1]))) - _atd_bad_json('ResolutionResult', x) - _atd_bad_json('ResolutionResult', x) + @staticmethod + def to_json() -> Any: + return 'Internal matching error' - def to_json(self) -> Any: - return self.value.to_json() + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) - @classmethod - def from_json_string(cls, x: str) -> 'ResolutionResult': - return cls.from_json(json.loads(x)) + +@dataclass(frozen=True, order=True) +class SemgrepMatchFound: + """Original type: error_type = [ ... | SemgrepMatchFound | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'SemgrepMatchFound' + + @staticmethod + def to_json() -> Any: + return 'Semgrep match found' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class Profile: - """Original type: profile = { ... }""" +@dataclass(frozen=True, order=True) +class TooManyMatches_: + """Original type: error_type = [ ... | TooManyMatches | ... ]""" - rules: List[RuleId] - rules_parse_time: float - profiling_times: Dict[str, float] - targets: List[TargetTimes] - total_bytes: int - max_memory_bytes: Optional[int] = None + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'TooManyMatches_' - @classmethod - def from_json(cls, x: Any) -> 'Profile': - if isinstance(x, dict): - return cls( - rules=_atd_read_list(RuleId.from_json)(x['rules']) if 'rules' in x else _atd_missing_json_field('Profile', 'rules'), - rules_parse_time=_atd_read_float(x['rules_parse_time']) if 'rules_parse_time' in x else _atd_missing_json_field('Profile', 'rules_parse_time'), - profiling_times=_atd_read_assoc_object_into_dict(_atd_read_float)(x['profiling_times']) if 'profiling_times' in x else _atd_missing_json_field('Profile', 'profiling_times'), - targets=_atd_read_list(TargetTimes.from_json)(x['targets']) if 'targets' in x else _atd_missing_json_field('Profile', 'targets'), - total_bytes=_atd_read_int(x['total_bytes']) if 'total_bytes' in x else _atd_missing_json_field('Profile', 'total_bytes'), - max_memory_bytes=_atd_read_int(x['max_memory_bytes']) if 'max_memory_bytes' in x else None, - ) - else: - _atd_bad_json('Profile', x) + @staticmethod + def to_json() -> Any: + return 'Too many matches' - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['rules'] = _atd_write_list((lambda x: x.to_json()))(self.rules) - res['rules_parse_time'] = _atd_write_float(self.rules_parse_time) - res['profiling_times'] = _atd_write_assoc_dict_to_object(_atd_write_float)(self.profiling_times) - res['targets'] = _atd_write_list((lambda x: x.to_json()))(self.targets) - res['total_bytes'] = _atd_write_int(self.total_bytes) - if self.max_memory_bytes is not None: - res['max_memory_bytes'] = _atd_write_int(self.max_memory_bytes) - return res + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) - @classmethod - def from_json_string(cls, x: str) -> 'Profile': - return cls.from_json(json.loads(x)) + +@dataclass(frozen=True, order=True) +class FatalError: + """Original type: error_type = [ ... | FatalError | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'FatalError' + + @staticmethod + def to_json() -> Any: + return 'Fatal error' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class ParsingStats: - """Original type: parsing_stats = { ... }""" - - targets_parsed: int - num_targets: int - bytes_parsed: int - num_bytes: int - - @classmethod - def from_json(cls, x: Any) -> 'ParsingStats': - if isinstance(x, dict): - return cls( - targets_parsed=_atd_read_int(x['targets_parsed']) if 'targets_parsed' in x else _atd_missing_json_field('ParsingStats', 'targets_parsed'), - num_targets=_atd_read_int(x['num_targets']) if 'num_targets' in x else _atd_missing_json_field('ParsingStats', 'num_targets'), - bytes_parsed=_atd_read_int(x['bytes_parsed']) if 'bytes_parsed' in x else _atd_missing_json_field('ParsingStats', 'bytes_parsed'), - num_bytes=_atd_read_int(x['num_bytes']) if 'num_bytes' in x else _atd_missing_json_field('ParsingStats', 'num_bytes'), - ) - else: - _atd_bad_json('ParsingStats', x) +@dataclass(frozen=True, order=True) +class Timeout: + """Original type: error_type = [ ... | Timeout | ... ]""" - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['targets_parsed'] = _atd_write_int(self.targets_parsed) - res['num_targets'] = _atd_write_int(self.num_targets) - res['bytes_parsed'] = _atd_write_int(self.bytes_parsed) - res['num_bytes'] = _atd_write_int(self.num_bytes) - return res + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'Timeout' - @classmethod - def from_json_string(cls, x: str) -> 'ParsingStats': - return cls.from_json(json.loads(x)) + @staticmethod + def to_json() -> Any: + return 'Timeout' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class FindingHashes: - """Original type: finding_hashes = { ... }""" - - start_line_hash: str - end_line_hash: str - code_hash: str - pattern_hash: str - - @classmethod - def from_json(cls, x: Any) -> 'FindingHashes': - if isinstance(x, dict): - return cls( - start_line_hash=_atd_read_string(x['start_line_hash']) if 'start_line_hash' in x else _atd_missing_json_field('FindingHashes', 'start_line_hash'), - end_line_hash=_atd_read_string(x['end_line_hash']) if 'end_line_hash' in x else _atd_missing_json_field('FindingHashes', 'end_line_hash'), - code_hash=_atd_read_string(x['code_hash']) if 'code_hash' in x else _atd_missing_json_field('FindingHashes', 'code_hash'), - pattern_hash=_atd_read_string(x['pattern_hash']) if 'pattern_hash' in x else _atd_missing_json_field('FindingHashes', 'pattern_hash'), - ) - else: - _atd_bad_json('FindingHashes', x) +@dataclass(frozen=True, order=True) +class OutOfMemory: + """Original type: error_type = [ ... | OutOfMemory | ... ]""" - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['start_line_hash'] = _atd_write_string(self.start_line_hash) - res['end_line_hash'] = _atd_write_string(self.end_line_hash) - res['code_hash'] = _atd_write_string(self.code_hash) - res['pattern_hash'] = _atd_write_string(self.pattern_hash) - return res + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'OutOfMemory' - @classmethod - def from_json_string(cls, x: str) -> 'FindingHashes': - return cls.from_json(json.loads(x)) + @staticmethod + def to_json() -> Any: + return 'Out of memory' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class Finding: - """Original type: finding = { ... }""" +@dataclass(frozen=True, order=True) +class StackOverflow: + """Original type: error_type = [ ... | StackOverflow | ... ]""" - check_id: RuleId - path: Fpath - line: int - column: int - end_line: int - end_column: int - message: str - severity: Any - index: int - commit_date: str - syntactic_id: str - metadata: RawJson - is_blocking: bool - match_based_id: Optional[str] = None - hashes: Optional[FindingHashes] = None - fixed_lines: Optional[List[str]] = None - sca_info: Optional[ScaInfo] = None - dataflow_trace: Optional[MatchDataflowTrace] = None - validation_state: Optional[ValidationState] = None - historical_info: Optional[HistoricalInfo] = None - engine_kind: Optional[EngineOfFinding] = None + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'StackOverflow' - @classmethod - def from_json(cls, x: Any) -> 'Finding': - if isinstance(x, dict): - return cls( - check_id=RuleId.from_json(x['check_id']) if 'check_id' in x else _atd_missing_json_field('Finding', 'check_id'), - path=Fpath.from_json(x['path']) if 'path' in x else _atd_missing_json_field('Finding', 'path'), - line=_atd_read_int(x['line']) if 'line' in x else _atd_missing_json_field('Finding', 'line'), - column=_atd_read_int(x['column']) if 'column' in x else _atd_missing_json_field('Finding', 'column'), - end_line=_atd_read_int(x['end_line']) if 'end_line' in x else _atd_missing_json_field('Finding', 'end_line'), - end_column=_atd_read_int(x['end_column']) if 'end_column' in x else _atd_missing_json_field('Finding', 'end_column'), - message=_atd_read_string(x['message']) if 'message' in x else _atd_missing_json_field('Finding', 'message'), - severity=(lambda x: x)(x['severity']) if 'severity' in x else _atd_missing_json_field('Finding', 'severity'), - index=_atd_read_int(x['index']) if 'index' in x else _atd_missing_json_field('Finding', 'index'), - commit_date=_atd_read_string(x['commit_date']) if 'commit_date' in x else _atd_missing_json_field('Finding', 'commit_date'), - syntactic_id=_atd_read_string(x['syntactic_id']) if 'syntactic_id' in x else _atd_missing_json_field('Finding', 'syntactic_id'), - metadata=RawJson.from_json(x['metadata']) if 'metadata' in x else _atd_missing_json_field('Finding', 'metadata'), - is_blocking=_atd_read_bool(x['is_blocking']) if 'is_blocking' in x else _atd_missing_json_field('Finding', 'is_blocking'), - match_based_id=_atd_read_string(x['match_based_id']) if 'match_based_id' in x else None, - hashes=FindingHashes.from_json(x['hashes']) if 'hashes' in x else None, - fixed_lines=_atd_read_list(_atd_read_string)(x['fixed_lines']) if 'fixed_lines' in x else None, - sca_info=ScaInfo.from_json(x['sca_info']) if 'sca_info' in x else None, - dataflow_trace=MatchDataflowTrace.from_json(x['dataflow_trace']) if 'dataflow_trace' in x else None, - validation_state=ValidationState.from_json(x['validation_state']) if 'validation_state' in x else None, - historical_info=HistoricalInfo.from_json(x['historical_info']) if 'historical_info' in x else None, - engine_kind=EngineOfFinding.from_json(x['engine_kind']) if 'engine_kind' in x else None, - ) - else: - _atd_bad_json('Finding', x) + @staticmethod + def to_json() -> Any: + return 'Stack overflow' - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['check_id'] = (lambda x: x.to_json())(self.check_id) - res['path'] = (lambda x: x.to_json())(self.path) - res['line'] = _atd_write_int(self.line) - res['column'] = _atd_write_int(self.column) - res['end_line'] = _atd_write_int(self.end_line) - res['end_column'] = _atd_write_int(self.end_column) - res['message'] = _atd_write_string(self.message) - res['severity'] = (lambda x: x)(self.severity) - res['index'] = _atd_write_int(self.index) - res['commit_date'] = _atd_write_string(self.commit_date) - res['syntactic_id'] = _atd_write_string(self.syntactic_id) - res['metadata'] = (lambda x: x.to_json())(self.metadata) - res['is_blocking'] = _atd_write_bool(self.is_blocking) - if self.match_based_id is not None: - res['match_based_id'] = _atd_write_string(self.match_based_id) - if self.hashes is not None: - res['hashes'] = (lambda x: x.to_json())(self.hashes) - if self.fixed_lines is not None: - res['fixed_lines'] = _atd_write_list(_atd_write_string)(self.fixed_lines) - if self.sca_info is not None: - res['sca_info'] = (lambda x: x.to_json())(self.sca_info) - if self.dataflow_trace is not None: - res['dataflow_trace'] = (lambda x: x.to_json())(self.dataflow_trace) - if self.validation_state is not None: - res['validation_state'] = (lambda x: x.to_json())(self.validation_state) - if self.historical_info is not None: - res['historical_info'] = (lambda x: x.to_json())(self.historical_info) - if self.engine_kind is not None: - res['engine_kind'] = (lambda x: x.to_json())(self.engine_kind) - return res + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) - @classmethod - def from_json_string(cls, x: str) -> 'Finding': - return cls.from_json(json.loads(x)) + +@dataclass(frozen=True, order=True) +class TimeoutDuringInterfile: + """Original type: error_type = [ ... | TimeoutDuringInterfile | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'TimeoutDuringInterfile' + + @staticmethod + def to_json() -> Any: + return 'Timeout during interfile analysis' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class DependencyParserError: - """Original type: dependency_parser_error = { ... }""" +@dataclass(frozen=True, order=True) +class OutOfMemoryDuringInterfile: + """Original type: error_type = [ ... | OutOfMemoryDuringInterfile | ... ]""" - path: str - parser: ScaParserName - reason: str - line: Optional[int] = None - col: Optional[int] = None - text: Optional[str] = None + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'OutOfMemoryDuringInterfile' - @classmethod - def from_json(cls, x: Any) -> 'DependencyParserError': - if isinstance(x, dict): - return cls( - path=_atd_read_string(x['path']) if 'path' in x else _atd_missing_json_field('DependencyParserError', 'path'), - parser=ScaParserName.from_json(x['parser']) if 'parser' in x else _atd_missing_json_field('DependencyParserError', 'parser'), - reason=_atd_read_string(x['reason']) if 'reason' in x else _atd_missing_json_field('DependencyParserError', 'reason'), - line=_atd_read_int(x['line']) if 'line' in x else None, - col=_atd_read_int(x['col']) if 'col' in x else None, - text=_atd_read_string(x['text']) if 'text' in x else None, - ) - else: - _atd_bad_json('DependencyParserError', x) + @staticmethod + def to_json() -> Any: + return 'OOM during interfile analysis' - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['path'] = _atd_write_string(self.path) - res['parser'] = (lambda x: x.to_json())(self.parser) - res['reason'] = _atd_write_string(self.reason) - if self.line is not None: - res['line'] = _atd_write_int(self.line) - if self.col is not None: - res['col'] = _atd_write_int(self.col) - if self.text is not None: - res['text'] = _atd_write_string(self.text) - return res + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) - @classmethod - def from_json_string(cls, x: str) -> 'DependencyParserError': - return cls.from_json(json.loads(x)) + +@dataclass(frozen=True, order=True) +class MissingPlugin: + """Original type: error_type = [ ... | MissingPlugin | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'MissingPlugin' + + @staticmethod + def to_json() -> Any: + return 'Missing plugin' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class Contributor: - """Original type: contributor = { ... }""" +@dataclass(frozen=True, order=True) +class PatternParseError: + """Original type: error_type = [ ... | PatternParseError of ... | ... ]""" - commit_author_name: str - commit_author_email: str + value: List[str] - @classmethod - def from_json(cls, x: Any) -> 'Contributor': - if isinstance(x, dict): - return cls( - commit_author_name=_atd_read_string(x['commit_author_name']) if 'commit_author_name' in x else _atd_missing_json_field('Contributor', 'commit_author_name'), - commit_author_email=_atd_read_string(x['commit_author_email']) if 'commit_author_email' in x else _atd_missing_json_field('Contributor', 'commit_author_email'), - ) - else: - _atd_bad_json('Contributor', x) + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'PatternParseError' def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['commit_author_name'] = _atd_write_string(self.commit_author_name) - res['commit_author_email'] = _atd_write_string(self.commit_author_email) - return res - - @classmethod - def from_json_string(cls, x: str) -> 'Contributor': - return cls.from_json(json.loads(x)) + return ['PatternParseError', _atd_write_list(_atd_write_string)(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class Contribution: - """Original type: contribution = { ... }""" +@dataclass(frozen=True, order=True) +class PartialParsing: + """Original type: error_type = [ ... | PartialParsing of ... | ... ]""" - commit_hash: str - commit_timestamp: Datetime - contributor: Contributor + value: List[Location] - @classmethod - def from_json(cls, x: Any) -> 'Contribution': - if isinstance(x, dict): - return cls( - commit_hash=_atd_read_string(x['commit_hash']) if 'commit_hash' in x else _atd_missing_json_field('Contribution', 'commit_hash'), - commit_timestamp=Datetime.from_json(x['commit_timestamp']) if 'commit_timestamp' in x else _atd_missing_json_field('Contribution', 'commit_timestamp'), - contributor=Contributor.from_json(x['contributor']) if 'contributor' in x else _atd_missing_json_field('Contribution', 'contributor'), - ) - else: - _atd_bad_json('Contribution', x) + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'PartialParsing' def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['commit_hash'] = _atd_write_string(self.commit_hash) - res['commit_timestamp'] = (lambda x: x.to_json())(self.commit_timestamp) - res['contributor'] = (lambda x: x.to_json())(self.contributor) - return res - - @classmethod - def from_json_string(cls, x: str) -> 'Contribution': - return cls.from_json(json.loads(x)) + return ['PartialParsing', _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 Contributions: - """Original type: contributions""" +@dataclass(frozen=True, order=True) +class IncompatibleRule_: + """Original type: error_type = [ ... | IncompatibleRule of ... | ... ]""" - value: List[Contribution] + value: IncompatibleRule - @classmethod - def from_json(cls, x: Any) -> 'Contributions': - return cls(_atd_read_list(Contribution.from_json)(x)) + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'IncompatibleRule_' def to_json(self) -> Any: - return _atd_write_list((lambda x: x.to_json()))(self.value) - - @classmethod - def from_json_string(cls, x: str) -> 'Contributions': - return cls.from_json(json.loads(x)) + return ['IncompatibleRule', (lambda x: x.to_json())(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class CiScanDependencies: - """Original type: ci_scan_dependencies""" +@dataclass(frozen=True, order=True) +class PatternParseError0: + """Original type: error_type = [ ... | PatternParseError0 | ... ]""" - value: Dict[str, List[FoundDependency]] + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'PatternParseError0' - @classmethod - def from_json(cls, x: Any) -> 'CiScanDependencies': - return cls(_atd_read_assoc_object_into_dict(_atd_read_list(FoundDependency.from_json))(x)) + @staticmethod + def to_json() -> Any: + return 'Pattern parse error' - def to_json(self) -> Any: - return _atd_write_assoc_dict_to_object(_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) - @classmethod - def from_json_string(cls, x: str) -> 'CiScanDependencies': - return cls.from_json(json.loads(x)) + +@dataclass(frozen=True, order=True) +class IncompatibleRule0: + """Original type: error_type = [ ... | IncompatibleRule0 | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'IncompatibleRule0' + + @staticmethod + def to_json() -> Any: + return 'Incompatible rule' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class CiScanResults: - """Original type: ci_scan_results = { ... }""" +@dataclass(frozen=True, order=True) +class DependencyResolutionError: + """Original type: error_type = [ ... | DependencyResolutionError of ... | ... ]""" - findings: List[Finding] - ignores: List[Finding] - token: Optional[str] - searched_paths: List[Fpath] - renamed_paths: List[Fpath] - rule_ids: List[RuleId] - contributions: Optional[Contributions] = None - dependencies: Optional[CiScanDependencies] = None + value: ResolutionError - @classmethod - def from_json(cls, x: Any) -> 'CiScanResults': - if isinstance(x, dict): - return cls( - findings=_atd_read_list(Finding.from_json)(x['findings']) if 'findings' in x else _atd_missing_json_field('CiScanResults', 'findings'), - ignores=_atd_read_list(Finding.from_json)(x['ignores']) if 'ignores' in x else _atd_missing_json_field('CiScanResults', 'ignores'), - token=_atd_read_nullable(_atd_read_string)(x['token']) if 'token' in x else _atd_missing_json_field('CiScanResults', 'token'), - searched_paths=_atd_read_list(Fpath.from_json)(x['searched_paths']) if 'searched_paths' in x else _atd_missing_json_field('CiScanResults', 'searched_paths'), - renamed_paths=_atd_read_list(Fpath.from_json)(x['renamed_paths']) if 'renamed_paths' in x else _atd_missing_json_field('CiScanResults', 'renamed_paths'), - rule_ids=_atd_read_list(RuleId.from_json)(x['rule_ids']) if 'rule_ids' in x else _atd_missing_json_field('CiScanResults', 'rule_ids'), - contributions=Contributions.from_json(x['contributions']) if 'contributions' in x else None, - dependencies=CiScanDependencies.from_json(x['dependencies']) if 'dependencies' in x else None, - ) - else: - _atd_bad_json('CiScanResults', x) + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'DependencyResolutionError' def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['findings'] = _atd_write_list((lambda x: x.to_json()))(self.findings) - res['ignores'] = _atd_write_list((lambda x: x.to_json()))(self.ignores) - res['token'] = _atd_write_nullable(_atd_write_string)(self.token) - res['searched_paths'] = _atd_write_list((lambda x: x.to_json()))(self.searched_paths) - res['renamed_paths'] = _atd_write_list((lambda x: x.to_json()))(self.renamed_paths) - res['rule_ids'] = _atd_write_list((lambda x: x.to_json()))(self.rule_ids) - if self.contributions is not None: - res['contributions'] = (lambda x: x.to_json())(self.contributions) - if self.dependencies is not None: - res['dependencies'] = (lambda x: x.to_json())(self.dependencies) - return res - - @classmethod - def from_json_string(cls, x: str) -> 'CiScanResults': - return cls.from_json(json.loads(x)) + return ['DependencyResolutionError', (lambda x: x.to_json())(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class CiScanFailure: - """Original type: ci_scan_failure = { ... }""" +@dataclass(frozen=True, order=True) +class ErrorType: + """Original type: error_type = [ ... ]""" - exit_code: int - stderr: str + value: Union[LexicalError, ParseError, OtherParseError, AstBuilderError, RuleParseError, SemgrepWarning, SemgrepError, InvalidRuleSchemaError, UnknownLanguageError, InvalidYaml, MatchingError, SemgrepMatchFound, TooManyMatches_, FatalError, Timeout, OutOfMemory, StackOverflow, TimeoutDuringInterfile, OutOfMemoryDuringInterfile, MissingPlugin, PatternParseError, PartialParsing, IncompatibleRule_, PatternParseError0, IncompatibleRule0, DependencyResolutionError] + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return self.value.kind @classmethod - def from_json(cls, x: Any) -> 'CiScanFailure': - if isinstance(x, dict): - return cls( - exit_code=_atd_read_int(x['exit_code']) if 'exit_code' in x else _atd_missing_json_field('CiScanFailure', 'exit_code'), - stderr=_atd_read_string(x['stderr']) if 'stderr' in x else _atd_missing_json_field('CiScanFailure', 'stderr'), - ) - else: - _atd_bad_json('CiScanFailure', x) + def from_json(cls, x: Any) -> 'ErrorType': + if isinstance(x, str): + if x == 'Lexical error': + return cls(LexicalError()) + if x == 'Syntax error': + return cls(ParseError()) + if x == 'Other syntax error': + return cls(OtherParseError()) + if x == 'AST builder error': + return cls(AstBuilderError()) + if x == 'Rule parse error': + return cls(RuleParseError()) + if x == 'SemgrepWarning': + return cls(SemgrepWarning()) + if x == 'SemgrepError': + return cls(SemgrepError()) + if x == 'InvalidRuleSchemaError': + return cls(InvalidRuleSchemaError()) + if x == 'UnknownLanguageError': + return cls(UnknownLanguageError()) + if x == 'Invalid YAML': + return cls(InvalidYaml()) + if x == 'Internal matching error': + return cls(MatchingError()) + if x == 'Semgrep match found': + return cls(SemgrepMatchFound()) + if x == 'Too many matches': + return cls(TooManyMatches_()) + if x == 'Fatal error': + return cls(FatalError()) + if x == 'Timeout': + return cls(Timeout()) + if x == 'Out of memory': + return cls(OutOfMemory()) + if x == 'Stack overflow': + return cls(StackOverflow()) + if x == 'Timeout during interfile analysis': + return cls(TimeoutDuringInterfile()) + if x == 'OOM during interfile analysis': + return cls(OutOfMemoryDuringInterfile()) + if x == 'Missing plugin': + return cls(MissingPlugin()) + if x == 'Pattern parse error': + return cls(PatternParseError0()) + if x == 'Incompatible rule': + return cls(IncompatibleRule0()) + _atd_bad_json('ErrorType', x) + if isinstance(x, List) and len(x) == 2: + cons = x[0] + if cons == 'PatternParseError': + return cls(PatternParseError(_atd_read_list(_atd_read_string)(x[1]))) + if cons == 'PartialParsing': + return cls(PartialParsing(_atd_read_list(Location.from_json)(x[1]))) + if cons == 'IncompatibleRule': + return cls(IncompatibleRule_(IncompatibleRule.from_json(x[1]))) + if cons == 'DependencyResolutionError': + return cls(DependencyResolutionError(ResolutionError.from_json(x[1]))) + _atd_bad_json('ErrorType', x) + _atd_bad_json('ErrorType', x) def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['exit_code'] = _atd_write_int(self.exit_code) - res['stderr'] = _atd_write_string(self.stderr) - return res + return self.value.to_json() @classmethod - def from_json_string(cls, x: str) -> 'CiScanFailure': + def from_json_string(cls, x: str) -> 'ErrorType': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: @@ -6363,347 +6297,413 @@ def to_json_string(self, **kw: Any) -> str: @dataclass -class CiScanCompleteStats: - """Original type: ci_scan_complete_stats = { ... }""" +class ErrorSpan: + """Original type: error_span = { ... }""" - findings: int - errors: List[CliError] - total_time: float - unsupported_exts: Dict[str, int] - lockfile_scan_info: Dict[str, int] - parse_rate: Dict[str, ParsingStats] - engine_requested: Optional[str] = None - findings_by_product: Optional[Dict[str, int]] = None + file: Fpath + start: Position + end: Position + source_hash: Optional[str] = None + config_start: Optional[Optional[Position]] = None + config_end: Optional[Optional[Position]] = None + config_path: Optional[Optional[List[str]]] = None + context_start: Optional[Optional[Position]] = None + context_end: Optional[Optional[Position]] = None @classmethod - def from_json(cls, x: Any) -> 'CiScanCompleteStats': + def from_json(cls, x: Any) -> 'ErrorSpan': if isinstance(x, dict): return cls( - findings=_atd_read_int(x['findings']) if 'findings' in x else _atd_missing_json_field('CiScanCompleteStats', 'findings'), - errors=_atd_read_list(CliError.from_json)(x['errors']) if 'errors' in x else _atd_missing_json_field('CiScanCompleteStats', 'errors'), - total_time=_atd_read_float(x['total_time']) if 'total_time' in x else _atd_missing_json_field('CiScanCompleteStats', 'total_time'), - unsupported_exts=_atd_read_assoc_object_into_dict(_atd_read_int)(x['unsupported_exts']) if 'unsupported_exts' in x else _atd_missing_json_field('CiScanCompleteStats', 'unsupported_exts'), - lockfile_scan_info=_atd_read_assoc_object_into_dict(_atd_read_int)(x['lockfile_scan_info']) if 'lockfile_scan_info' in x else _atd_missing_json_field('CiScanCompleteStats', 'lockfile_scan_info'), - parse_rate=_atd_read_assoc_object_into_dict(ParsingStats.from_json)(x['parse_rate']) if 'parse_rate' in x else _atd_missing_json_field('CiScanCompleteStats', 'parse_rate'), - engine_requested=_atd_read_string(x['engine_requested']) if 'engine_requested' in x else None, - findings_by_product=_atd_read_assoc_object_into_dict(_atd_read_int)(x['findings_by_product']) if 'findings_by_product' in x else None, + file=Fpath.from_json(x['file']) if 'file' in x else _atd_missing_json_field('ErrorSpan', 'file'), + start=Position.from_json(x['start']) if 'start' in x else _atd_missing_json_field('ErrorSpan', 'start'), + end=Position.from_json(x['end']) if 'end' in x else _atd_missing_json_field('ErrorSpan', 'end'), + source_hash=_atd_read_string(x['source_hash']) if 'source_hash' in x else None, + config_start=_atd_read_nullable(Position.from_json)(x['config_start']) if 'config_start' in x else None, + config_end=_atd_read_nullable(Position.from_json)(x['config_end']) if 'config_end' in x else None, + config_path=_atd_read_nullable(_atd_read_list(_atd_read_string))(x['config_path']) if 'config_path' in x else None, + context_start=_atd_read_nullable(Position.from_json)(x['context_start']) if 'context_start' in x else None, + context_end=_atd_read_nullable(Position.from_json)(x['context_end']) if 'context_end' in x else None, ) else: - _atd_bad_json('CiScanCompleteStats', x) + _atd_bad_json('ErrorSpan', x) def to_json(self) -> Any: res: Dict[str, Any] = {} - res['findings'] = _atd_write_int(self.findings) - res['errors'] = _atd_write_list((lambda x: x.to_json()))(self.errors) - res['total_time'] = _atd_write_float(self.total_time) - res['unsupported_exts'] = _atd_write_assoc_dict_to_object(_atd_write_int)(self.unsupported_exts) - res['lockfile_scan_info'] = _atd_write_assoc_dict_to_object(_atd_write_int)(self.lockfile_scan_info) - res['parse_rate'] = _atd_write_assoc_dict_to_object((lambda x: x.to_json()))(self.parse_rate) - if self.engine_requested is not None: - res['engine_requested'] = _atd_write_string(self.engine_requested) - if self.findings_by_product is not None: - res['findings_by_product'] = _atd_write_assoc_dict_to_object(_atd_write_int)(self.findings_by_product) + res['file'] = (lambda x: x.to_json())(self.file) + res['start'] = (lambda x: x.to_json())(self.start) + res['end'] = (lambda x: x.to_json())(self.end) + if self.source_hash is not None: + res['source_hash'] = _atd_write_string(self.source_hash) + if self.config_start is not None: + res['config_start'] = _atd_write_nullable((lambda x: x.to_json()))(self.config_start) + if self.config_end is not None: + res['config_end'] = _atd_write_nullable((lambda x: x.to_json()))(self.config_end) + if self.config_path is not None: + res['config_path'] = _atd_write_nullable(_atd_write_list(_atd_write_string))(self.config_path) + if self.context_start is not None: + res['context_start'] = _atd_write_nullable((lambda x: x.to_json()))(self.context_start) + if self.context_end is not None: + res['context_end'] = _atd_write_nullable((lambda x: x.to_json()))(self.context_end) return res @classmethod - def from_json_string(cls, x: str) -> 'CiScanCompleteStats': + def from_json_string(cls, x: str) -> 'ErrorSpan': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass -class CiScanComplete: - """Original type: ci_scan_complete = { ... }""" +@dataclass(frozen=True) +class Error_: + """Original type: error_severity = [ ... | Error | ... ]""" - exit_code: int - stats: CiScanCompleteStats - dependencies: Optional[CiScanDependencies] = None - dependency_parser_errors: Optional[List[DependencyParserError]] = None - task_id: Optional[str] = None - final_attempt: Optional[bool] = None + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'Error_' - @classmethod - def from_json(cls, x: Any) -> 'CiScanComplete': - if isinstance(x, dict): - return cls( - exit_code=_atd_read_int(x['exit_code']) if 'exit_code' in x else _atd_missing_json_field('CiScanComplete', 'exit_code'), - stats=CiScanCompleteStats.from_json(x['stats']) if 'stats' in x else _atd_missing_json_field('CiScanComplete', 'stats'), - dependencies=CiScanDependencies.from_json(x['dependencies']) if 'dependencies' in x else None, - dependency_parser_errors=_atd_read_list(DependencyParserError.from_json)(x['dependency_parser_errors']) if 'dependency_parser_errors' in x else None, - task_id=_atd_read_string(x['task_id']) if 'task_id' in x else None, - final_attempt=_atd_read_bool(x['final_attempt']) if 'final_attempt' in x else None, - ) - else: - _atd_bad_json('CiScanComplete', x) + @staticmethod + def to_json() -> Any: + return 'error' - def to_json(self) -> Any: - res: Dict[str, Any] = {} - res['exit_code'] = _atd_write_int(self.exit_code) - res['stats'] = (lambda x: x.to_json())(self.stats) - if self.dependencies is not None: - res['dependencies'] = (lambda x: x.to_json())(self.dependencies) - if self.dependency_parser_errors is not None: - res['dependency_parser_errors'] = _atd_write_list((lambda x: x.to_json()))(self.dependency_parser_errors) - if self.task_id is not None: - res['task_id'] = _atd_write_string(self.task_id) - if self.final_attempt is not None: - res['final_attempt'] = _atd_write_bool(self.final_attempt) - return res + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) - @classmethod - def from_json_string(cls, x: str) -> 'CiScanComplete': - return cls.from_json(json.loads(x)) + +@dataclass(frozen=True) +class Warning_: + """Original type: error_severity = [ ... | Warning | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'Warning_' + + @staticmethod + def to_json() -> Any: + return 'warn' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class PartialScanOk: - """Original type: partial_scan_result = [ ... | PartialScanOk of ... | ... ]""" - - value: Tuple[CiScanResults, CiScanComplete] +class Info_: + """Original type: error_severity = [ ... | Info | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'PartialScanOk' + return 'Info_' - def to_json(self) -> Any: - return ['PartialScanOk', (lambda x: [(lambda x: x.to_json())(x[0]), (lambda x: x.to_json())(x[1])] if isinstance(x, tuple) and len(x) == 2 else _atd_bad_python('tuple of length 2', x))(self.value)] + @staticmethod + def to_json() -> Any: + return 'info' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class PartialScanError: - """Original type: partial_scan_result = [ ... | PartialScanError of ... | ... ]""" +class ErrorSeverity: + """Original type: error_severity = [ ... ]""" - value: CiScanFailure + value: Union[Error_, Warning_, Info_] @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'PartialScanError' + return self.value.kind + + @classmethod + def from_json(cls, x: Any) -> 'ErrorSeverity': + if isinstance(x, str): + if x == 'error': + return cls(Error_()) + if x == 'warn': + return cls(Warning_()) + if x == 'info': + return cls(Info_()) + _atd_bad_json('ErrorSeverity', x) + _atd_bad_json('ErrorSeverity', x) def to_json(self) -> Any: - return ['PartialScanError', (lambda x: x.to_json())(self.value)] + return self.value.to_json() + + @classmethod + def from_json_string(cls, x: str) -> 'ErrorSeverity': + return cls.from_json(json.loads(x)) + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass +class CliMatchExtra: + """Original type: cli_match_extra = { ... }""" + + message: str + metadata: RawJson + severity: MatchSeverity + fingerprint: str + lines: str + metavars: Optional[Metavars] = None + fix: Optional[str] = None + fixed_lines: Optional[List[str]] = None + is_ignored: Optional[bool] = None + sca_info: Optional[ScaInfo] = None + dataflow_trace: Optional[MatchDataflowTrace] = None + engine_kind: Optional[EngineOfFinding] = None + validation_state: Optional[ValidationState] = None + historical_info: Optional[HistoricalInfo] = None + extra_extra: Optional[RawJson] = None + + @classmethod + def from_json(cls, x: Any) -> 'CliMatchExtra': + if isinstance(x, dict): + return cls( + message=_atd_read_string(x['message']) if 'message' in x else _atd_missing_json_field('CliMatchExtra', 'message'), + metadata=RawJson.from_json(x['metadata']) if 'metadata' in x else _atd_missing_json_field('CliMatchExtra', 'metadata'), + severity=MatchSeverity.from_json(x['severity']) if 'severity' in x else _atd_missing_json_field('CliMatchExtra', 'severity'), + fingerprint=_atd_read_string(x['fingerprint']) if 'fingerprint' in x else _atd_missing_json_field('CliMatchExtra', 'fingerprint'), + lines=_atd_read_string(x['lines']) if 'lines' in x else _atd_missing_json_field('CliMatchExtra', 'lines'), + metavars=Metavars.from_json(x['metavars']) if 'metavars' in x else None, + fix=_atd_read_string(x['fix']) if 'fix' in x else None, + fixed_lines=_atd_read_list(_atd_read_string)(x['fixed_lines']) if 'fixed_lines' in x else None, + is_ignored=_atd_read_bool(x['is_ignored']) if 'is_ignored' in x else None, + sca_info=ScaInfo.from_json(x['sca_info']) if 'sca_info' in x else None, + dataflow_trace=MatchDataflowTrace.from_json(x['dataflow_trace']) if 'dataflow_trace' in x else None, + engine_kind=EngineOfFinding.from_json(x['engine_kind']) if 'engine_kind' in x else None, + validation_state=ValidationState.from_json(x['validation_state']) if 'validation_state' in x else None, + historical_info=HistoricalInfo.from_json(x['historical_info']) if 'historical_info' in x else None, + extra_extra=RawJson.from_json(x['extra_extra']) if 'extra_extra' in x else None, + ) + else: + _atd_bad_json('CliMatchExtra', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['message'] = _atd_write_string(self.message) + res['metadata'] = (lambda x: x.to_json())(self.metadata) + res['severity'] = (lambda x: x.to_json())(self.severity) + res['fingerprint'] = _atd_write_string(self.fingerprint) + res['lines'] = _atd_write_string(self.lines) + if self.metavars is not None: + res['metavars'] = (lambda x: x.to_json())(self.metavars) + if self.fix is not None: + res['fix'] = _atd_write_string(self.fix) + if self.fixed_lines is not None: + res['fixed_lines'] = _atd_write_list(_atd_write_string)(self.fixed_lines) + if self.is_ignored is not None: + res['is_ignored'] = _atd_write_bool(self.is_ignored) + if self.sca_info is not None: + res['sca_info'] = (lambda x: x.to_json())(self.sca_info) + if self.dataflow_trace is not None: + res['dataflow_trace'] = (lambda x: x.to_json())(self.dataflow_trace) + if self.engine_kind is not None: + res['engine_kind'] = (lambda x: x.to_json())(self.engine_kind) + if self.validation_state is not None: + res['validation_state'] = (lambda x: x.to_json())(self.validation_state) + if self.historical_info is not None: + res['historical_info'] = (lambda x: x.to_json())(self.historical_info) + if self.extra_extra is not None: + res['extra_extra'] = (lambda x: x.to_json())(self.extra_extra) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'CliMatchExtra': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True) -class PartialScanResult: - """Original type: partial_scan_result = [ ... ]""" - - value: Union[PartialScanOk, PartialScanError] +@dataclass +class CliMatch: + """Original type: cli_match = { ... }""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return self.value.kind + check_id: RuleId + path: Fpath + start: Position + end: Position + extra: CliMatchExtra @classmethod - def from_json(cls, x: Any) -> 'PartialScanResult': - if isinstance(x, List) and len(x) == 2: - cons = x[0] - if cons == 'PartialScanOk': - return cls(PartialScanOk((lambda x: (CiScanResults.from_json(x[0]), CiScanComplete.from_json(x[1])) if isinstance(x, list) and len(x) == 2 else _atd_bad_json('array of length 2', x))(x[1]))) - if cons == 'PartialScanError': - return cls(PartialScanError(CiScanFailure.from_json(x[1]))) - _atd_bad_json('PartialScanResult', x) - _atd_bad_json('PartialScanResult', x) + def from_json(cls, x: Any) -> 'CliMatch': + if isinstance(x, dict): + return cls( + check_id=RuleId.from_json(x['check_id']) if 'check_id' in x else _atd_missing_json_field('CliMatch', 'check_id'), + path=Fpath.from_json(x['path']) if 'path' in x else _atd_missing_json_field('CliMatch', 'path'), + start=Position.from_json(x['start']) if 'start' in x else _atd_missing_json_field('CliMatch', 'start'), + end=Position.from_json(x['end']) if 'end' in x else _atd_missing_json_field('CliMatch', 'end'), + extra=CliMatchExtra.from_json(x['extra']) if 'extra' in x else _atd_missing_json_field('CliMatch', 'extra'), + ) + else: + _atd_bad_json('CliMatch', x) def to_json(self) -> Any: - return self.value.to_json() + res: Dict[str, Any] = {} + res['check_id'] = (lambda x: x.to_json())(self.check_id) + res['path'] = (lambda x: x.to_json())(self.path) + res['start'] = (lambda x: x.to_json())(self.start) + res['end'] = (lambda x: x.to_json())(self.end) + res['extra'] = (lambda x: x.to_json())(self.extra) + return res @classmethod - def from_json_string(cls, x: str) -> 'PartialScanResult': + def from_json_string(cls, x: str) -> 'CliMatch': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True) -class Text: - """Original type: output_format = [ ... | Text | ... ]""" - - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'Text' - - @staticmethod - def to_json() -> Any: - return 'Text' - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - -@dataclass(frozen=True) -class Json: - """Original type: output_format = [ ... | Json | ... ]""" - - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'Json' - - @staticmethod - def to_json() -> Any: - return 'Json' - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - -@dataclass(frozen=True) -class Emacs: - """Original type: output_format = [ ... | Emacs | ... ]""" - - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'Emacs' - - @staticmethod - def to_json() -> Any: - return 'Emacs' - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - -@dataclass(frozen=True) -class Vim: - """Original type: output_format = [ ... | Vim | ... ]""" - - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'Vim' - - @staticmethod - def to_json() -> Any: - return 'Vim' - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - - -@dataclass(frozen=True) -class Sarif: - """Original type: output_format = [ ... | Sarif | ... ]""" - - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'Sarif' - - @staticmethod - def to_json() -> Any: - return 'Sarif' - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) +@dataclass +class CliError: + """Original type: cli_error = { ... }""" + code: int + level: ErrorSeverity + type_: ErrorType + rule_id: Optional[RuleId] = None + message: Optional[str] = None + path: Optional[Fpath] = None + long_msg: Optional[str] = None + short_msg: Optional[str] = None + spans: Optional[List[ErrorSpan]] = None + help: Optional[str] = None -@dataclass(frozen=True) -class GitlabSast: - """Original type: output_format = [ ... | Gitlab_sast | ... ]""" + @classmethod + def from_json(cls, x: Any) -> 'CliError': + if isinstance(x, dict): + return cls( + code=_atd_read_int(x['code']) if 'code' in x else _atd_missing_json_field('CliError', 'code'), + level=ErrorSeverity.from_json(x['level']) if 'level' in x else _atd_missing_json_field('CliError', 'level'), + type_=ErrorType.from_json(x['type']) if 'type' in x else _atd_missing_json_field('CliError', 'type'), + rule_id=RuleId.from_json(x['rule_id']) if 'rule_id' in x else None, + message=_atd_read_string(x['message']) if 'message' in x else None, + path=Fpath.from_json(x['path']) if 'path' in x else None, + long_msg=_atd_read_string(x['long_msg']) if 'long_msg' in x else None, + short_msg=_atd_read_string(x['short_msg']) if 'short_msg' in x else None, + spans=_atd_read_list(ErrorSpan.from_json)(x['spans']) if 'spans' in x else None, + help=_atd_read_string(x['help']) if 'help' in x else None, + ) + else: + _atd_bad_json('CliError', x) - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'GitlabSast' + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['code'] = _atd_write_int(self.code) + res['level'] = (lambda x: x.to_json())(self.level) + res['type'] = (lambda x: x.to_json())(self.type_) + if self.rule_id is not None: + res['rule_id'] = (lambda x: x.to_json())(self.rule_id) + if self.message is not None: + res['message'] = _atd_write_string(self.message) + if self.path is not None: + res['path'] = (lambda x: x.to_json())(self.path) + if self.long_msg is not None: + res['long_msg'] = _atd_write_string(self.long_msg) + if self.short_msg is not None: + res['short_msg'] = _atd_write_string(self.short_msg) + if self.spans is not None: + res['spans'] = _atd_write_list((lambda x: x.to_json()))(self.spans) + if self.help is not None: + res['help'] = _atd_write_string(self.help) + return res - @staticmethod - def to_json() -> Any: - return 'Gitlab_sast' + @classmethod + def from_json_string(cls, x: str) -> 'CliError': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class GitlabSecrets: - """Original type: output_format = [ ... | Gitlab_secrets | ... ]""" - - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'GitlabSecrets' - - @staticmethod - def to_json() -> Any: - return 'Gitlab_secrets' - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) +class SarifFormatParams: + """Original type: sarif_format_params = { ... }""" + hide_nudge: bool + engine_label: str + rules: Fpath + cli_matches: List[CliMatch] + cli_errors: List[CliError] + show_dataflow_traces: Optional[bool] = None -@dataclass(frozen=True) -class JunitXml: - """Original type: output_format = [ ... | Junit_xml | ... ]""" + @classmethod + def from_json(cls, x: Any) -> 'SarifFormatParams': + if isinstance(x, dict): + return cls( + hide_nudge=_atd_read_bool(x['hide_nudge']) if 'hide_nudge' in x else _atd_missing_json_field('SarifFormatParams', 'hide_nudge'), + engine_label=_atd_read_string(x['engine_label']) if 'engine_label' in x else _atd_missing_json_field('SarifFormatParams', 'engine_label'), + rules=Fpath.from_json(x['rules']) if 'rules' in x else _atd_missing_json_field('SarifFormatParams', 'rules'), + cli_matches=_atd_read_list(CliMatch.from_json)(x['cli_matches']) if 'cli_matches' in x else _atd_missing_json_field('SarifFormatParams', 'cli_matches'), + cli_errors=_atd_read_list(CliError.from_json)(x['cli_errors']) if 'cli_errors' in x else _atd_missing_json_field('SarifFormatParams', 'cli_errors'), + show_dataflow_traces=_atd_read_bool(x['show_dataflow_traces']) if 'show_dataflow_traces' in x else None, + ) + else: + _atd_bad_json('SarifFormatParams', x) - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'JunitXml' + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['hide_nudge'] = _atd_write_bool(self.hide_nudge) + res['engine_label'] = _atd_write_string(self.engine_label) + res['rules'] = (lambda x: x.to_json())(self.rules) + res['cli_matches'] = _atd_write_list((lambda x: x.to_json()))(self.cli_matches) + res['cli_errors'] = _atd_write_list((lambda x: x.to_json()))(self.cli_errors) + if self.show_dataflow_traces is not None: + res['show_dataflow_traces'] = _atd_write_bool(self.show_dataflow_traces) + return res - @staticmethod - def to_json() -> Any: - return 'Junit_xml' + @classmethod + def from_json_string(cls, x: str) -> 'SarifFormatParams': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True) -class FilesWithMatches: - """Original type: output_format = [ ... | Files_with_matches | ... ]""" +@dataclass(frozen=True) +class OSS_: + """Original type: engine_kind = [ ... | OSS | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'FilesWithMatches' + return 'OSS_' @staticmethod def to_json() -> Any: - return 'Files_with_matches' + return 'OSS' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class Incremental: - """Original type: output_format = [ ... | Incremental | ... ]""" +class PRO_: + """Original type: engine_kind = [ ... | PRO | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Incremental' + return 'PRO_' @staticmethod def to_json() -> Any: - return 'Incremental' + return 'PRO' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class OutputFormat: - """Original type: output_format = [ ... ]""" +class EngineKind: + """Original type: engine_kind = [ ... ]""" - value: Union[Text, Json, Emacs, Vim, Sarif, GitlabSast, GitlabSecrets, JunitXml, FilesWithMatches, Incremental] + value: Union[OSS_, PRO_] @property def kind(self) -> str: @@ -6711,36 +6711,20 @@ def kind(self) -> str: return self.value.kind @classmethod - def from_json(cls, x: Any) -> 'OutputFormat': + def from_json(cls, x: Any) -> 'EngineKind': if isinstance(x, str): - if x == 'Text': - return cls(Text()) - if x == 'Json': - return cls(Json()) - if x == 'Emacs': - return cls(Emacs()) - if x == 'Vim': - return cls(Vim()) - if x == 'Sarif': - return cls(Sarif()) - if x == 'Gitlab_sast': - return cls(GitlabSast()) - if x == 'Gitlab_secrets': - return cls(GitlabSecrets()) - if x == 'Junit_xml': - return cls(JunitXml()) - if x == 'Files_with_matches': - return cls(FilesWithMatches()) - if x == 'Incremental': - return cls(Incremental()) - _atd_bad_json('OutputFormat', x) - _atd_bad_json('OutputFormat', x) + if x == 'OSS': + return cls(OSS_()) + if x == 'PRO': + return cls(PRO_()) + _atd_bad_json('EngineKind', x) + _atd_bad_json('EngineKind', x) def to_json(self) -> Any: return self.value.to_json() @classmethod - def from_json_string(cls, x: str) -> 'OutputFormat': + def from_json_string(cls, x: str) -> 'EngineKind': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: @@ -6748,675 +6732,958 @@ def to_json_string(self, **kw: Any) -> str: @dataclass(frozen=True) -class RequirementsIn: - """Original type: manifest_kind = [ ... | RequirementsIn | ... ]""" +class RuleIdAndEngineKind: + """Original type: rule_id_and_engine_kind""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'RequirementsIn' + value: Tuple[RuleId, EngineKind] - @staticmethod - def to_json() -> Any: - return 'RequirementsIn' + @classmethod + def from_json(cls, x: Any) -> 'RuleIdAndEngineKind': + return cls((lambda x: (RuleId.from_json(x[0]), EngineKind.from_json(x[1])) if isinstance(x, list) and len(x) == 2 else _atd_bad_json('array of length 2', x))(x)) + + def to_json(self) -> Any: + return (lambda x: [(lambda x: x.to_json())(x[0]), (lambda x: x.to_json())(x[1])] if isinstance(x, tuple) and len(x) == 2 else _atd_bad_python('tuple of length 2', x))(self.value) + + @classmethod + def from_json_string(cls, x: str) -> 'RuleIdAndEngineKind': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True) -class PackageJson: - """Original type: manifest_kind = [ ... | PackageJson | ... ]""" +@dataclass +class ResolutionOk: + """Original type: resolution_result = [ ... | ResolutionOk of ... | ... ]""" + + value: Tuple[List[FoundDependency], List[ResolutionError]] @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'PackageJson' + return 'ResolutionOk' - @staticmethod - def to_json() -> Any: - return 'PackageJson' + def to_json(self) -> Any: + return ['ResolutionOk', (lambda x: [_atd_write_list((lambda x: x.to_json()))(x[0]), _atd_write_list((lambda x: x.to_json()))(x[1])] if isinstance(x, tuple) and len(x) == 2 else _atd_bad_python('tuple of length 2', x))(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True) -class Gemfile: - """Original type: manifest_kind = [ ... | Gemfile | ... ]""" +@dataclass +class ResolutionError_: + """Original type: resolution_result = [ ... | ResolutionError of ... | ... ]""" + + value: List[ResolutionError] @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'Gemfile' + return 'ResolutionError_' - @staticmethod - def to_json() -> Any: - return 'Gemfile' + def to_json(self) -> Any: + return ['ResolutionError', _atd_write_list((lambda x: x.to_json()))(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True) -class GoMod_: - """Original type: manifest_kind = [ ... | GoMod | ... ]""" +@dataclass +class ResolutionResult: + """Original type: resolution_result = [ ... ]""" + + value: Union[ResolutionOk, ResolutionError_] @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'GoMod_' + return self.value.kind - @staticmethod - def to_json() -> Any: - return 'GoMod' + @classmethod + def from_json(cls, x: Any) -> 'ResolutionResult': + if isinstance(x, List) and len(x) == 2: + cons = x[0] + if cons == 'ResolutionOk': + return cls(ResolutionOk((lambda x: (_atd_read_list(FoundDependency.from_json)(x[0]), _atd_read_list(ResolutionError.from_json)(x[1])) if isinstance(x, list) and len(x) == 2 else _atd_bad_json('array of length 2', x))(x[1]))) + if cons == 'ResolutionError': + return cls(ResolutionError_(_atd_read_list(ResolutionError.from_json)(x[1]))) + _atd_bad_json('ResolutionResult', x) + _atd_bad_json('ResolutionResult', x) + + def to_json(self) -> Any: + return self.value.to_json() + + @classmethod + def from_json_string(cls, x: str) -> 'ResolutionResult': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True) -class CargoToml: - """Original type: manifest_kind = [ ... | CargoToml | ... ]""" +@dataclass +class Profile: + """Original type: profile = { ... }""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'CargoToml' + rules: List[RuleId] + rules_parse_time: float + profiling_times: Dict[str, float] + targets: List[TargetTimes] + total_bytes: int + max_memory_bytes: Optional[int] = None - @staticmethod - def to_json() -> Any: - return 'CargoToml' + @classmethod + def from_json(cls, x: Any) -> 'Profile': + if isinstance(x, dict): + return cls( + rules=_atd_read_list(RuleId.from_json)(x['rules']) if 'rules' in x else _atd_missing_json_field('Profile', 'rules'), + rules_parse_time=_atd_read_float(x['rules_parse_time']) if 'rules_parse_time' in x else _atd_missing_json_field('Profile', 'rules_parse_time'), + profiling_times=_atd_read_assoc_object_into_dict(_atd_read_float)(x['profiling_times']) if 'profiling_times' in x else _atd_missing_json_field('Profile', 'profiling_times'), + targets=_atd_read_list(TargetTimes.from_json)(x['targets']) if 'targets' in x else _atd_missing_json_field('Profile', 'targets'), + total_bytes=_atd_read_int(x['total_bytes']) if 'total_bytes' in x else _atd_missing_json_field('Profile', 'total_bytes'), + max_memory_bytes=_atd_read_int(x['max_memory_bytes']) if 'max_memory_bytes' in x else None, + ) + else: + _atd_bad_json('Profile', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['rules'] = _atd_write_list((lambda x: x.to_json()))(self.rules) + res['rules_parse_time'] = _atd_write_float(self.rules_parse_time) + res['profiling_times'] = _atd_write_assoc_dict_to_object(_atd_write_float)(self.profiling_times) + res['targets'] = _atd_write_list((lambda x: x.to_json()))(self.targets) + res['total_bytes'] = _atd_write_int(self.total_bytes) + if self.max_memory_bytes is not None: + res['max_memory_bytes'] = _atd_write_int(self.max_memory_bytes) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'Profile': + return cls.from_json(json.loads(x)) + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass +class ParsingStats: + """Original type: parsing_stats = { ... }""" + + targets_parsed: int + num_targets: int + bytes_parsed: int + num_bytes: int + + @classmethod + def from_json(cls, x: Any) -> 'ParsingStats': + if isinstance(x, dict): + return cls( + targets_parsed=_atd_read_int(x['targets_parsed']) if 'targets_parsed' in x else _atd_missing_json_field('ParsingStats', 'targets_parsed'), + num_targets=_atd_read_int(x['num_targets']) if 'num_targets' in x else _atd_missing_json_field('ParsingStats', 'num_targets'), + bytes_parsed=_atd_read_int(x['bytes_parsed']) if 'bytes_parsed' in x else _atd_missing_json_field('ParsingStats', 'bytes_parsed'), + num_bytes=_atd_read_int(x['num_bytes']) if 'num_bytes' in x else _atd_missing_json_field('ParsingStats', 'num_bytes'), + ) + else: + _atd_bad_json('ParsingStats', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['targets_parsed'] = _atd_write_int(self.targets_parsed) + res['num_targets'] = _atd_write_int(self.num_targets) + res['bytes_parsed'] = _atd_write_int(self.bytes_parsed) + res['num_bytes'] = _atd_write_int(self.num_bytes) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'ParsingStats': + return cls.from_json(json.loads(x)) + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + +@dataclass +class FindingHashes: + """Original type: finding_hashes = { ... }""" + + start_line_hash: str + end_line_hash: str + code_hash: str + pattern_hash: str + + @classmethod + def from_json(cls, x: Any) -> 'FindingHashes': + if isinstance(x, dict): + return cls( + start_line_hash=_atd_read_string(x['start_line_hash']) if 'start_line_hash' in x else _atd_missing_json_field('FindingHashes', 'start_line_hash'), + end_line_hash=_atd_read_string(x['end_line_hash']) if 'end_line_hash' in x else _atd_missing_json_field('FindingHashes', 'end_line_hash'), + code_hash=_atd_read_string(x['code_hash']) if 'code_hash' in x else _atd_missing_json_field('FindingHashes', 'code_hash'), + pattern_hash=_atd_read_string(x['pattern_hash']) if 'pattern_hash' in x else _atd_missing_json_field('FindingHashes', 'pattern_hash'), + ) + else: + _atd_bad_json('FindingHashes', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['start_line_hash'] = _atd_write_string(self.start_line_hash) + res['end_line_hash'] = _atd_write_string(self.end_line_hash) + res['code_hash'] = _atd_write_string(self.code_hash) + res['pattern_hash'] = _atd_write_string(self.pattern_hash) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'FindingHashes': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True) -class PomXml: - """Original type: manifest_kind = [ ... | PomXml | ... ]""" - - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'PomXml' - - @staticmethod - def to_json() -> Any: - return 'PomXml' - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) +@dataclass +class Finding: + """Original type: finding = { ... }""" + check_id: RuleId + path: Fpath + line: int + column: int + end_line: int + end_column: int + message: str + severity: Any + index: int + commit_date: str + syntactic_id: str + metadata: RawJson + is_blocking: bool + match_based_id: Optional[str] = None + hashes: Optional[FindingHashes] = None + fixed_lines: Optional[List[str]] = None + sca_info: Optional[ScaInfo] = None + dataflow_trace: Optional[MatchDataflowTrace] = None + validation_state: Optional[ValidationState] = None + historical_info: Optional[HistoricalInfo] = None + engine_kind: Optional[EngineOfFinding] = None -@dataclass(frozen=True) -class BuildGradle: - """Original type: manifest_kind = [ ... | BuildGradle | ... ]""" + @classmethod + def from_json(cls, x: Any) -> 'Finding': + if isinstance(x, dict): + return cls( + check_id=RuleId.from_json(x['check_id']) if 'check_id' in x else _atd_missing_json_field('Finding', 'check_id'), + path=Fpath.from_json(x['path']) if 'path' in x else _atd_missing_json_field('Finding', 'path'), + line=_atd_read_int(x['line']) if 'line' in x else _atd_missing_json_field('Finding', 'line'), + column=_atd_read_int(x['column']) if 'column' in x else _atd_missing_json_field('Finding', 'column'), + end_line=_atd_read_int(x['end_line']) if 'end_line' in x else _atd_missing_json_field('Finding', 'end_line'), + end_column=_atd_read_int(x['end_column']) if 'end_column' in x else _atd_missing_json_field('Finding', 'end_column'), + message=_atd_read_string(x['message']) if 'message' in x else _atd_missing_json_field('Finding', 'message'), + severity=(lambda x: x)(x['severity']) if 'severity' in x else _atd_missing_json_field('Finding', 'severity'), + index=_atd_read_int(x['index']) if 'index' in x else _atd_missing_json_field('Finding', 'index'), + commit_date=_atd_read_string(x['commit_date']) if 'commit_date' in x else _atd_missing_json_field('Finding', 'commit_date'), + syntactic_id=_atd_read_string(x['syntactic_id']) if 'syntactic_id' in x else _atd_missing_json_field('Finding', 'syntactic_id'), + metadata=RawJson.from_json(x['metadata']) if 'metadata' in x else _atd_missing_json_field('Finding', 'metadata'), + is_blocking=_atd_read_bool(x['is_blocking']) if 'is_blocking' in x else _atd_missing_json_field('Finding', 'is_blocking'), + match_based_id=_atd_read_string(x['match_based_id']) if 'match_based_id' in x else None, + hashes=FindingHashes.from_json(x['hashes']) if 'hashes' in x else None, + fixed_lines=_atd_read_list(_atd_read_string)(x['fixed_lines']) if 'fixed_lines' in x else None, + sca_info=ScaInfo.from_json(x['sca_info']) if 'sca_info' in x else None, + dataflow_trace=MatchDataflowTrace.from_json(x['dataflow_trace']) if 'dataflow_trace' in x else None, + validation_state=ValidationState.from_json(x['validation_state']) if 'validation_state' in x else None, + historical_info=HistoricalInfo.from_json(x['historical_info']) if 'historical_info' in x else None, + engine_kind=EngineOfFinding.from_json(x['engine_kind']) if 'engine_kind' in x else None, + ) + else: + _atd_bad_json('Finding', x) - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'BuildGradle' + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['check_id'] = (lambda x: x.to_json())(self.check_id) + res['path'] = (lambda x: x.to_json())(self.path) + res['line'] = _atd_write_int(self.line) + res['column'] = _atd_write_int(self.column) + res['end_line'] = _atd_write_int(self.end_line) + res['end_column'] = _atd_write_int(self.end_column) + res['message'] = _atd_write_string(self.message) + res['severity'] = (lambda x: x)(self.severity) + res['index'] = _atd_write_int(self.index) + res['commit_date'] = _atd_write_string(self.commit_date) + res['syntactic_id'] = _atd_write_string(self.syntactic_id) + res['metadata'] = (lambda x: x.to_json())(self.metadata) + res['is_blocking'] = _atd_write_bool(self.is_blocking) + if self.match_based_id is not None: + res['match_based_id'] = _atd_write_string(self.match_based_id) + if self.hashes is not None: + res['hashes'] = (lambda x: x.to_json())(self.hashes) + if self.fixed_lines is not None: + res['fixed_lines'] = _atd_write_list(_atd_write_string)(self.fixed_lines) + if self.sca_info is not None: + res['sca_info'] = (lambda x: x.to_json())(self.sca_info) + if self.dataflow_trace is not None: + res['dataflow_trace'] = (lambda x: x.to_json())(self.dataflow_trace) + if self.validation_state is not None: + res['validation_state'] = (lambda x: x.to_json())(self.validation_state) + if self.historical_info is not None: + res['historical_info'] = (lambda x: x.to_json())(self.historical_info) + if self.engine_kind is not None: + res['engine_kind'] = (lambda x: x.to_json())(self.engine_kind) + return res - @staticmethod - def to_json() -> Any: - return 'BuildGradle' + @classmethod + def from_json_string(cls, x: str) -> 'Finding': + return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) -@dataclass(frozen=True) -class SettingsGradle: - """Original type: manifest_kind = [ ... | SettingsGradle | ... ]""" - - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'SettingsGradle' - - @staticmethod - def to_json() -> Any: - return 'SettingsGradle' - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) +@dataclass +class DependencyParserError: + """Original type: dependency_parser_error = { ... }""" + path: str + parser: ScaParserName + reason: str + line: Optional[int] = None + col: Optional[int] = None + text: Optional[str] = None -@dataclass(frozen=True) -class ComposerJson: - """Original type: manifest_kind = [ ... | ComposerJson | ... ]""" + @classmethod + def from_json(cls, x: Any) -> 'DependencyParserError': + if isinstance(x, dict): + return cls( + path=_atd_read_string(x['path']) if 'path' in x else _atd_missing_json_field('DependencyParserError', 'path'), + parser=ScaParserName.from_json(x['parser']) if 'parser' in x else _atd_missing_json_field('DependencyParserError', 'parser'), + reason=_atd_read_string(x['reason']) if 'reason' in x else _atd_missing_json_field('DependencyParserError', 'reason'), + line=_atd_read_int(x['line']) if 'line' in x else None, + col=_atd_read_int(x['col']) if 'col' in x else None, + text=_atd_read_string(x['text']) if 'text' in x else None, + ) + else: + _atd_bad_json('DependencyParserError', x) - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'ComposerJson' + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['path'] = _atd_write_string(self.path) + res['parser'] = (lambda x: x.to_json())(self.parser) + res['reason'] = _atd_write_string(self.reason) + if self.line is not None: + res['line'] = _atd_write_int(self.line) + if self.col is not None: + res['col'] = _atd_write_int(self.col) + if self.text is not None: + res['text'] = _atd_write_string(self.text) + return res - @staticmethod - def to_json() -> Any: - return 'ComposerJson' + @classmethod + def from_json_string(cls, x: str) -> 'DependencyParserError': + 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 NugetManifestJson: - """Original type: manifest_kind = [ ... | NugetManifestJson | ... ]""" - - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'NugetManifestJson' - - @staticmethod - def to_json() -> Any: - return 'NugetManifestJson' - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) +@dataclass +class Contributor: + """Original type: contributor = { ... }""" + commit_author_name: str + commit_author_email: str -@dataclass(frozen=True) -class PubspecYaml: - """Original type: manifest_kind = [ ... | PubspecYaml | ... ]""" + @classmethod + def from_json(cls, x: Any) -> 'Contributor': + if isinstance(x, dict): + return cls( + commit_author_name=_atd_read_string(x['commit_author_name']) if 'commit_author_name' in x else _atd_missing_json_field('Contributor', 'commit_author_name'), + commit_author_email=_atd_read_string(x['commit_author_email']) if 'commit_author_email' in x else _atd_missing_json_field('Contributor', 'commit_author_email'), + ) + else: + _atd_bad_json('Contributor', x) - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'PubspecYaml' + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['commit_author_name'] = _atd_write_string(self.commit_author_name) + res['commit_author_email'] = _atd_write_string(self.commit_author_email) + return res - @staticmethod - def to_json() -> Any: - return 'PubspecYaml' + @classmethod + def from_json_string(cls, x: str) -> 'Contributor': + 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 PackageSwift_: - """Original type: manifest_kind = [ ... | PackageSwift | ... ]""" +@dataclass +class Contribution: + """Original type: contribution = { ... }""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'PackageSwift_' + commit_hash: str + commit_timestamp: Datetime + contributor: Contributor - @staticmethod - def to_json() -> Any: - return 'PackageSwift' + @classmethod + def from_json(cls, x: Any) -> 'Contribution': + if isinstance(x, dict): + return cls( + commit_hash=_atd_read_string(x['commit_hash']) if 'commit_hash' in x else _atd_missing_json_field('Contribution', 'commit_hash'), + commit_timestamp=Datetime.from_json(x['commit_timestamp']) if 'commit_timestamp' in x else _atd_missing_json_field('Contribution', 'commit_timestamp'), + contributor=Contributor.from_json(x['contributor']) if 'contributor' in x else _atd_missing_json_field('Contribution', 'contributor'), + ) + else: + _atd_bad_json('Contribution', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['commit_hash'] = _atd_write_string(self.commit_hash) + res['commit_timestamp'] = (lambda x: x.to_json())(self.commit_timestamp) + res['contributor'] = (lambda x: x.to_json())(self.contributor) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'Contribution': + 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 MixExs: - """Original type: manifest_kind = [ ... | MixExs | ... ]""" +@dataclass +class Contributions: + """Original type: contributions""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'MixExs' + value: List[Contribution] - @staticmethod - def to_json() -> Any: - return 'MixExs' + @classmethod + def from_json(cls, x: Any) -> 'Contributions': + return cls(_atd_read_list(Contribution.from_json)(x)) + + def to_json(self) -> Any: + return _atd_write_list((lambda x: x.to_json()))(self.value) + + @classmethod + def from_json_string(cls, x: str) -> 'Contributions': + 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 Pipfile_: - """Original type: manifest_kind = [ ... | Pipfile | ... ]""" +@dataclass +class CiScanDependencies: + """Original type: ci_scan_dependencies""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'Pipfile_' + value: Dict[str, List[FoundDependency]] - @staticmethod - def to_json() -> Any: - return 'Pipfile' + @classmethod + def from_json(cls, x: Any) -> 'CiScanDependencies': + return cls(_atd_read_assoc_object_into_dict(_atd_read_list(FoundDependency.from_json))(x)) + + def to_json(self) -> Any: + return _atd_write_assoc_dict_to_object(_atd_write_list((lambda x: x.to_json())))(self.value) + + @classmethod + def from_json_string(cls, x: str) -> 'CiScanDependencies': + 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 PyprojectToml_: - """Original type: manifest_kind = [ ... | PyprojectToml | ... ]""" +@dataclass +class CiScanResults: + """Original type: ci_scan_results = { ... }""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'PyprojectToml_' + findings: List[Finding] + ignores: List[Finding] + token: Optional[str] + searched_paths: List[Fpath] + renamed_paths: List[Fpath] + rule_ids: List[RuleId] + contributions: Optional[Contributions] = None + dependencies: Optional[CiScanDependencies] = None - @staticmethod - def to_json() -> Any: - return 'PyprojectToml' + @classmethod + def from_json(cls, x: Any) -> 'CiScanResults': + if isinstance(x, dict): + return cls( + findings=_atd_read_list(Finding.from_json)(x['findings']) if 'findings' in x else _atd_missing_json_field('CiScanResults', 'findings'), + ignores=_atd_read_list(Finding.from_json)(x['ignores']) if 'ignores' in x else _atd_missing_json_field('CiScanResults', 'ignores'), + token=_atd_read_nullable(_atd_read_string)(x['token']) if 'token' in x else _atd_missing_json_field('CiScanResults', 'token'), + searched_paths=_atd_read_list(Fpath.from_json)(x['searched_paths']) if 'searched_paths' in x else _atd_missing_json_field('CiScanResults', 'searched_paths'), + renamed_paths=_atd_read_list(Fpath.from_json)(x['renamed_paths']) if 'renamed_paths' in x else _atd_missing_json_field('CiScanResults', 'renamed_paths'), + rule_ids=_atd_read_list(RuleId.from_json)(x['rule_ids']) if 'rule_ids' in x else _atd_missing_json_field('CiScanResults', 'rule_ids'), + contributions=Contributions.from_json(x['contributions']) if 'contributions' in x else None, + dependencies=CiScanDependencies.from_json(x['dependencies']) if 'dependencies' in x else None, + ) + else: + _atd_bad_json('CiScanResults', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['findings'] = _atd_write_list((lambda x: x.to_json()))(self.findings) + res['ignores'] = _atd_write_list((lambda x: x.to_json()))(self.ignores) + res['token'] = _atd_write_nullable(_atd_write_string)(self.token) + res['searched_paths'] = _atd_write_list((lambda x: x.to_json()))(self.searched_paths) + res['renamed_paths'] = _atd_write_list((lambda x: x.to_json()))(self.renamed_paths) + res['rule_ids'] = _atd_write_list((lambda x: x.to_json()))(self.rule_ids) + if self.contributions is not None: + res['contributions'] = (lambda x: x.to_json())(self.contributions) + if self.dependencies is not None: + res['dependencies'] = (lambda x: x.to_json())(self.dependencies) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'CiScanResults': + 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 ManifestKind: - """Original type: manifest_kind = [ ... ]""" - - value: Union[RequirementsIn, PackageJson, Gemfile, GoMod_, CargoToml, PomXml, BuildGradle, SettingsGradle, ComposerJson, NugetManifestJson, PubspecYaml, PackageSwift_, MixExs, Pipfile_, PyprojectToml_] +@dataclass +class CiScanFailure: + """Original type: ci_scan_failure = { ... }""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return self.value.kind + exit_code: int + stderr: str @classmethod - def from_json(cls, x: Any) -> 'ManifestKind': - if isinstance(x, str): - if x == 'RequirementsIn': - return cls(RequirementsIn()) - if x == 'PackageJson': - return cls(PackageJson()) - if x == 'Gemfile': - return cls(Gemfile()) - if x == 'GoMod': - return cls(GoMod_()) - if x == 'CargoToml': - return cls(CargoToml()) - if x == 'PomXml': - return cls(PomXml()) - if x == 'BuildGradle': - return cls(BuildGradle()) - if x == 'SettingsGradle': - return cls(SettingsGradle()) - if x == 'ComposerJson': - return cls(ComposerJson()) - if x == 'NugetManifestJson': - return cls(NugetManifestJson()) - if x == 'PubspecYaml': - return cls(PubspecYaml()) - if x == 'PackageSwift': - return cls(PackageSwift_()) - if x == 'MixExs': - return cls(MixExs()) - if x == 'Pipfile': - return cls(Pipfile_()) - if x == 'PyprojectToml': - return cls(PyprojectToml_()) - _atd_bad_json('ManifestKind', x) - _atd_bad_json('ManifestKind', x) + def from_json(cls, x: Any) -> 'CiScanFailure': + if isinstance(x, dict): + return cls( + exit_code=_atd_read_int(x['exit_code']) if 'exit_code' in x else _atd_missing_json_field('CiScanFailure', 'exit_code'), + stderr=_atd_read_string(x['stderr']) if 'stderr' in x else _atd_missing_json_field('CiScanFailure', 'stderr'), + ) + else: + _atd_bad_json('CiScanFailure', x) def to_json(self) -> Any: - return self.value.to_json() + res: Dict[str, Any] = {} + res['exit_code'] = _atd_write_int(self.exit_code) + res['stderr'] = _atd_write_string(self.stderr) + return res @classmethod - def from_json_string(cls, x: str) -> 'ManifestKind': + def from_json_string(cls, x: str) -> 'CiScanFailure': 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 Manifest: - """Original type: manifest = { ... }""" +@dataclass +class CiScanCompleteStats: + """Original type: ci_scan_complete_stats = { ... }""" - kind: ManifestKind - path: Fpath + findings: int + errors: List[CliError] + total_time: float + unsupported_exts: Dict[str, int] + lockfile_scan_info: Dict[str, int] + parse_rate: Dict[str, ParsingStats] + engine_requested: Optional[str] = None + findings_by_product: Optional[Dict[str, int]] = None + supply_chain_stats: Optional[SupplyChainStats] = None @classmethod - def from_json(cls, x: Any) -> 'Manifest': + def from_json(cls, x: Any) -> 'CiScanCompleteStats': if isinstance(x, dict): return cls( - kind=ManifestKind.from_json(x['kind']) if 'kind' in x else _atd_missing_json_field('Manifest', 'kind'), - path=Fpath.from_json(x['path']) if 'path' in x else _atd_missing_json_field('Manifest', 'path'), + findings=_atd_read_int(x['findings']) if 'findings' in x else _atd_missing_json_field('CiScanCompleteStats', 'findings'), + errors=_atd_read_list(CliError.from_json)(x['errors']) if 'errors' in x else _atd_missing_json_field('CiScanCompleteStats', 'errors'), + total_time=_atd_read_float(x['total_time']) if 'total_time' in x else _atd_missing_json_field('CiScanCompleteStats', 'total_time'), + unsupported_exts=_atd_read_assoc_object_into_dict(_atd_read_int)(x['unsupported_exts']) if 'unsupported_exts' in x else _atd_missing_json_field('CiScanCompleteStats', 'unsupported_exts'), + lockfile_scan_info=_atd_read_assoc_object_into_dict(_atd_read_int)(x['lockfile_scan_info']) if 'lockfile_scan_info' in x else _atd_missing_json_field('CiScanCompleteStats', 'lockfile_scan_info'), + parse_rate=_atd_read_assoc_object_into_dict(ParsingStats.from_json)(x['parse_rate']) if 'parse_rate' in x else _atd_missing_json_field('CiScanCompleteStats', 'parse_rate'), + engine_requested=_atd_read_string(x['engine_requested']) if 'engine_requested' in x else None, + findings_by_product=_atd_read_assoc_object_into_dict(_atd_read_int)(x['findings_by_product']) if 'findings_by_product' in x else None, + supply_chain_stats=SupplyChainStats.from_json(x['supply_chain_stats']) if 'supply_chain_stats' in x else None, ) else: - _atd_bad_json('Manifest', x) + _atd_bad_json('CiScanCompleteStats', x) def to_json(self) -> Any: res: Dict[str, Any] = {} - res['kind'] = (lambda x: x.to_json())(self.kind) - res['path'] = (lambda x: x.to_json())(self.path) + res['findings'] = _atd_write_int(self.findings) + res['errors'] = _atd_write_list((lambda x: x.to_json()))(self.errors) + res['total_time'] = _atd_write_float(self.total_time) + res['unsupported_exts'] = _atd_write_assoc_dict_to_object(_atd_write_int)(self.unsupported_exts) + res['lockfile_scan_info'] = _atd_write_assoc_dict_to_object(_atd_write_int)(self.lockfile_scan_info) + res['parse_rate'] = _atd_write_assoc_dict_to_object((lambda x: x.to_json()))(self.parse_rate) + if self.engine_requested is not None: + res['engine_requested'] = _atd_write_string(self.engine_requested) + if self.findings_by_product is not None: + res['findings_by_product'] = _atd_write_assoc_dict_to_object(_atd_write_int)(self.findings_by_product) + if self.supply_chain_stats is not None: + res['supply_chain_stats'] = (lambda x: x.to_json())(self.supply_chain_stats) return res @classmethod - def from_json_string(cls, x: str) -> 'Manifest': + def from_json_string(cls, x: str) -> 'CiScanCompleteStats': 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 PipRequirementsTxt: - """Original type: lockfile_kind = [ ... | PipRequirementsTxt | ... ]""" +@dataclass +class CiScanComplete: + """Original type: ci_scan_complete = { ... }""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'PipRequirementsTxt' + exit_code: int + stats: CiScanCompleteStats + dependencies: Optional[CiScanDependencies] = None + dependency_parser_errors: Optional[List[DependencyParserError]] = None + task_id: Optional[str] = None + final_attempt: Optional[bool] = None - @staticmethod - def to_json() -> Any: - return 'PipRequirementsTxt' + @classmethod + def from_json(cls, x: Any) -> 'CiScanComplete': + if isinstance(x, dict): + return cls( + exit_code=_atd_read_int(x['exit_code']) if 'exit_code' in x else _atd_missing_json_field('CiScanComplete', 'exit_code'), + stats=CiScanCompleteStats.from_json(x['stats']) if 'stats' in x else _atd_missing_json_field('CiScanComplete', 'stats'), + dependencies=CiScanDependencies.from_json(x['dependencies']) if 'dependencies' in x else None, + dependency_parser_errors=_atd_read_list(DependencyParserError.from_json)(x['dependency_parser_errors']) if 'dependency_parser_errors' in x else None, + task_id=_atd_read_string(x['task_id']) if 'task_id' in x else None, + final_attempt=_atd_read_bool(x['final_attempt']) if 'final_attempt' in x else None, + ) + else: + _atd_bad_json('CiScanComplete', x) + + def to_json(self) -> Any: + res: Dict[str, Any] = {} + res['exit_code'] = _atd_write_int(self.exit_code) + res['stats'] = (lambda x: x.to_json())(self.stats) + if self.dependencies is not None: + res['dependencies'] = (lambda x: x.to_json())(self.dependencies) + if self.dependency_parser_errors is not None: + res['dependency_parser_errors'] = _atd_write_list((lambda x: x.to_json()))(self.dependency_parser_errors) + if self.task_id is not None: + res['task_id'] = _atd_write_string(self.task_id) + if self.final_attempt is not None: + res['final_attempt'] = _atd_write_bool(self.final_attempt) + return res + + @classmethod + def from_json_string(cls, x: str) -> 'CiScanComplete': + 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 PoetryLock_: - """Original type: lockfile_kind = [ ... | PoetryLock | ... ]""" +class PartialScanOk: + """Original type: partial_scan_result = [ ... | PartialScanOk of ... | ... ]""" + + value: Tuple[CiScanResults, CiScanComplete] @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'PoetryLock_' + return 'PartialScanOk' - @staticmethod - def to_json() -> Any: - return 'PoetryLock' + def to_json(self) -> Any: + return ['PartialScanOk', (lambda x: [(lambda x: x.to_json())(x[0]), (lambda x: x.to_json())(x[1])] if isinstance(x, tuple) and len(x) == 2 else _atd_bad_python('tuple of length 2', x))(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class PipfileLock: - """Original type: lockfile_kind = [ ... | PipfileLock | ... ]""" +class PartialScanError: + """Original type: partial_scan_result = [ ... | PartialScanError of ... | ... ]""" + + value: CiScanFailure @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'PipfileLock' + return 'PartialScanError' - @staticmethod - def to_json() -> Any: - return 'PipfileLock' + def to_json(self) -> Any: + return ['PartialScanError', (lambda x: x.to_json())(self.value)] def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class NpmPackageLockJson: - """Original type: lockfile_kind = [ ... | NpmPackageLockJson | ... ]""" +class PartialScanResult: + """Original type: partial_scan_result = [ ... ]""" + + value: Union[PartialScanOk, PartialScanError] @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'NpmPackageLockJson' - - @staticmethod - def to_json() -> Any: - return 'NpmPackageLockJson' - - def to_json_string(self, **kw: Any) -> str: - return json.dumps(self.to_json(), **kw) - + return self.value.kind -@dataclass(frozen=True) -class YarnLock: - """Original type: lockfile_kind = [ ... | YarnLock | ... ]""" + @classmethod + def from_json(cls, x: Any) -> 'PartialScanResult': + if isinstance(x, List) and len(x) == 2: + cons = x[0] + if cons == 'PartialScanOk': + return cls(PartialScanOk((lambda x: (CiScanResults.from_json(x[0]), CiScanComplete.from_json(x[1])) if isinstance(x, list) and len(x) == 2 else _atd_bad_json('array of length 2', x))(x[1]))) + if cons == 'PartialScanError': + return cls(PartialScanError(CiScanFailure.from_json(x[1]))) + _atd_bad_json('PartialScanResult', x) + _atd_bad_json('PartialScanResult', x) - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return 'YarnLock' + def to_json(self) -> Any: + return self.value.to_json() - @staticmethod - def to_json() -> Any: - return 'YarnLock' + @classmethod + def from_json_string(cls, x: str) -> 'PartialScanResult': + 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 PnpmLock_: - """Original type: lockfile_kind = [ ... | PnpmLock | ... ]""" +class Text: + """Original type: output_format = [ ... | Text | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'PnpmLock_' + return 'Text' @staticmethod def to_json() -> Any: - return 'PnpmLock' + return 'Text' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class GemfileLock_: - """Original type: lockfile_kind = [ ... | GemfileLock | ... ]""" +class Json: + """Original type: output_format = [ ... | Json | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'GemfileLock_' + return 'Json' @staticmethod def to_json() -> Any: - return 'GemfileLock' + return 'Json' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class GoMod2: - """Original type: lockfile_kind = [ ... | GoMod | ... ]""" +class Emacs: + """Original type: output_format = [ ... | Emacs | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'GoMod2' + return 'Emacs' @staticmethod def to_json() -> Any: - return 'GoMod' + return 'Emacs' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class CargoLock: - """Original type: lockfile_kind = [ ... | CargoLock | ... ]""" +class Vim: + """Original type: output_format = [ ... | Vim | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'CargoLock' + return 'Vim' @staticmethod def to_json() -> Any: - return 'CargoLock' + return 'Vim' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class MavenDepTree: - """Original type: lockfile_kind = [ ... | MavenDepTree | ... ]""" +class Sarif: + """Original type: output_format = [ ... | Sarif | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'MavenDepTree' + return 'Sarif' @staticmethod def to_json() -> Any: - return 'MavenDepTree' + return 'Sarif' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class GradleLockfile_: - """Original type: lockfile_kind = [ ... | GradleLockfile | ... ]""" +class GitlabSast: + """Original type: output_format = [ ... | Gitlab_sast | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'GradleLockfile_' + return 'GitlabSast' @staticmethod def to_json() -> Any: - return 'GradleLockfile' + return 'Gitlab_sast' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class ComposerLock_: - """Original type: lockfile_kind = [ ... | ComposerLock | ... ]""" +class GitlabSecrets: + """Original type: output_format = [ ... | Gitlab_secrets | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'ComposerLock_' + return 'GitlabSecrets' @staticmethod def to_json() -> Any: - return 'ComposerLock' + return 'Gitlab_secrets' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class NugetPackagesLockJson: - """Original type: lockfile_kind = [ ... | NugetPackagesLockJson | ... ]""" +class JunitXml: + """Original type: output_format = [ ... | Junit_xml | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'NugetPackagesLockJson' + return 'JunitXml' @staticmethod def to_json() -> Any: - return 'NugetPackagesLockJson' + return 'Junit_xml' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class PubspecLock_: - """Original type: lockfile_kind = [ ... | PubspecLock | ... ]""" +class FilesWithMatches: + """Original type: output_format = [ ... | Files_with_matches | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'PubspecLock_' + return 'FilesWithMatches' @staticmethod def to_json() -> Any: - return 'PubspecLock' + return 'Files_with_matches' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class SwiftPackageResolved: - """Original type: lockfile_kind = [ ... | SwiftPackageResolved | ... ]""" +class Incremental: + """Original type: output_format = [ ... | Incremental | ... ]""" @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'SwiftPackageResolved' + return 'Incremental' @staticmethod def to_json() -> Any: - return 'SwiftPackageResolved' + return 'Incremental' def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) @dataclass(frozen=True) -class MixLock_: - """Original type: lockfile_kind = [ ... | MixLock | ... ]""" +class OutputFormat: + """Original type: output_format = [ ... ]""" + + value: Union[Text, Json, Emacs, Vim, Sarif, GitlabSast, GitlabSecrets, JunitXml, FilesWithMatches, Incremental] @property def kind(self) -> str: """Name of the class representing this variant.""" - return 'MixLock_' + return self.value.kind - @staticmethod - def to_json() -> Any: - return 'MixLock' + @classmethod + def from_json(cls, x: Any) -> 'OutputFormat': + if isinstance(x, str): + if x == 'Text': + return cls(Text()) + if x == 'Json': + return cls(Json()) + if x == 'Emacs': + return cls(Emacs()) + if x == 'Vim': + return cls(Vim()) + if x == 'Sarif': + return cls(Sarif()) + if x == 'Gitlab_sast': + return cls(GitlabSast()) + if x == 'Gitlab_secrets': + return cls(GitlabSecrets()) + if x == 'Junit_xml': + return cls(JunitXml()) + if x == 'Files_with_matches': + return cls(FilesWithMatches()) + if x == 'Incremental': + return cls(Incremental()) + _atd_bad_json('OutputFormat', x) + _atd_bad_json('OutputFormat', x) + + def to_json(self) -> Any: + return self.value.to_json() + + @classmethod + def from_json_string(cls, x: str) -> 'OutputFormat': + 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 LockfileKind: - """Original type: lockfile_kind = [ ... ]""" - - value: Union[PipRequirementsTxt, PoetryLock_, PipfileLock, NpmPackageLockJson, YarnLock, PnpmLock_, GemfileLock_, GoMod2, CargoLock, MavenDepTree, GradleLockfile_, ComposerLock_, NugetPackagesLockJson, PubspecLock_, SwiftPackageResolved, MixLock_] +class Manifest: + """Original type: manifest = { ... }""" - @property - def kind(self) -> str: - """Name of the class representing this variant.""" - return self.value.kind + kind: ManifestKind + path: Fpath @classmethod - def from_json(cls, x: Any) -> 'LockfileKind': - if isinstance(x, str): - if x == 'PipRequirementsTxt': - return cls(PipRequirementsTxt()) - if x == 'PoetryLock': - return cls(PoetryLock_()) - if x == 'PipfileLock': - return cls(PipfileLock()) - if x == 'NpmPackageLockJson': - return cls(NpmPackageLockJson()) - if x == 'YarnLock': - return cls(YarnLock()) - if x == 'PnpmLock': - return cls(PnpmLock_()) - if x == 'GemfileLock': - return cls(GemfileLock_()) - if x == 'GoMod': - return cls(GoMod2()) - if x == 'CargoLock': - return cls(CargoLock()) - if x == 'MavenDepTree': - return cls(MavenDepTree()) - if x == 'GradleLockfile': - return cls(GradleLockfile_()) - if x == 'ComposerLock': - return cls(ComposerLock_()) - if x == 'NugetPackagesLockJson': - return cls(NugetPackagesLockJson()) - if x == 'PubspecLock': - return cls(PubspecLock_()) - if x == 'SwiftPackageResolved': - return cls(SwiftPackageResolved()) - if x == 'MixLock': - return cls(MixLock_()) - _atd_bad_json('LockfileKind', x) - _atd_bad_json('LockfileKind', x) + def from_json(cls, x: Any) -> 'Manifest': + if isinstance(x, dict): + return cls( + kind=ManifestKind.from_json(x['kind']) if 'kind' in x else _atd_missing_json_field('Manifest', 'kind'), + path=Fpath.from_json(x['path']) if 'path' in x else _atd_missing_json_field('Manifest', 'path'), + ) + else: + _atd_bad_json('Manifest', x) def to_json(self) -> Any: - return self.value.to_json() + res: Dict[str, Any] = {} + res['kind'] = (lambda x: x.to_json())(self.kind) + res['path'] = (lambda x: x.to_json())(self.path) + return res @classmethod - def from_json_string(cls, x: str) -> 'LockfileKind': + def from_json_string(cls, x: str) -> 'Manifest': return cls.from_json(json.loads(x)) def to_json_string(self, **kw: Any) -> str: diff --git a/semgrep_output_v1.ts b/semgrep_output_v1.ts index 5520207..02773dc 100644 --- a/semgrep_output_v1.ts +++ b/semgrep_output_v1.ts @@ -763,6 +763,36 @@ export type CiScanCompleteStats = { parse_rate: Map; engine_requested?: string; findings_by_product?: Map; + supply_chain_stats?: SupplyChainStats; +} + +export type ResolutionMethod = +| { kind: 'LockfileParsing' } +| { kind: 'DynamicResolution' } + +export type DependencyResolutionStats = { + resolution_method: ResolutionMethod; + dependency_count: number /*int*/; + ecosystem: Ecosystem; +} + +export type DependencySourceFileKind = +| { kind: 'Lockfile'; value: LockfileKind } +| { kind: 'Manifest'; value: ManifestKind } + +export type DependencySourceFile = { + kind: DependencySourceFileKind; + path: Fpath; +} + +export type SubprojectStats = { + subproject_id: string; + dependency_sources: DependencySourceFile[]; + resolved_stats?: DependencyResolutionStats; +} + +export type SupplyChainStats = { + subprojects_stats: SubprojectStats[]; } export type ParsingStats = { @@ -3239,6 +3269,7 @@ export function writeCiScanCompleteStats(x: CiScanCompleteStats, context: any = 'parse_rate': _atd_write_required_field('CiScanCompleteStats', 'parse_rate', _atd_write_assoc_map_to_object(writeParsingStats), x.parse_rate, x), 'engine_requested': _atd_write_optional_field(_atd_write_string, x.engine_requested, x), 'findings_by_product': _atd_write_optional_field(_atd_write_assoc_map_to_object(_atd_write_int), x.findings_by_product, x), + 'supply_chain_stats': _atd_write_optional_field(writeSupplyChainStats, x.supply_chain_stats, x), }; } @@ -3252,6 +3283,108 @@ export function readCiScanCompleteStats(x: any, context: any = x): CiScanComplet parse_rate: _atd_read_required_field('CiScanCompleteStats', 'parse_rate', _atd_read_assoc_object_into_map(readParsingStats), x['parse_rate'], x), engine_requested: _atd_read_optional_field(_atd_read_string, x['engine_requested'], x), findings_by_product: _atd_read_optional_field(_atd_read_assoc_object_into_map(_atd_read_int), x['findings_by_product'], x), + supply_chain_stats: _atd_read_optional_field(readSupplyChainStats, x['supply_chain_stats'], x), + }; +} + +export function writeResolutionMethod(x: ResolutionMethod, context: any = x): any { + switch (x.kind) { + case 'LockfileParsing': + return 'LockfileParsing' + case 'DynamicResolution': + return 'DynamicResolution' + } +} + +export function readResolutionMethod(x: any, context: any = x): ResolutionMethod { + switch (x) { + case 'LockfileParsing': + return { kind: 'LockfileParsing' } + case 'DynamicResolution': + return { kind: 'DynamicResolution' } + default: + _atd_bad_json('ResolutionMethod', x, context) + throw new Error('impossible') + } +} + +export function writeDependencyResolutionStats(x: DependencyResolutionStats, context: any = x): any { + return { + 'resolution_method': _atd_write_required_field('DependencyResolutionStats', 'resolution_method', writeResolutionMethod, x.resolution_method, x), + 'dependency_count': _atd_write_required_field('DependencyResolutionStats', 'dependency_count', _atd_write_int, x.dependency_count, x), + 'ecosystem': _atd_write_required_field('DependencyResolutionStats', 'ecosystem', writeEcosystem, x.ecosystem, x), + }; +} + +export function readDependencyResolutionStats(x: any, context: any = x): DependencyResolutionStats { + return { + resolution_method: _atd_read_required_field('DependencyResolutionStats', 'resolution_method', readResolutionMethod, x['resolution_method'], x), + dependency_count: _atd_read_required_field('DependencyResolutionStats', 'dependency_count', _atd_read_int, x['dependency_count'], x), + ecosystem: _atd_read_required_field('DependencyResolutionStats', 'ecosystem', readEcosystem, x['ecosystem'], x), + }; +} + +export function writeDependencySourceFileKind(x: DependencySourceFileKind, context: any = x): any { + switch (x.kind) { + case 'Lockfile': + return ['Lockfile', writeLockfileKind(x.value, x)] + case 'Manifest': + return ['Manifest', writeManifestKind(x.value, x)] + } +} + +export function readDependencySourceFileKind(x: any, context: any = x): DependencySourceFileKind { + _atd_check_json_tuple(2, x, context) + switch (x[0]) { + case 'Lockfile': + return { kind: 'Lockfile', value: readLockfileKind(x[1], x) } + case 'Manifest': + return { kind: 'Manifest', value: readManifestKind(x[1], x) } + default: + _atd_bad_json('DependencySourceFileKind', x, context) + throw new Error('impossible') + } +} + +export function writeDependencySourceFile(x: DependencySourceFile, context: any = x): any { + return { + 'kind': _atd_write_required_field('DependencySourceFile', 'kind', writeDependencySourceFileKind, x.kind, x), + 'path': _atd_write_required_field('DependencySourceFile', 'path', writeFpath, x.path, x), + }; +} + +export function readDependencySourceFile(x: any, context: any = x): DependencySourceFile { + return { + kind: _atd_read_required_field('DependencySourceFile', 'kind', readDependencySourceFileKind, x['kind'], x), + path: _atd_read_required_field('DependencySourceFile', 'path', readFpath, x['path'], x), + }; +} + +export function writeSubprojectStats(x: SubprojectStats, context: any = x): any { + return { + 'subproject_id': _atd_write_required_field('SubprojectStats', 'subproject_id', _atd_write_string, x.subproject_id, x), + 'dependency_sources': _atd_write_required_field('SubprojectStats', 'dependency_sources', _atd_write_array(writeDependencySourceFile), x.dependency_sources, x), + 'resolved_stats': _atd_write_optional_field(writeDependencyResolutionStats, x.resolved_stats, x), + }; +} + +export function readSubprojectStats(x: any, context: any = x): SubprojectStats { + return { + subproject_id: _atd_read_required_field('SubprojectStats', 'subproject_id', _atd_read_string, x['subproject_id'], x), + dependency_sources: _atd_read_required_field('SubprojectStats', 'dependency_sources', _atd_read_array(readDependencySourceFile), x['dependency_sources'], x), + resolved_stats: _atd_read_optional_field(readDependencyResolutionStats, x['resolved_stats'], x), + }; +} + +export function writeSupplyChainStats(x: SupplyChainStats, context: any = x): any { + return { + 'subprojects_stats': _atd_write_required_field('SupplyChainStats', 'subprojects_stats', _atd_write_array(writeSubprojectStats), x.subprojects_stats, x), + }; +} + +export function readSupplyChainStats(x: any, context: any = x): SupplyChainStats { + return { + subprojects_stats: _atd_read_required_field('SupplyChainStats', 'subprojects_stats', _atd_read_array(readSubprojectStats), x['subprojects_stats'], x), }; } diff --git a/semgrep_output_v1_j.ml b/semgrep_output_v1_j.ml index cbaa99b..d8cf672 100644 --- a/semgrep_output_v1_j.ml +++ b/semgrep_output_v1_j.ml @@ -226,6 +226,48 @@ type target_times = Semgrep_output_v1_t.target_times = { type tag = Semgrep_output_v1_t.tag +type resolution_method = Semgrep_output_v1_t.resolution_method + [@@deriving show] + +type manifest_kind = Semgrep_output_v1_t.manifest_kind + [@@deriving show, eq, yojson] + +type lockfile_kind = Semgrep_output_v1_t.lockfile_kind = + PipRequirementsTxt | PoetryLock | PipfileLock | NpmPackageLockJson + | YarnLock | PnpmLock | GemfileLock | GoMod | CargoLock | MavenDepTree + | GradleLockfile | ComposerLock | NugetPackagesLockJson | PubspecLock + | SwiftPackageResolved | MixLock + + [@@deriving show, eq, yojson] + +type ecosystem = Semgrep_output_v1_t.ecosystem [@@deriving show,eq] + +type dependency_source_file_kind = + Semgrep_output_v1_t.dependency_source_file_kind + [@@deriving show] + +type dependency_source_file = Semgrep_output_v1_t.dependency_source_file = { + kind: dependency_source_file_kind; + path: fpath +} + +type dependency_resolution_stats = + Semgrep_output_v1_t.dependency_resolution_stats = { + resolution_method: resolution_method; + dependency_count: int; + ecosystem: ecosystem +} + +type subproject_stats = Semgrep_output_v1_t.subproject_stats = { + subproject_id: string; + dependency_sources: dependency_source_file list; + resolved_stats: dependency_resolution_stats option +} + +type supply_chain_stats = Semgrep_output_v1_t.supply_chain_stats = { + subprojects_stats: subproject_stats list +} + type skip_reason = Semgrep_output_v1_t.skip_reason = Always_skipped | Semgrepignore_patterns_match | Cli_include_flags_do_not_match | Cli_exclude_flags_match @@ -388,8 +430,6 @@ type scan_config = Semgrep_output_v1_t.scan_config = { type sca_parser_name = Semgrep_output_v1_t.sca_parser_name -type ecosystem = Semgrep_output_v1_t.ecosystem [@@deriving show,eq] - type dependency_child = Semgrep_output_v1_t.dependency_child = { package: string; version: string @@ -644,7 +684,8 @@ type ci_scan_complete_stats = Semgrep_output_v1_t.ci_scan_complete_stats = { lockfile_scan_info: (string * int) list; parse_rate: (string * parsing_stats) list; engine_requested: string option; - findings_by_product: (string * int) list option + findings_by_product: (string * int) list option; + supply_chain_stats: supply_chain_stats option } type ci_scan_complete = Semgrep_output_v1_t.ci_scan_complete = { @@ -664,23 +705,12 @@ type output_format = Semgrep_output_v1_t.output_format = [@@deriving show] -type manifest_kind = Semgrep_output_v1_t.manifest_kind - [@@deriving show, eq, yojson] - type manifest = Semgrep_output_v1_t.manifest = { kind: manifest_kind; path: fpath } [@@deriving show, eq] -type lockfile_kind = Semgrep_output_v1_t.lockfile_kind = - PipRequirementsTxt | PoetryLock | PipfileLock | NpmPackageLockJson - | YarnLock | PnpmLock | GemfileLock | GoMod | CargoLock | MavenDepTree - | GradleLockfile | ComposerLock | NugetPackagesLockJson | PubspecLock - | SwiftPackageResolved | MixLock - - [@@deriving show, eq, yojson] - type lockfile = Semgrep_output_v1_t.lockfile = { kind: lockfile_kind; path: fpath @@ -8545,144 +8575,174 @@ let read_tag = ( ) let tag_of_string s = read_tag (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_skip_reason : _ -> skip_reason -> _ = ( - fun ob (x : skip_reason) -> +let write_resolution_method = ( + fun ob x -> match x with - | Always_skipped -> Buffer.add_string ob "\"always_skipped\"" - | Semgrepignore_patterns_match -> Buffer.add_string ob "\"semgrepignore_patterns_match\"" - | Cli_include_flags_do_not_match -> Buffer.add_string ob "\"cli_include_flags_do_not_match\"" - | Cli_exclude_flags_match -> Buffer.add_string ob "\"cli_exclude_flags_match\"" - | Exceeded_size_limit -> Buffer.add_string ob "\"exceeded_size_limit\"" - | Analysis_failed_parser_or_internal_error -> Buffer.add_string ob "\"analysis_failed_parser_or_internal_error\"" - | Excluded_by_config -> Buffer.add_string ob "\"excluded_by_config\"" - | Wrong_language -> Buffer.add_string ob "\"wrong_language\"" - | Too_big -> Buffer.add_string ob "\"too_big\"" - | Minified -> Buffer.add_string ob "\"minified\"" - | Binary -> Buffer.add_string ob "\"binary\"" - | Irrelevant_rule -> Buffer.add_string ob "\"irrelevant_rule\"" - | Too_many_matches -> Buffer.add_string ob "\"too_many_matches\"" - | Gitignore_patterns_match -> Buffer.add_string ob "\"Gitignore_patterns_match\"" - | Dotfile -> Buffer.add_string ob "\"Dotfile\"" - | Nonexistent_file -> Buffer.add_string ob "\"Nonexistent_file\"" - | Insufficient_permissions -> Buffer.add_string ob "\"insufficient_permissions\"" + | `LockfileParsing -> Buffer.add_string ob "\"LockfileParsing\"" + | `DynamicResolution -> Buffer.add_string ob "\"DynamicResolution\"" ) -let string_of_skip_reason ?(len = 1024) x = +let string_of_resolution_method ?(len = 1024) x = let ob = Buffer.create len in - write_skip_reason ob x; + write_resolution_method ob x; Buffer.contents ob -let read_skip_reason = ( +let read_resolution_method = ( 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 - | "always_skipped" -> + | "LockfileParsing" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (Always_skipped : skip_reason) - | "semgrepignore_patterns_match" -> + `LockfileParsing + | "DynamicResolution" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (Semgrepignore_patterns_match : skip_reason) - | "cli_include_flags_do_not_match" -> + `DynamicResolution + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Double_quote -> ( + match Yojson.Safe.finish_string p lb with + | "LockfileParsing" -> + `LockfileParsing + | "DynamicResolution" -> + `DynamicResolution + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Square_bracket -> ( + match Atdgen_runtime.Oj_run.read_string p lb with + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) +) +let resolution_method_of_string s = + read_resolution_method (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_manifest_kind = ( + fun ob x -> + match x with + | `RequirementsIn -> Buffer.add_string ob "\"RequirementsIn\"" + | `PackageJson -> Buffer.add_string ob "\"PackageJson\"" + | `Gemfile -> Buffer.add_string ob "\"Gemfile\"" + | `GoMod -> Buffer.add_string ob "\"GoMod\"" + | `CargoToml -> Buffer.add_string ob "\"CargoToml\"" + | `PomXml -> Buffer.add_string ob "\"PomXml\"" + | `BuildGradle -> Buffer.add_string ob "\"BuildGradle\"" + | `SettingsGradle -> Buffer.add_string ob "\"SettingsGradle\"" + | `ComposerJson -> Buffer.add_string ob "\"ComposerJson\"" + | `NugetManifestJson -> Buffer.add_string ob "\"NugetManifestJson\"" + | `PubspecYaml -> Buffer.add_string ob "\"PubspecYaml\"" + | `PackageSwift -> Buffer.add_string ob "\"PackageSwift\"" + | `MixExs -> Buffer.add_string ob "\"MixExs\"" + | `Pipfile -> Buffer.add_string ob "\"Pipfile\"" + | `PyprojectToml -> Buffer.add_string ob "\"PyprojectToml\"" +) +let string_of_manifest_kind ?(len = 1024) x = + let ob = Buffer.create len in + write_manifest_kind ob x; + Buffer.contents ob +let read_manifest_kind = ( + fun p lb -> + Yojson.Safe.read_space p lb; + match Yojson.Safe.start_any_variant p lb with + | `Edgy_bracket -> ( + match Yojson.Safe.read_ident p lb with + | "RequirementsIn" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (Cli_include_flags_do_not_match : skip_reason) - | "cli_exclude_flags_match" -> + `RequirementsIn + | "PackageJson" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (Cli_exclude_flags_match : skip_reason) - | "exceeded_size_limit" -> + `PackageJson + | "Gemfile" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (Exceeded_size_limit : skip_reason) - | "analysis_failed_parser_or_internal_error" -> + `Gemfile + | "GoMod" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (Analysis_failed_parser_or_internal_error : skip_reason) - | "excluded_by_config" -> + `GoMod + | "CargoToml" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (Excluded_by_config : skip_reason) - | "wrong_language" -> + `CargoToml + | "PomXml" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (Wrong_language : skip_reason) - | "too_big" -> + `PomXml + | "BuildGradle" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (Too_big : skip_reason) - | "minified" -> + `BuildGradle + | "SettingsGradle" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (Minified : skip_reason) - | "binary" -> + `SettingsGradle + | "ComposerJson" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (Binary : skip_reason) - | "irrelevant_rule" -> + `ComposerJson + | "NugetManifestJson" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (Irrelevant_rule : skip_reason) - | "too_many_matches" -> + `NugetManifestJson + | "PubspecYaml" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (Too_many_matches : skip_reason) - | "Gitignore_patterns_match" -> + `PubspecYaml + | "PackageSwift" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (Gitignore_patterns_match : skip_reason) - | "Dotfile" -> + `PackageSwift + | "MixExs" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (Dotfile : skip_reason) - | "Nonexistent_file" -> + `MixExs + | "Pipfile" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (Nonexistent_file : skip_reason) - | "insufficient_permissions" -> + `Pipfile + | "PyprojectToml" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - (Insufficient_permissions : skip_reason) + `PyprojectToml | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Double_quote -> ( match Yojson.Safe.finish_string p lb with - | "always_skipped" -> - (Always_skipped : skip_reason) - | "semgrepignore_patterns_match" -> - (Semgrepignore_patterns_match : skip_reason) - | "cli_include_flags_do_not_match" -> - (Cli_include_flags_do_not_match : skip_reason) - | "cli_exclude_flags_match" -> - (Cli_exclude_flags_match : skip_reason) - | "exceeded_size_limit" -> - (Exceeded_size_limit : skip_reason) - | "analysis_failed_parser_or_internal_error" -> - (Analysis_failed_parser_or_internal_error : skip_reason) - | "excluded_by_config" -> - (Excluded_by_config : skip_reason) - | "wrong_language" -> - (Wrong_language : skip_reason) - | "too_big" -> - (Too_big : skip_reason) - | "minified" -> - (Minified : skip_reason) - | "binary" -> - (Binary : skip_reason) - | "irrelevant_rule" -> - (Irrelevant_rule : skip_reason) - | "too_many_matches" -> - (Too_many_matches : skip_reason) - | "Gitignore_patterns_match" -> - (Gitignore_patterns_match : skip_reason) - | "Dotfile" -> - (Dotfile : skip_reason) - | "Nonexistent_file" -> - (Nonexistent_file : skip_reason) - | "insufficient_permissions" -> - (Insufficient_permissions : skip_reason) + | "RequirementsIn" -> + `RequirementsIn + | "PackageJson" -> + `PackageJson + | "Gemfile" -> + `Gemfile + | "GoMod" -> + `GoMod + | "CargoToml" -> + `CargoToml + | "PomXml" -> + `PomXml + | "BuildGradle" -> + `BuildGradle + | "SettingsGradle" -> + `SettingsGradle + | "ComposerJson" -> + `ComposerJson + | "NugetManifestJson" -> + `NugetManifestJson + | "PubspecYaml" -> + `PubspecYaml + | "PackageSwift" -> + `PackageSwift + | "MixExs" -> + `MixExs + | "Pipfile" -> + `Pipfile + | "PyprojectToml" -> + `PyprojectToml | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) @@ -8692,29 +8752,1264 @@ let read_skip_reason = ( Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) -let skip_reason_of_string s = - read_skip_reason (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__rule_id_option = ( - Atdgen_runtime.Oj_run.write_std_option ( - write_rule_id - ) -) -let string_of__rule_id_option ?(len = 1024) x = - let ob = Buffer.create len in - write__rule_id_option ob x; - Buffer.contents ob -let read__rule_id_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 manifest_kind_of_string s = + read_manifest_kind (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_lockfile_kind : _ -> lockfile_kind -> _ = ( + fun ob (x : lockfile_kind) -> + match x with + | PipRequirementsTxt -> Buffer.add_string ob "\"PipRequirementsTxt\"" + | PoetryLock -> Buffer.add_string ob "\"PoetryLock\"" + | PipfileLock -> Buffer.add_string ob "\"PipfileLock\"" + | NpmPackageLockJson -> Buffer.add_string ob "\"NpmPackageLockJson\"" + | YarnLock -> Buffer.add_string ob "\"YarnLock\"" + | PnpmLock -> Buffer.add_string ob "\"PnpmLock\"" + | GemfileLock -> Buffer.add_string ob "\"GemfileLock\"" + | GoMod -> Buffer.add_string ob "\"GoMod\"" + | CargoLock -> Buffer.add_string ob "\"CargoLock\"" + | MavenDepTree -> Buffer.add_string ob "\"MavenDepTree\"" + | GradleLockfile -> Buffer.add_string ob "\"GradleLockfile\"" + | ComposerLock -> Buffer.add_string ob "\"ComposerLock\"" + | NugetPackagesLockJson -> Buffer.add_string ob "\"NugetPackagesLockJson\"" + | PubspecLock -> Buffer.add_string ob "\"PubspecLock\"" + | SwiftPackageResolved -> Buffer.add_string ob "\"SwiftPackageResolved\"" + | MixLock -> Buffer.add_string ob "\"MixLock\"" +) +let string_of_lockfile_kind ?(len = 1024) x = + let ob = Buffer.create len in + write_lockfile_kind ob x; + Buffer.contents ob +let read_lockfile_kind = ( + fun p lb -> + Yojson.Safe.read_space p lb; + match Yojson.Safe.start_any_variant p lb with + | `Edgy_bracket -> ( + match Yojson.Safe.read_ident p lb with + | "PipRequirementsTxt" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (PipRequirementsTxt : lockfile_kind) + | "PoetryLock" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (PoetryLock : lockfile_kind) + | "PipfileLock" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (PipfileLock : lockfile_kind) + | "NpmPackageLockJson" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (NpmPackageLockJson : lockfile_kind) + | "YarnLock" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (YarnLock : lockfile_kind) + | "PnpmLock" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (PnpmLock : lockfile_kind) + | "GemfileLock" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (GemfileLock : lockfile_kind) + | "GoMod" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (GoMod : lockfile_kind) + | "CargoLock" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (CargoLock : lockfile_kind) + | "MavenDepTree" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (MavenDepTree : lockfile_kind) + | "GradleLockfile" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (GradleLockfile : lockfile_kind) + | "ComposerLock" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (ComposerLock : lockfile_kind) + | "NugetPackagesLockJson" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (NugetPackagesLockJson : lockfile_kind) + | "PubspecLock" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (PubspecLock : lockfile_kind) + | "SwiftPackageResolved" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (SwiftPackageResolved : lockfile_kind) + | "MixLock" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (MixLock : lockfile_kind) + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Double_quote -> ( + match Yojson.Safe.finish_string p lb with + | "PipRequirementsTxt" -> + (PipRequirementsTxt : lockfile_kind) + | "PoetryLock" -> + (PoetryLock : lockfile_kind) + | "PipfileLock" -> + (PipfileLock : lockfile_kind) + | "NpmPackageLockJson" -> + (NpmPackageLockJson : lockfile_kind) + | "YarnLock" -> + (YarnLock : lockfile_kind) + | "PnpmLock" -> + (PnpmLock : lockfile_kind) + | "GemfileLock" -> + (GemfileLock : lockfile_kind) + | "GoMod" -> + (GoMod : lockfile_kind) + | "CargoLock" -> + (CargoLock : lockfile_kind) + | "MavenDepTree" -> + (MavenDepTree : lockfile_kind) + | "GradleLockfile" -> + (GradleLockfile : lockfile_kind) + | "ComposerLock" -> + (ComposerLock : lockfile_kind) + | "NugetPackagesLockJson" -> + (NugetPackagesLockJson : lockfile_kind) + | "PubspecLock" -> + (PubspecLock : lockfile_kind) + | "SwiftPackageResolved" -> + (SwiftPackageResolved : lockfile_kind) + | "MixLock" -> + (MixLock : lockfile_kind) + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Square_bracket -> ( + match Atdgen_runtime.Oj_run.read_string p lb with + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) +) +let lockfile_kind_of_string s = + read_lockfile_kind (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_ecosystem = ( + fun ob x -> + match x with + | `Npm -> Buffer.add_string ob "\"npm\"" + | `Pypi -> Buffer.add_string ob "\"pypi\"" + | `Gem -> Buffer.add_string ob "\"gem\"" + | `Gomod -> Buffer.add_string ob "\"gomod\"" + | `Cargo -> Buffer.add_string ob "\"cargo\"" + | `Maven -> Buffer.add_string ob "\"maven\"" + | `Composer -> Buffer.add_string ob "\"composer\"" + | `Nuget -> Buffer.add_string ob "\"nuget\"" + | `Pub -> Buffer.add_string ob "\"pub\"" + | `SwiftPM -> Buffer.add_string ob "\"swiftpm\"" + | `Mix -> Buffer.add_string ob "\"mix\"" + | `Hex -> Buffer.add_string ob "\"hex\"" +) +let string_of_ecosystem ?(len = 1024) x = + let ob = Buffer.create len in + write_ecosystem ob x; + Buffer.contents ob +let read_ecosystem = ( + 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 + | "npm" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Npm + | "pypi" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Pypi + | "gem" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Gem + | "gomod" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Gomod + | "cargo" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Cargo + | "maven" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Maven + | "composer" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Composer + | "nuget" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Nuget + | "pub" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Pub + | "swiftpm" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `SwiftPM + | "mix" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Mix + | "hex" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Hex + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Double_quote -> ( + match Yojson.Safe.finish_string p lb with + | "npm" -> + `Npm + | "pypi" -> + `Pypi + | "gem" -> + `Gem + | "gomod" -> + `Gomod + | "cargo" -> + `Cargo + | "maven" -> + `Maven + | "composer" -> + `Composer + | "nuget" -> + `Nuget + | "pub" -> + `Pub + | "swiftpm" -> + `SwiftPM + | "mix" -> + `Mix + | "hex" -> + `Hex + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Square_bracket -> ( + match Atdgen_runtime.Oj_run.read_string p lb with + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) +) +let ecosystem_of_string s = + read_ecosystem (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_dependency_source_file_kind = ( + fun ob x -> + match x with + | `Lockfile x -> + Buffer.add_string ob "[\"Lockfile\","; + ( + write_lockfile_kind + ) ob x; + Buffer.add_char ob ']' + | `Manifest x -> + Buffer.add_string ob "[\"Manifest\","; + ( + write_manifest_kind + ) ob x; + Buffer.add_char ob ']' +) +let string_of_dependency_source_file_kind ?(len = 1024) x = + let ob = Buffer.create len in + write_dependency_source_file_kind ob x; + Buffer.contents ob +let read_dependency_source_file_kind = ( + fun p lb -> + Yojson.Safe.read_space p lb; + match Yojson.Safe.start_any_variant p lb with + | `Edgy_bracket -> ( + match Yojson.Safe.read_ident p lb with + | "Lockfile" -> + Atdgen_runtime.Oj_run.read_until_field_value p lb; + let x = ( + read_lockfile_kind + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Lockfile x + | "Manifest" -> + Atdgen_runtime.Oj_run.read_until_field_value p lb; + let x = ( + read_manifest_kind + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + `Manifest 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 + | "Lockfile" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; + let x = ( + read_lockfile_kind + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_rbr p lb; + `Lockfile x + | "Manifest" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_comma p lb; + Yojson.Safe.read_space p lb; + let x = ( + read_manifest_kind + ) p lb + in + Yojson.Safe.read_space p lb; + Yojson.Safe.read_rbr p lb; + `Manifest x + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) +) +let dependency_source_file_kind_of_string s = + read_dependency_source_file_kind (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_dependency_source_file : _ -> dependency_source_file -> _ = ( + fun ob (x : dependency_source_file) -> + 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 "\"kind\":"; + ( + write_dependency_source_file_kind + ) + ob x.kind; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"path\":"; + ( + write_fpath + ) + ob x.path; + Buffer.add_char ob '}'; +) +let string_of_dependency_source_file ?(len = 1024) x = + let ob = Buffer.create len in + write_dependency_source_file ob x; + Buffer.contents ob +let read_dependency_source_file = ( + fun p lb -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_lcurl p lb; + let field_kind = ref (None) in + let field_path = 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); + if len = 4 then ( + match String.unsafe_get s pos with + | 'k' -> ( + if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'd' then ( + 0 + ) + else ( + -1 + ) + ) + | 'p' -> ( + if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' then ( + 1 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + else ( + -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_kind := ( + Some ( + ( + read_dependency_source_file_kind + ) p lb + ) + ); + | 1 -> + field_path := ( + Some ( + ( + read_fpath + ) 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); + if len = 4 then ( + match String.unsafe_get s pos with + | 'k' -> ( + if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'd' then ( + 0 + ) + else ( + -1 + ) + ) + | 'p' -> ( + if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' then ( + 1 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + ) + else ( + -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_kind := ( + Some ( + ( + read_dependency_source_file_kind + ) p lb + ) + ); + | 1 -> + field_path := ( + Some ( + ( + read_fpath + ) p lb + ) + ); + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + done; + assert false; + with Yojson.End_of_object -> ( + ( + { + kind = (match !field_kind with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "kind"); + path = (match !field_path with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "path"); + } + : dependency_source_file) + ) +) +let dependency_source_file_of_string s = + read_dependency_source_file (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_dependency_resolution_stats : _ -> dependency_resolution_stats -> _ = ( + fun ob (x : dependency_resolution_stats) -> + Buffer.add_char ob '{'; + let is_first = ref true in + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"resolution_method\":"; + ( + write_resolution_method + ) + ob x.resolution_method; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"dependency_count\":"; + ( + Yojson.Safe.write_int + ) + ob x.dependency_count; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"ecosystem\":"; + ( + write_ecosystem + ) + ob x.ecosystem; + Buffer.add_char ob '}'; +) +let string_of_dependency_resolution_stats ?(len = 1024) x = + let ob = Buffer.create len in + write_dependency_resolution_stats ob x; + Buffer.contents ob +let read_dependency_resolution_stats = ( + fun p lb -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_lcurl p lb; + let field_resolution_method = ref (None) in + let field_dependency_count = ref (None) in + let field_ecosystem = ref (None) in + try + Yojson.Safe.read_space p lb; + Yojson.Safe.read_object_end lb; + Yojson.Safe.read_space p lb; + let f = + fun s pos len -> + if pos < 0 || len < 0 || pos + len > String.length s then + invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); + match len with + | 9 -> ( + if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'c' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 'y' && String.unsafe_get s (pos+5) = 's' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'm' then ( + 2 + ) + else ( + -1 + ) + ) + | 16 -> ( + if String.unsafe_get s pos = 'd' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'c' && String.unsafe_get s (pos+9) = 'y' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'c' && String.unsafe_get s (pos+12) = 'o' && String.unsafe_get s (pos+13) = 'u' && String.unsafe_get s (pos+14) = 'n' && String.unsafe_get s (pos+15) = 't' then ( + 1 + ) + else ( + -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) = 'o' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'u' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'm' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 't' && String.unsafe_get s (pos+14) = 'h' && String.unsafe_get s (pos+15) = 'o' && String.unsafe_get s (pos+16) = 'd' then ( + 0 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + in + let i = Yojson.Safe.map_ident p f lb in + Atdgen_runtime.Oj_run.read_until_field_value p lb; + ( + match i with + | 0 -> + field_resolution_method := ( + Some ( + ( + read_resolution_method + ) p lb + ) + ); + | 1 -> + field_dependency_count := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 2 -> + field_ecosystem := ( + Some ( + ( + read_ecosystem + ) p lb + ) + ); + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + while true do + Yojson.Safe.read_space p lb; + Yojson.Safe.read_object_sep p lb; + Yojson.Safe.read_space p lb; + let f = + fun s pos len -> + if pos < 0 || len < 0 || pos + len > String.length s then + invalid_arg (Printf.sprintf "out-of-bounds substring position or length: string = %S, requested position = %i, requested length = %i" s pos len); + match len with + | 9 -> ( + if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'c' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 'y' && String.unsafe_get s (pos+5) = 's' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'm' then ( + 2 + ) + else ( + -1 + ) + ) + | 16 -> ( + if String.unsafe_get s pos = 'd' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'c' && String.unsafe_get s (pos+9) = 'y' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'c' && String.unsafe_get s (pos+12) = 'o' && String.unsafe_get s (pos+13) = 'u' && String.unsafe_get s (pos+14) = 'n' && String.unsafe_get s (pos+15) = 't' then ( + 1 + ) + else ( + -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) = 'o' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'u' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'm' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 't' && String.unsafe_get s (pos+14) = 'h' && String.unsafe_get s (pos+15) = 'o' && String.unsafe_get s (pos+16) = 'd' then ( + 0 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) + in + let i = Yojson.Safe.map_ident p f lb in + Atdgen_runtime.Oj_run.read_until_field_value p lb; + ( + match i with + | 0 -> + field_resolution_method := ( + Some ( + ( + read_resolution_method + ) p lb + ) + ); + | 1 -> + field_dependency_count := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ) + ); + | 2 -> + field_ecosystem := ( + Some ( + ( + read_ecosystem + ) p lb + ) + ); + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + done; + assert false; + with Yojson.End_of_object -> ( + ( + { + resolution_method = (match !field_resolution_method with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "resolution_method"); + dependency_count = (match !field_dependency_count with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "dependency_count"); + ecosystem = (match !field_ecosystem with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "ecosystem"); + } + : dependency_resolution_stats) + ) +) +let dependency_resolution_stats_of_string s = + read_dependency_resolution_stats (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__dependency_source_file_list = ( + Atdgen_runtime.Oj_run.write_list ( + write_dependency_source_file + ) +) +let string_of__dependency_source_file_list ?(len = 1024) x = + let ob = Buffer.create len in + write__dependency_source_file_list ob x; + Buffer.contents ob +let read__dependency_source_file_list = ( + Atdgen_runtime.Oj_run.read_list ( + read_dependency_source_file + ) +) +let _dependency_source_file_list_of_string s = + read__dependency_source_file_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__dependency_resolution_stats_option = ( + Atdgen_runtime.Oj_run.write_std_option ( + write_dependency_resolution_stats + ) +) +let string_of__dependency_resolution_stats_option ?(len = 1024) x = + let ob = Buffer.create len in + write__dependency_resolution_stats_option ob x; + Buffer.contents ob +let read__dependency_resolution_stats_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_dependency_resolution_stats + ) 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_dependency_resolution_stats + ) 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 _dependency_resolution_stats_option_of_string s = + read__dependency_resolution_stats_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_subproject_stats : _ -> subproject_stats -> _ = ( + fun ob (x : subproject_stats) -> + Buffer.add_char ob '{'; + let is_first = ref true in + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"subproject_id\":"; + ( + Yojson.Safe.write_string + ) + ob x.subproject_id; + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"dependency_sources\":"; + ( + write__dependency_source_file_list + ) + ob x.dependency_sources; + (match x.resolved_stats with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"resolved_stats\":"; + ( + write_dependency_resolution_stats + ) + ob x; + ); + Buffer.add_char ob '}'; +) +let string_of_subproject_stats ?(len = 1024) x = + let ob = Buffer.create len in + write_subproject_stats ob x; + Buffer.contents ob +let read_subproject_stats = ( + fun p lb -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_lcurl p lb; + let field_subproject_id = ref (None) in + let field_dependency_sources = ref (None) in + let field_resolved_stats = 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 + | 13 -> ( + if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'b' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'j' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'c' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'i' && String.unsafe_get s (pos+12) = 'd' then ( + 0 + ) + else ( + -1 + ) + ) + | 14 -> ( + 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) = 'o' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'v' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'd' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 't' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 's' then ( + 2 + ) + else ( + -1 + ) + ) + | 18 -> ( + if String.unsafe_get s pos = 'd' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'c' && String.unsafe_get s (pos+9) = 'y' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 'o' && String.unsafe_get s (pos+13) = 'u' && String.unsafe_get s (pos+14) = 'r' && String.unsafe_get s (pos+15) = 'c' && String.unsafe_get s (pos+16) = 'e' && String.unsafe_get s (pos+17) = 's' 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_subproject_id := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + | 1 -> + field_dependency_sources := ( + Some ( + ( + read__dependency_source_file_list + ) p lb + ) + ); + | 2 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_resolved_stats := ( + Some ( + ( + read_dependency_resolution_stats + ) 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 + | 13 -> ( + if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'b' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'j' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'c' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'i' && String.unsafe_get s (pos+12) = 'd' then ( + 0 + ) + else ( + -1 + ) + ) + | 14 -> ( + 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) = 'o' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'v' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'd' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 't' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 's' then ( + 2 + ) + else ( + -1 + ) + ) + | 18 -> ( + if String.unsafe_get s pos = 'd' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'c' && String.unsafe_get s (pos+9) = 'y' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 'o' && String.unsafe_get s (pos+13) = 'u' && String.unsafe_get s (pos+14) = 'r' && String.unsafe_get s (pos+15) = 'c' && String.unsafe_get s (pos+16) = 'e' && String.unsafe_get s (pos+17) = 's' 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_subproject_id := ( + Some ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ) + ); + | 1 -> + field_dependency_sources := ( + Some ( + ( + read__dependency_source_file_list + ) p lb + ) + ); + | 2 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_resolved_stats := ( + Some ( + ( + read_dependency_resolution_stats + ) p lb + ) + ); + ) + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + done; + assert false; + with Yojson.End_of_object -> ( + ( + { + subproject_id = (match !field_subproject_id with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "subproject_id"); + dependency_sources = (match !field_dependency_sources with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "dependency_sources"); + resolved_stats = !field_resolved_stats; + } + : subproject_stats) + ) +) +let subproject_stats_of_string s = + read_subproject_stats (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__subproject_stats_list = ( + Atdgen_runtime.Oj_run.write_list ( + write_subproject_stats + ) +) +let string_of__subproject_stats_list ?(len = 1024) x = + let ob = Buffer.create len in + write__subproject_stats_list ob x; + Buffer.contents ob +let read__subproject_stats_list = ( + Atdgen_runtime.Oj_run.read_list ( + read_subproject_stats + ) +) +let _subproject_stats_list_of_string s = + read__subproject_stats_list (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_supply_chain_stats : _ -> supply_chain_stats -> _ = ( + fun ob (x : supply_chain_stats) -> + Buffer.add_char ob '{'; + let is_first = ref true in + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"subprojects_stats\":"; + ( + write__subproject_stats_list + ) + ob x.subprojects_stats; + Buffer.add_char ob '}'; +) +let string_of_supply_chain_stats ?(len = 1024) x = + let ob = Buffer.create len in + write_supply_chain_stats ob x; + Buffer.contents ob +let read_supply_chain_stats = ( + fun p lb -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_lcurl p lb; + let field_subprojects_stats = 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); + if len = 17 && String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'b' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'j' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'c' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 's' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 's' && String.unsafe_get s (pos+13) = 't' && String.unsafe_get s (pos+14) = 'a' && String.unsafe_get s (pos+15) = 't' && String.unsafe_get s (pos+16) = 's' then ( + 0 + ) + else ( + -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_subprojects_stats := ( + Some ( + ( + read__subproject_stats_list + ) 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); + if len = 17 && String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'b' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'j' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'c' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 's' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 's' && String.unsafe_get s (pos+13) = 't' && String.unsafe_get s (pos+14) = 'a' && String.unsafe_get s (pos+15) = 't' && String.unsafe_get s (pos+16) = 's' then ( + 0 + ) + else ( + -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_subprojects_stats := ( + Some ( + ( + read__subproject_stats_list + ) p lb + ) + ); + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + done; + assert false; + with Yojson.End_of_object -> ( + ( + { + subprojects_stats = (match !field_subprojects_stats with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "subprojects_stats"); + } + : supply_chain_stats) + ) +) +let supply_chain_stats_of_string s = + read_supply_chain_stats (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_skip_reason : _ -> skip_reason -> _ = ( + fun ob (x : skip_reason) -> + match x with + | Always_skipped -> Buffer.add_string ob "\"always_skipped\"" + | Semgrepignore_patterns_match -> Buffer.add_string ob "\"semgrepignore_patterns_match\"" + | Cli_include_flags_do_not_match -> Buffer.add_string ob "\"cli_include_flags_do_not_match\"" + | Cli_exclude_flags_match -> Buffer.add_string ob "\"cli_exclude_flags_match\"" + | Exceeded_size_limit -> Buffer.add_string ob "\"exceeded_size_limit\"" + | Analysis_failed_parser_or_internal_error -> Buffer.add_string ob "\"analysis_failed_parser_or_internal_error\"" + | Excluded_by_config -> Buffer.add_string ob "\"excluded_by_config\"" + | Wrong_language -> Buffer.add_string ob "\"wrong_language\"" + | Too_big -> Buffer.add_string ob "\"too_big\"" + | Minified -> Buffer.add_string ob "\"minified\"" + | Binary -> Buffer.add_string ob "\"binary\"" + | Irrelevant_rule -> Buffer.add_string ob "\"irrelevant_rule\"" + | Too_many_matches -> Buffer.add_string ob "\"too_many_matches\"" + | Gitignore_patterns_match -> Buffer.add_string ob "\"Gitignore_patterns_match\"" + | Dotfile -> Buffer.add_string ob "\"Dotfile\"" + | Nonexistent_file -> Buffer.add_string ob "\"Nonexistent_file\"" + | Insufficient_permissions -> Buffer.add_string ob "\"insufficient_permissions\"" +) +let string_of_skip_reason ?(len = 1024) x = + let ob = Buffer.create len in + write_skip_reason ob x; + Buffer.contents ob +let read_skip_reason = ( + 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 + | "always_skipped" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Always_skipped : skip_reason) + | "semgrepignore_patterns_match" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Semgrepignore_patterns_match : skip_reason) + | "cli_include_flags_do_not_match" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Cli_include_flags_do_not_match : skip_reason) + | "cli_exclude_flags_match" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Cli_exclude_flags_match : skip_reason) + | "exceeded_size_limit" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Exceeded_size_limit : skip_reason) + | "analysis_failed_parser_or_internal_error" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Analysis_failed_parser_or_internal_error : skip_reason) + | "excluded_by_config" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Excluded_by_config : skip_reason) + | "wrong_language" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Wrong_language : skip_reason) + | "too_big" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Too_big : skip_reason) + | "minified" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Minified : skip_reason) + | "binary" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Binary : skip_reason) + | "irrelevant_rule" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Irrelevant_rule : skip_reason) + | "too_many_matches" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Too_many_matches : skip_reason) + | "Gitignore_patterns_match" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Gitignore_patterns_match : skip_reason) + | "Dotfile" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Dotfile : skip_reason) + | "Nonexistent_file" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Nonexistent_file : skip_reason) + | "insufficient_permissions" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Insufficient_permissions : skip_reason) + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Double_quote -> ( + match Yojson.Safe.finish_string p lb with + | "always_skipped" -> + (Always_skipped : skip_reason) + | "semgrepignore_patterns_match" -> + (Semgrepignore_patterns_match : skip_reason) + | "cli_include_flags_do_not_match" -> + (Cli_include_flags_do_not_match : skip_reason) + | "cli_exclude_flags_match" -> + (Cli_exclude_flags_match : skip_reason) + | "exceeded_size_limit" -> + (Exceeded_size_limit : skip_reason) + | "analysis_failed_parser_or_internal_error" -> + (Analysis_failed_parser_or_internal_error : skip_reason) + | "excluded_by_config" -> + (Excluded_by_config : skip_reason) + | "wrong_language" -> + (Wrong_language : skip_reason) + | "too_big" -> + (Too_big : skip_reason) + | "minified" -> + (Minified : skip_reason) + | "binary" -> + (Binary : skip_reason) + | "irrelevant_rule" -> + (Irrelevant_rule : skip_reason) + | "too_many_matches" -> + (Too_many_matches : skip_reason) + | "Gitignore_patterns_match" -> + (Gitignore_patterns_match : skip_reason) + | "Dotfile" -> + (Dotfile : skip_reason) + | "Nonexistent_file" -> + (Nonexistent_file : skip_reason) + | "insufficient_permissions" -> + (Insufficient_permissions : skip_reason) + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) + | `Square_bracket -> ( + match Atdgen_runtime.Oj_run.read_string p lb with + | x -> + Atdgen_runtime.Oj_run.invalid_variant_tag p x + ) +) +let skip_reason_of_string s = + read_skip_reason (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__rule_id_option = ( + Atdgen_runtime.Oj_run.write_std_option ( + write_rule_id + ) +) +let string_of__rule_id_option ?(len = 1024) x = + let ob = Buffer.create len in + write__rule_id_option ob x; + Buffer.contents ob +let read__rule_id_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_rule_id ) p lb @@ -15597,135 +16892,21 @@ let read_sca_parser_name = ( | "yarn_1" -> `Yarn_1 | "yarn_2" -> - `Yarn_2 - | "pomtree" -> - `Pomtree - | "cargo" -> - `Cargo_parser - | "composer_lock" -> - `Composer_lock - | "pubspec_lock" -> - `Pubspec_lock - | "package_swift" -> - `Package_swift - | "package_resolved" -> - `Package_resolved - | "mix_lock" -> - `Mix_lock - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let sca_parser_name_of_string s = - read_sca_parser_name (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_ecosystem = ( - fun ob x -> - match x with - | `Npm -> Buffer.add_string ob "\"npm\"" - | `Pypi -> Buffer.add_string ob "\"pypi\"" - | `Gem -> Buffer.add_string ob "\"gem\"" - | `Gomod -> Buffer.add_string ob "\"gomod\"" - | `Cargo -> Buffer.add_string ob "\"cargo\"" - | `Maven -> Buffer.add_string ob "\"maven\"" - | `Composer -> Buffer.add_string ob "\"composer\"" - | `Nuget -> Buffer.add_string ob "\"nuget\"" - | `Pub -> Buffer.add_string ob "\"pub\"" - | `SwiftPM -> Buffer.add_string ob "\"swiftpm\"" - | `Mix -> Buffer.add_string ob "\"mix\"" - | `Hex -> Buffer.add_string ob "\"hex\"" -) -let string_of_ecosystem ?(len = 1024) x = - let ob = Buffer.create len in - write_ecosystem ob x; - Buffer.contents ob -let read_ecosystem = ( - 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 - | "npm" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `Npm - | "pypi" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `Pypi - | "gem" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `Gem - | "gomod" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `Gomod - | "cargo" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `Cargo - | "maven" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `Maven - | "composer" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `Composer - | "nuget" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `Nuget - | "pub" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `Pub - | "swiftpm" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `SwiftPM - | "mix" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `Mix - | "hex" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `Hex - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "npm" -> - `Npm - | "pypi" -> - `Pypi - | "gem" -> - `Gem - | "gomod" -> - `Gomod + `Yarn_2 + | "pomtree" -> + `Pomtree | "cargo" -> - `Cargo - | "maven" -> - `Maven - | "composer" -> - `Composer - | "nuget" -> - `Nuget - | "pub" -> - `Pub - | "swiftpm" -> - `SwiftPM - | "mix" -> - `Mix - | "hex" -> - `Hex + `Cargo_parser + | "composer_lock" -> + `Composer_lock + | "pubspec_lock" -> + `Pubspec_lock + | "package_swift" -> + `Package_swift + | "package_resolved" -> + `Package_resolved + | "mix_lock" -> + `Mix_lock | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) @@ -15735,8 +16916,8 @@ let read_ecosystem = ( Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) -let ecosystem_of_string s = - read_ecosystem (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let sca_parser_name_of_string s = + read_sca_parser_name (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_dependency_child : _ -> dependency_child -> _ = ( fun ob (x : dependency_child) -> Buffer.add_char ob '{'; @@ -25458,6 +26639,63 @@ let read__x_122e274 = ( ) let _x_122e274_of_string s = read__x_122e274 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write__supply_chain_stats_option = ( + Atdgen_runtime.Oj_run.write_std_option ( + write_supply_chain_stats + ) +) +let string_of__supply_chain_stats_option ?(len = 1024) x = + let ob = Buffer.create len in + write__supply_chain_stats_option ob x; + Buffer.contents ob +let read__supply_chain_stats_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_supply_chain_stats + ) 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_supply_chain_stats + ) 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 _supply_chain_stats_option_of_string s = + read__supply_chain_stats_option (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_ci_scan_complete_stats : _ -> ci_scan_complete_stats -> _ = ( fun ob (x : ci_scan_complete_stats) -> Buffer.add_char ob '{'; @@ -25538,6 +26776,17 @@ let write_ci_scan_complete_stats : _ -> ci_scan_complete_stats -> _ = ( ) ob x; ); + (match x.supply_chain_stats with None -> () | Some x -> + if !is_first then + is_first := false + else + Buffer.add_char ob ','; + Buffer.add_string ob "\"supply_chain_stats\":"; + ( + write_supply_chain_stats + ) + ob x; + ); Buffer.add_char ob '}'; ) let string_of_ci_scan_complete_stats ?(len = 1024) x = @@ -25556,6 +26805,7 @@ let read_ci_scan_complete_stats = ( let field_parse_rate = ref (None) in let field_engine_requested = ref (None) in let field_findings_by_product = ref (None) in + let field_supply_chain_stats = ref (None) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; @@ -25626,12 +26876,26 @@ let read_ci_scan_complete_stats = ( ) ) | 18 -> ( - if String.unsafe_get s pos = 'l' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'c' && String.unsafe_get s (pos+3) = 'k' && String.unsafe_get s (pos+4) = 'f' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'c' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 'n' && String.unsafe_get s (pos+13) = '_' && String.unsafe_get s (pos+14) = 'i' && String.unsafe_get s (pos+15) = 'n' && String.unsafe_get s (pos+16) = 'f' && String.unsafe_get s (pos+17) = 'o' then ( - 4 - ) - else ( - -1 - ) + match String.unsafe_get s pos with + | 'l' -> ( + if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'c' && String.unsafe_get s (pos+3) = 'k' && String.unsafe_get s (pos+4) = 'f' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'c' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 'n' && String.unsafe_get s (pos+13) = '_' && String.unsafe_get s (pos+14) = 'i' && String.unsafe_get s (pos+15) = 'n' && String.unsafe_get s (pos+16) = 'f' && String.unsafe_get s (pos+17) = 'o' then ( + 4 + ) + else ( + -1 + ) + ) + | 's' -> ( + if String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'h' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 'i' && String.unsafe_get s (pos+11) = 'n' && String.unsafe_get s (pos+12) = '_' && String.unsafe_get s (pos+13) = 's' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'a' && String.unsafe_get s (pos+16) = 't' && String.unsafe_get s (pos+17) = 's' then ( + 8 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) ) | 19 -> ( if String.unsafe_get s pos = 'f' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'd' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'g' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 'b' && String.unsafe_get s (pos+10) = 'y' && 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) = 'd' && String.unsafe_get s (pos+16) = 'u' && String.unsafe_get s (pos+17) = 'c' && String.unsafe_get s (pos+18) = 't' then ( @@ -25717,6 +26981,16 @@ let read_ci_scan_complete_stats = ( ) ); ) + | 8 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_supply_chain_stats := ( + Some ( + ( + read_supply_chain_stats + ) p lb + ) + ); + ) | _ -> ( Yojson.Safe.skip_json p lb ) @@ -25791,12 +27065,26 @@ let read_ci_scan_complete_stats = ( ) ) | 18 -> ( - if String.unsafe_get s pos = 'l' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'c' && String.unsafe_get s (pos+3) = 'k' && String.unsafe_get s (pos+4) = 'f' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'c' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 'n' && String.unsafe_get s (pos+13) = '_' && String.unsafe_get s (pos+14) = 'i' && String.unsafe_get s (pos+15) = 'n' && String.unsafe_get s (pos+16) = 'f' && String.unsafe_get s (pos+17) = 'o' then ( - 4 - ) - else ( - -1 - ) + match String.unsafe_get s pos with + | 'l' -> ( + if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'c' && String.unsafe_get s (pos+3) = 'k' && String.unsafe_get s (pos+4) = 'f' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 's' && String.unsafe_get s (pos+10) = 'c' && String.unsafe_get s (pos+11) = 'a' && String.unsafe_get s (pos+12) = 'n' && String.unsafe_get s (pos+13) = '_' && String.unsafe_get s (pos+14) = 'i' && String.unsafe_get s (pos+15) = 'n' && String.unsafe_get s (pos+16) = 'f' && String.unsafe_get s (pos+17) = 'o' then ( + 4 + ) + else ( + -1 + ) + ) + | 's' -> ( + if String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'p' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'y' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'h' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 'i' && String.unsafe_get s (pos+11) = 'n' && String.unsafe_get s (pos+12) = '_' && String.unsafe_get s (pos+13) = 's' && String.unsafe_get s (pos+14) = 't' && String.unsafe_get s (pos+15) = 'a' && String.unsafe_get s (pos+16) = 't' && String.unsafe_get s (pos+17) = 's' then ( + 8 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) ) | 19 -> ( if String.unsafe_get s pos = 'f' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'd' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'g' && String.unsafe_get s (pos+7) = 's' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 'b' && String.unsafe_get s (pos+10) = 'y' && 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) = 'd' && String.unsafe_get s (pos+16) = 'u' && String.unsafe_get s (pos+17) = 'c' && String.unsafe_get s (pos+18) = 't' then ( @@ -25882,6 +27170,16 @@ let read_ci_scan_complete_stats = ( ) ); ) + | 8 -> + if not (Yojson.Safe.read_null_if_possible p lb) then ( + field_supply_chain_stats := ( + Some ( + ( + read_supply_chain_stats + ) p lb + ) + ); + ) | _ -> ( Yojson.Safe.skip_json p lb ) @@ -25899,6 +27197,7 @@ let read_ci_scan_complete_stats = ( parse_rate = (match !field_parse_rate with Some x -> x | None -> Atdgen_runtime.Oj_run.missing_field p "parse_rate"); engine_requested = !field_engine_requested; findings_by_product = !field_findings_by_product; + supply_chain_stats = !field_supply_chain_stats; } : ci_scan_complete_stats) ) @@ -26528,206 +27827,71 @@ let read_output_format = ( match Yojson.Safe.start_any_variant p lb with | `Edgy_bracket -> ( match Yojson.Safe.read_ident p lb with - | "Text" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Text : output_format) - | "Json" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Json : output_format) - | "Emacs" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Emacs : output_format) - | "Vim" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Vim : output_format) - | "Sarif" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Sarif : output_format) - | "Gitlab_sast" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Gitlab_sast : output_format) - | "Gitlab_secrets" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Gitlab_secrets : output_format) - | "Junit_xml" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Junit_xml : output_format) - | "Files_with_matches" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Files_with_matches : output_format) - | "Incremental" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Incremental : output_format) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "Text" -> - (Text : output_format) - | "Json" -> - (Json : output_format) - | "Emacs" -> - (Emacs : output_format) - | "Vim" -> - (Vim : output_format) - | "Sarif" -> - (Sarif : output_format) - | "Gitlab_sast" -> - (Gitlab_sast : output_format) - | "Gitlab_secrets" -> - (Gitlab_secrets : output_format) - | "Junit_xml" -> - (Junit_xml : output_format) - | "Files_with_matches" -> - (Files_with_matches : output_format) - | "Incremental" -> - (Incremental : output_format) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let output_format_of_string s = - read_output_format (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_manifest_kind = ( - fun ob x -> - match x with - | `RequirementsIn -> Buffer.add_string ob "\"RequirementsIn\"" - | `PackageJson -> Buffer.add_string ob "\"PackageJson\"" - | `Gemfile -> Buffer.add_string ob "\"Gemfile\"" - | `GoMod -> Buffer.add_string ob "\"GoMod\"" - | `CargoToml -> Buffer.add_string ob "\"CargoToml\"" - | `PomXml -> Buffer.add_string ob "\"PomXml\"" - | `BuildGradle -> Buffer.add_string ob "\"BuildGradle\"" - | `SettingsGradle -> Buffer.add_string ob "\"SettingsGradle\"" - | `ComposerJson -> Buffer.add_string ob "\"ComposerJson\"" - | `NugetManifestJson -> Buffer.add_string ob "\"NugetManifestJson\"" - | `PubspecYaml -> Buffer.add_string ob "\"PubspecYaml\"" - | `PackageSwift -> Buffer.add_string ob "\"PackageSwift\"" - | `MixExs -> Buffer.add_string ob "\"MixExs\"" - | `Pipfile -> Buffer.add_string ob "\"Pipfile\"" - | `PyprojectToml -> Buffer.add_string ob "\"PyprojectToml\"" -) -let string_of_manifest_kind ?(len = 1024) x = - let ob = Buffer.create len in - write_manifest_kind ob x; - Buffer.contents ob -let read_manifest_kind = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "RequirementsIn" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `RequirementsIn - | "PackageJson" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `PackageJson - | "Gemfile" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `Gemfile - | "GoMod" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `GoMod - | "CargoToml" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - `CargoToml - | "PomXml" -> + | "Text" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - `PomXml - | "BuildGradle" -> + (Text : output_format) + | "Json" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - `BuildGradle - | "SettingsGradle" -> + (Json : output_format) + | "Emacs" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - `SettingsGradle - | "ComposerJson" -> + (Emacs : output_format) + | "Vim" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - `ComposerJson - | "NugetManifestJson" -> + (Vim : output_format) + | "Sarif" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - `NugetManifestJson - | "PubspecYaml" -> + (Sarif : output_format) + | "Gitlab_sast" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - `PubspecYaml - | "PackageSwift" -> + (Gitlab_sast : output_format) + | "Gitlab_secrets" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - `PackageSwift - | "MixExs" -> + (Gitlab_secrets : output_format) + | "Junit_xml" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - `MixExs - | "Pipfile" -> + (Junit_xml : output_format) + | "Files_with_matches" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - `Pipfile - | "PyprojectToml" -> + (Files_with_matches : output_format) + | "Incremental" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; - `PyprojectToml + (Incremental : output_format) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Double_quote -> ( match Yojson.Safe.finish_string p lb with - | "RequirementsIn" -> - `RequirementsIn - | "PackageJson" -> - `PackageJson - | "Gemfile" -> - `Gemfile - | "GoMod" -> - `GoMod - | "CargoToml" -> - `CargoToml - | "PomXml" -> - `PomXml - | "BuildGradle" -> - `BuildGradle - | "SettingsGradle" -> - `SettingsGradle - | "ComposerJson" -> - `ComposerJson - | "NugetManifestJson" -> - `NugetManifestJson - | "PubspecYaml" -> - `PubspecYaml - | "PackageSwift" -> - `PackageSwift - | "MixExs" -> - `MixExs - | "Pipfile" -> - `Pipfile - | "PyprojectToml" -> - `PyprojectToml + | "Text" -> + (Text : output_format) + | "Json" -> + (Json : output_format) + | "Emacs" -> + (Emacs : output_format) + | "Vim" -> + (Vim : output_format) + | "Sarif" -> + (Sarif : output_format) + | "Gitlab_sast" -> + (Gitlab_sast : output_format) + | "Gitlab_secrets" -> + (Gitlab_secrets : output_format) + | "Junit_xml" -> + (Junit_xml : output_format) + | "Files_with_matches" -> + (Files_with_matches : output_format) + | "Incremental" -> + (Incremental : output_format) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) @@ -26737,8 +27901,8 @@ let read_manifest_kind = ( Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) -let manifest_kind_of_string s = - read_manifest_kind (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let output_format_of_string s = + read_output_format (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_manifest : _ -> manifest -> _ = ( fun ob (x : manifest) -> Buffer.add_char ob '{'; @@ -26902,148 +28066,6 @@ let read_manifest = ( ) let manifest_of_string s = read_manifest (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_lockfile_kind : _ -> lockfile_kind -> _ = ( - fun ob (x : lockfile_kind) -> - match x with - | PipRequirementsTxt -> Buffer.add_string ob "\"PipRequirementsTxt\"" - | PoetryLock -> Buffer.add_string ob "\"PoetryLock\"" - | PipfileLock -> Buffer.add_string ob "\"PipfileLock\"" - | NpmPackageLockJson -> Buffer.add_string ob "\"NpmPackageLockJson\"" - | YarnLock -> Buffer.add_string ob "\"YarnLock\"" - | PnpmLock -> Buffer.add_string ob "\"PnpmLock\"" - | GemfileLock -> Buffer.add_string ob "\"GemfileLock\"" - | GoMod -> Buffer.add_string ob "\"GoMod\"" - | CargoLock -> Buffer.add_string ob "\"CargoLock\"" - | MavenDepTree -> Buffer.add_string ob "\"MavenDepTree\"" - | GradleLockfile -> Buffer.add_string ob "\"GradleLockfile\"" - | ComposerLock -> Buffer.add_string ob "\"ComposerLock\"" - | NugetPackagesLockJson -> Buffer.add_string ob "\"NugetPackagesLockJson\"" - | PubspecLock -> Buffer.add_string ob "\"PubspecLock\"" - | SwiftPackageResolved -> Buffer.add_string ob "\"SwiftPackageResolved\"" - | MixLock -> Buffer.add_string ob "\"MixLock\"" -) -let string_of_lockfile_kind ?(len = 1024) x = - let ob = Buffer.create len in - write_lockfile_kind ob x; - Buffer.contents ob -let read_lockfile_kind = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "PipRequirementsTxt" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (PipRequirementsTxt : lockfile_kind) - | "PoetryLock" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (PoetryLock : lockfile_kind) - | "PipfileLock" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (PipfileLock : lockfile_kind) - | "NpmPackageLockJson" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (NpmPackageLockJson : lockfile_kind) - | "YarnLock" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (YarnLock : lockfile_kind) - | "PnpmLock" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (PnpmLock : lockfile_kind) - | "GemfileLock" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (GemfileLock : lockfile_kind) - | "GoMod" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (GoMod : lockfile_kind) - | "CargoLock" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (CargoLock : lockfile_kind) - | "MavenDepTree" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (MavenDepTree : lockfile_kind) - | "GradleLockfile" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (GradleLockfile : lockfile_kind) - | "ComposerLock" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (ComposerLock : lockfile_kind) - | "NugetPackagesLockJson" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (NugetPackagesLockJson : lockfile_kind) - | "PubspecLock" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (PubspecLock : lockfile_kind) - | "SwiftPackageResolved" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (SwiftPackageResolved : lockfile_kind) - | "MixLock" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (MixLock : lockfile_kind) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "PipRequirementsTxt" -> - (PipRequirementsTxt : lockfile_kind) - | "PoetryLock" -> - (PoetryLock : lockfile_kind) - | "PipfileLock" -> - (PipfileLock : lockfile_kind) - | "NpmPackageLockJson" -> - (NpmPackageLockJson : lockfile_kind) - | "YarnLock" -> - (YarnLock : lockfile_kind) - | "PnpmLock" -> - (PnpmLock : lockfile_kind) - | "GemfileLock" -> - (GemfileLock : lockfile_kind) - | "GoMod" -> - (GoMod : lockfile_kind) - | "CargoLock" -> - (CargoLock : lockfile_kind) - | "MavenDepTree" -> - (MavenDepTree : lockfile_kind) - | "GradleLockfile" -> - (GradleLockfile : lockfile_kind) - | "ComposerLock" -> - (ComposerLock : lockfile_kind) - | "NugetPackagesLockJson" -> - (NugetPackagesLockJson : lockfile_kind) - | "PubspecLock" -> - (PubspecLock : lockfile_kind) - | "SwiftPackageResolved" -> - (SwiftPackageResolved : lockfile_kind) - | "MixLock" -> - (MixLock : lockfile_kind) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let lockfile_kind_of_string s = - read_lockfile_kind (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_lockfile : _ -> lockfile -> _ = ( fun ob (x : lockfile) -> Buffer.add_char ob '{'; diff --git a/semgrep_output_v1_j.mli b/semgrep_output_v1_j.mli index 94be4dd..3adda60 100644 --- a/semgrep_output_v1_j.mli +++ b/semgrep_output_v1_j.mli @@ -226,6 +226,48 @@ type target_times = Semgrep_output_v1_t.target_times = { type tag = Semgrep_output_v1_t.tag +type resolution_method = Semgrep_output_v1_t.resolution_method + [@@deriving show] + +type manifest_kind = Semgrep_output_v1_t.manifest_kind + [@@deriving show, eq, yojson] + +type lockfile_kind = Semgrep_output_v1_t.lockfile_kind = + PipRequirementsTxt | PoetryLock | PipfileLock | NpmPackageLockJson + | YarnLock | PnpmLock | GemfileLock | GoMod | CargoLock | MavenDepTree + | GradleLockfile | ComposerLock | NugetPackagesLockJson | PubspecLock + | SwiftPackageResolved | MixLock + + [@@deriving show, eq, yojson] + +type ecosystem = Semgrep_output_v1_t.ecosystem [@@deriving show,eq] + +type dependency_source_file_kind = + Semgrep_output_v1_t.dependency_source_file_kind + [@@deriving show] + +type dependency_source_file = Semgrep_output_v1_t.dependency_source_file = { + kind: dependency_source_file_kind; + path: fpath +} + +type dependency_resolution_stats = + Semgrep_output_v1_t.dependency_resolution_stats = { + resolution_method: resolution_method; + dependency_count: int; + ecosystem: ecosystem +} + +type subproject_stats = Semgrep_output_v1_t.subproject_stats = { + subproject_id: string; + dependency_sources: dependency_source_file list; + resolved_stats: dependency_resolution_stats option +} + +type supply_chain_stats = Semgrep_output_v1_t.supply_chain_stats = { + subprojects_stats: subproject_stats list +} + type skip_reason = Semgrep_output_v1_t.skip_reason = Always_skipped | Semgrepignore_patterns_match | Cli_include_flags_do_not_match | Cli_exclude_flags_match @@ -388,8 +430,6 @@ type scan_config = Semgrep_output_v1_t.scan_config = { type sca_parser_name = Semgrep_output_v1_t.sca_parser_name -type ecosystem = Semgrep_output_v1_t.ecosystem [@@deriving show,eq] - type dependency_child = Semgrep_output_v1_t.dependency_child = { package: string; version: string @@ -644,7 +684,8 @@ type ci_scan_complete_stats = Semgrep_output_v1_t.ci_scan_complete_stats = { lockfile_scan_info: (string * int) list; parse_rate: (string * parsing_stats) list; engine_requested: string option; - findings_by_product: (string * int) list option + findings_by_product: (string * int) list option; + supply_chain_stats: supply_chain_stats option } type ci_scan_complete = Semgrep_output_v1_t.ci_scan_complete = { @@ -664,23 +705,12 @@ type output_format = Semgrep_output_v1_t.output_format = [@@deriving show] -type manifest_kind = Semgrep_output_v1_t.manifest_kind - [@@deriving show, eq, yojson] - type manifest = Semgrep_output_v1_t.manifest = { kind: manifest_kind; path: fpath } [@@deriving show, eq] -type lockfile_kind = Semgrep_output_v1_t.lockfile_kind = - PipRequirementsTxt | PoetryLock | PipfileLock | NpmPackageLockJson - | YarnLock | PnpmLock | GemfileLock | GoMod | CargoLock | MavenDepTree - | GradleLockfile | ComposerLock | NugetPackagesLockJson | PubspecLock - | SwiftPackageResolved | MixLock - - [@@deriving show, eq, yojson] - type lockfile = Semgrep_output_v1_t.lockfile = { kind: lockfile_kind; path: fpath @@ -1769,6 +1799,186 @@ val tag_of_string : string -> tag (** Deserialize JSON data of type {!type:tag}. *) +val write_resolution_method : + Buffer.t -> resolution_method -> unit + (** Output a JSON value of type {!type:resolution_method}. *) + +val string_of_resolution_method : + ?len:int -> resolution_method -> string + (** Serialize a value of type {!type:resolution_method} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_resolution_method : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> resolution_method + (** Input JSON data of type {!type:resolution_method}. *) + +val resolution_method_of_string : + string -> resolution_method + (** Deserialize JSON data of type {!type:resolution_method}. *) + +val write_manifest_kind : + Buffer.t -> manifest_kind -> unit + (** Output a JSON value of type {!type:manifest_kind}. *) + +val string_of_manifest_kind : + ?len:int -> manifest_kind -> string + (** Serialize a value of type {!type:manifest_kind} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_manifest_kind : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> manifest_kind + (** Input JSON data of type {!type:manifest_kind}. *) + +val manifest_kind_of_string : + string -> manifest_kind + (** Deserialize JSON data of type {!type:manifest_kind}. *) + +val write_lockfile_kind : + Buffer.t -> lockfile_kind -> unit + (** Output a JSON value of type {!type:lockfile_kind}. *) + +val string_of_lockfile_kind : + ?len:int -> lockfile_kind -> string + (** Serialize a value of type {!type:lockfile_kind} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_lockfile_kind : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> lockfile_kind + (** Input JSON data of type {!type:lockfile_kind}. *) + +val lockfile_kind_of_string : + string -> lockfile_kind + (** Deserialize JSON data of type {!type:lockfile_kind}. *) + +val write_ecosystem : + Buffer.t -> ecosystem -> unit + (** Output a JSON value of type {!type:ecosystem}. *) + +val string_of_ecosystem : + ?len:int -> ecosystem -> string + (** Serialize a value of type {!type:ecosystem} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_ecosystem : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> ecosystem + (** Input JSON data of type {!type:ecosystem}. *) + +val ecosystem_of_string : + string -> ecosystem + (** Deserialize JSON data of type {!type:ecosystem}. *) + +val write_dependency_source_file_kind : + Buffer.t -> dependency_source_file_kind -> unit + (** Output a JSON value of type {!type:dependency_source_file_kind}. *) + +val string_of_dependency_source_file_kind : + ?len:int -> dependency_source_file_kind -> string + (** Serialize a value of type {!type:dependency_source_file_kind} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_dependency_source_file_kind : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> dependency_source_file_kind + (** Input JSON data of type {!type:dependency_source_file_kind}. *) + +val dependency_source_file_kind_of_string : + string -> dependency_source_file_kind + (** Deserialize JSON data of type {!type:dependency_source_file_kind}. *) + +val write_dependency_source_file : + Buffer.t -> dependency_source_file -> unit + (** Output a JSON value of type {!type:dependency_source_file}. *) + +val string_of_dependency_source_file : + ?len:int -> dependency_source_file -> string + (** Serialize a value of type {!type:dependency_source_file} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_dependency_source_file : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> dependency_source_file + (** Input JSON data of type {!type:dependency_source_file}. *) + +val dependency_source_file_of_string : + string -> dependency_source_file + (** Deserialize JSON data of type {!type:dependency_source_file}. *) + +val write_dependency_resolution_stats : + Buffer.t -> dependency_resolution_stats -> unit + (** Output a JSON value of type {!type:dependency_resolution_stats}. *) + +val string_of_dependency_resolution_stats : + ?len:int -> dependency_resolution_stats -> string + (** Serialize a value of type {!type:dependency_resolution_stats} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_dependency_resolution_stats : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> dependency_resolution_stats + (** Input JSON data of type {!type:dependency_resolution_stats}. *) + +val dependency_resolution_stats_of_string : + string -> dependency_resolution_stats + (** Deserialize JSON data of type {!type:dependency_resolution_stats}. *) + +val write_subproject_stats : + Buffer.t -> subproject_stats -> unit + (** Output a JSON value of type {!type:subproject_stats}. *) + +val string_of_subproject_stats : + ?len:int -> subproject_stats -> string + (** Serialize a value of type {!type:subproject_stats} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_subproject_stats : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> subproject_stats + (** Input JSON data of type {!type:subproject_stats}. *) + +val subproject_stats_of_string : + string -> subproject_stats + (** Deserialize JSON data of type {!type:subproject_stats}. *) + +val write_supply_chain_stats : + Buffer.t -> supply_chain_stats -> unit + (** Output a JSON value of type {!type:supply_chain_stats}. *) + +val string_of_supply_chain_stats : + ?len:int -> supply_chain_stats -> string + (** Serialize a value of type {!type:supply_chain_stats} + into a JSON string. + @param len specifies the initial length + of the buffer used internally. + Default: 1024. *) + +val read_supply_chain_stats : + Yojson.Safe.lexer_state -> Lexing.lexbuf -> supply_chain_stats + (** Input JSON data of type {!type:supply_chain_stats}. *) + +val supply_chain_stats_of_string : + string -> supply_chain_stats + (** Deserialize JSON data of type {!type:supply_chain_stats}. *) + val write_skip_reason : Buffer.t -> skip_reason -> unit (** Output a JSON value of type {!type:skip_reason}. *) @@ -2209,26 +2419,6 @@ val sca_parser_name_of_string : string -> sca_parser_name (** Deserialize JSON data of type {!type:sca_parser_name}. *) -val write_ecosystem : - Buffer.t -> ecosystem -> unit - (** Output a JSON value of type {!type:ecosystem}. *) - -val string_of_ecosystem : - ?len:int -> ecosystem -> string - (** Serialize a value of type {!type:ecosystem} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_ecosystem : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> ecosystem - (** Input JSON data of type {!type:ecosystem}. *) - -val ecosystem_of_string : - string -> ecosystem - (** Deserialize JSON data of type {!type:ecosystem}. *) - val write_dependency_child : Buffer.t -> dependency_child -> unit (** Output a JSON value of type {!type:dependency_child}. *) @@ -2909,26 +3099,6 @@ val output_format_of_string : string -> output_format (** Deserialize JSON data of type {!type:output_format}. *) -val write_manifest_kind : - Buffer.t -> manifest_kind -> unit - (** Output a JSON value of type {!type:manifest_kind}. *) - -val string_of_manifest_kind : - ?len:int -> manifest_kind -> string - (** Serialize a value of type {!type:manifest_kind} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_manifest_kind : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> manifest_kind - (** Input JSON data of type {!type:manifest_kind}. *) - -val manifest_kind_of_string : - string -> manifest_kind - (** Deserialize JSON data of type {!type:manifest_kind}. *) - val write_manifest : Buffer.t -> manifest -> unit (** Output a JSON value of type {!type:manifest}. *) @@ -2949,26 +3119,6 @@ val manifest_of_string : string -> manifest (** Deserialize JSON data of type {!type:manifest}. *) -val write_lockfile_kind : - Buffer.t -> lockfile_kind -> unit - (** Output a JSON value of type {!type:lockfile_kind}. *) - -val string_of_lockfile_kind : - ?len:int -> lockfile_kind -> string - (** Serialize a value of type {!type:lockfile_kind} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_lockfile_kind : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> lockfile_kind - (** Input JSON data of type {!type:lockfile_kind}. *) - -val lockfile_kind_of_string : - string -> lockfile_kind - (** Deserialize JSON data of type {!type:lockfile_kind}. *) - val write_lockfile : Buffer.t -> lockfile -> unit (** Output a JSON value of type {!type:lockfile}. *)