diff --git a/semgrep_output_v1.atd b/semgrep_output_v1.atd index 392ce029..5313baae 100644 --- a/semgrep_output_v1.atd +++ b/semgrep_output_v1.atd @@ -609,9 +609,13 @@ type error_span = { (*****************************************************************************) (* A reason for skipping a target file or a pair (target, rule). - * Note that this type is also used in Report.ml hence the need - * for deriving show here. - *) + Note that this type is also used in Report.ml hence the need + for deriving show here. + + For consistency, please make sure all the JSON constructors use the + same case rules (lowercase, underscores). This is hard to fix later! + Please review your code carefully before committing to interface changes. +*) type skip_reason = [ (* Originally returned by the Python CLI *) | Always_skipped @@ -630,11 +634,13 @@ type skip_reason = [ | Irrelevant_rule | Too_many_matches (* New in osemgrep *) - | Gitignore_patterns_match + | Gitignore_patterns_match (* TODO: use JSON lowercase for consistency *) (* since 1.40.0 (dotfiles were always ignored, but not shown in the skip report *) - | Dotfile + | Dotfile (* TODO: use JSON lowercase for consistency *) (* since 1.44.0 *) - | Nonexistent_file + | Nonexistent_file (* TODO: use JSON lowercase for consistency *) + (* since 1.94.0 *) + | Insufficient_permissions ] (* coupling: ugly: with yield_json_objects() in target_manager.py *) diff --git a/semgrep_output_v1.jsonschema b/semgrep_output_v1.jsonschema index 3fe1b33b..cbf67358 100644 --- a/semgrep_output_v1.jsonschema +++ b/semgrep_output_v1.jsonschema @@ -407,7 +407,8 @@ { "const": "too_many_matches" }, { "const": "Gitignore_patterns_match" }, { "const": "Dotfile" }, - { "const": "Nonexistent_file" } + { "const": "Nonexistent_file" }, + { "const": "insufficient_permissions" } ] }, "skipped_target": { diff --git a/semgrep_output_v1.proto b/semgrep_output_v1.proto index 2691e11c..2c7a1aea 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: 4bb6682721c4e0a4f5791f7e2c8d48932b22edd16c3328d061e9f193658d6d0a +// Source file sha256 digest: 3067b8e428f3b772906ed300a8c33bd26be5afd7900741dd897a814d98f348e0 syntax = "proto3"; diff --git a/semgrep_output_v1.py b/semgrep_output_v1.py index f5200ddf..944f5799 100644 --- a/semgrep_output_v1.py +++ b/semgrep_output_v1.py @@ -2789,11 +2789,28 @@ def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) +@dataclass +class InsufficientPermissions: + """Original type: skip_reason = [ ... | Insufficient_permissions | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'InsufficientPermissions' + + @staticmethod + def to_json() -> Any: + return 'insufficient_permissions' + + 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] + value: Union[AlwaysSkipped, SemgrepignorePatternsMatch, CliIncludeFlagsDoNotMatch, CliExcludeFlagsMatch, ExceededSizeLimit, AnalysisFailedParserOrInternalError, ExcludedByConfig, WrongLanguage, TooBig, Minified, Binary, IrrelevantRule, TooManyMatches, GitignorePatternsMatch, Dotfile, NonexistentFile, InsufficientPermissions] @property def kind(self) -> str: @@ -2835,6 +2852,8 @@ def from_json(cls, x: Any) -> 'SkipReason': 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) diff --git a/semgrep_output_v1.ts b/semgrep_output_v1.ts index 9083287d..5d12dfde 100644 --- a/semgrep_output_v1.ts +++ b/semgrep_output_v1.ts @@ -251,6 +251,7 @@ export type SkipReason = | { kind: 'Gitignore_patterns_match' } | { kind: 'Dotfile' } | { kind: 'Nonexistent_file' } +| { kind: 'Insufficient_permissions' /* JSON: "insufficient_permissions" */ } export type SkippedTarget = { path: Fpath; @@ -1671,6 +1672,8 @@ export function writeSkipReason(x: SkipReason, context: any = x): any { return 'Dotfile' case 'Nonexistent_file': return 'Nonexistent_file' + case 'Insufficient_permissions': + return 'insufficient_permissions' } } @@ -1708,6 +1711,8 @@ export function readSkipReason(x: any, context: any = x): SkipReason { return { kind: 'Dotfile' } case 'Nonexistent_file': return { kind: 'Nonexistent_file' } + case 'insufficient_permissions': + return { kind: 'Insufficient_permissions' } default: _atd_bad_json('SkipReason', x, context) throw new Error('impossible') diff --git a/semgrep_output_v1_j.ml b/semgrep_output_v1_j.ml index e409bb43..ec9f5652 100644 --- a/semgrep_output_v1_j.ml +++ b/semgrep_output_v1_j.ml @@ -232,7 +232,7 @@ type skip_reason = Semgrep_output_v1_t.skip_reason = | Exceeded_size_limit | Analysis_failed_parser_or_internal_error | Excluded_by_config | Wrong_language | Too_big | Minified | Binary | Irrelevant_rule | Too_many_matches | Gitignore_patterns_match | Dotfile - | Nonexistent_file + | Nonexistent_file | Insufficient_permissions [@@deriving show] @@ -8525,6 +8525,7 @@ let write_skip_reason : _ -> skip_reason -> _ = ( | 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 @@ -8600,6 +8601,10 @@ let read_skip_reason = ( 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 ) @@ -8637,6 +8642,8 @@ let read_skip_reason = ( (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 ) diff --git a/semgrep_output_v1_j.mli b/semgrep_output_v1_j.mli index aa8cb38d..8c750d5a 100644 --- a/semgrep_output_v1_j.mli +++ b/semgrep_output_v1_j.mli @@ -232,7 +232,7 @@ type skip_reason = Semgrep_output_v1_t.skip_reason = | Exceeded_size_limit | Analysis_failed_parser_or_internal_error | Excluded_by_config | Wrong_language | Too_big | Minified | Binary | Irrelevant_rule | Too_many_matches | Gitignore_patterns_match | Dotfile - | Nonexistent_file + | Nonexistent_file | Insufficient_permissions [@@deriving show]