diff --git a/semgrep_output_v1.atd b/semgrep_output_v1.atd index 4cecf313..ba017b7a 100644 --- a/semgrep_output_v1.atd +++ b/semgrep_output_v1.atd @@ -685,6 +685,7 @@ type matching_operation = [ | And | Or | Inside + | Anywhere (* XPat for eXtended pattern. Can be a spacegrep pattern, a * regexp pattern, or a proper semgrep pattern. * see semgrep-core/src/core/XPattern.ml diff --git a/semgrep_output_v1.jsonschema b/semgrep_output_v1.jsonschema index 24c24860..57903803 100644 --- a/semgrep_output_v1.jsonschema +++ b/semgrep_output_v1.jsonschema @@ -479,6 +479,7 @@ { "const": "And" }, { "const": "Or" }, { "const": "Inside" }, + { "const": "Anywhere" }, { "type": "array", "minItems": 2, diff --git a/semgrep_output_v1.proto b/semgrep_output_v1.proto index 84c0527e..3d134df8 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: 1351efaf61282cfef70c8d2a62674f6ddd029d3939abe4ab9981a24935ec81e7 +// Source file sha256 digest: caeb7ef7bba1a9fa85c84d7a3673278a490e1023c6aa636466fd1888cf4a9f44 syntax = "proto3"; diff --git a/semgrep_output_v1.py b/semgrep_output_v1.py index 017936f1..1d38940a 100644 --- a/semgrep_output_v1.py +++ b/semgrep_output_v1.py @@ -521,6 +521,23 @@ def to_json_string(self, **kw: Any) -> str: return json.dumps(self.to_json(), **kw) +@dataclass +class Anywhere: + """Original type: matching_operation = [ ... | Anywhere | ... ]""" + + @property + def kind(self) -> str: + """Name of the class representing this variant.""" + return 'Anywhere' + + @staticmethod + def to_json() -> Any: + return 'Anywhere' + + def to_json_string(self, **kw: Any) -> str: + return json.dumps(self.to_json(), **kw) + + @dataclass class XPat: """Original type: matching_operation = [ ... | XPat of ... | ... ]""" @@ -680,7 +697,7 @@ def to_json_string(self, **kw: Any) -> str: class MatchingOperation: """Original type: matching_operation = [ ... ]""" - value: Union[And, Or, Inside, XPat, Negation, Filter, Taint, TaintSource, TaintSink, TaintSanitizer, EllipsisAndStmts, ClassHeaderAndElems] + value: Union[And, Or, Inside, Anywhere, XPat, Negation, Filter, Taint, TaintSource, TaintSink, TaintSanitizer, EllipsisAndStmts, ClassHeaderAndElems] @property def kind(self) -> str: @@ -696,6 +713,8 @@ def from_json(cls, x: Any) -> 'MatchingOperation': return cls(Or()) if x == 'Inside': return cls(Inside()) + if x == 'Anywhere': + return cls(Anywhere()) if x == 'Negation': return cls(Negation()) if x == 'Taint': diff --git a/semgrep_output_v1.ts b/semgrep_output_v1.ts index 5290dd9d..cb99ab36 100644 --- a/semgrep_output_v1.ts +++ b/semgrep_output_v1.ts @@ -283,6 +283,7 @@ export type MatchingOperation = | { kind: 'And' } | { kind: 'Or' } | { kind: 'Inside' } +| { kind: 'Anywhere' } | { kind: 'XPat'; value: string } | { kind: 'Negation' } | { kind: 'Filter'; value: string } @@ -1493,6 +1494,8 @@ export function writeMatchingOperation(x: MatchingOperation, context: any = x): return 'Or' case 'Inside': return 'Inside' + case 'Anywhere': + return 'Anywhere' case 'XPat': return ['XPat', _atd_write_string(x.value, x)] case 'Negation': @@ -1523,6 +1526,8 @@ export function readMatchingOperation(x: any, context: any = x): MatchingOperati return { kind: 'Or' } case 'Inside': return { kind: 'Inside' } + case 'Anywhere': + return { kind: 'Anywhere' } case 'Negation': return { kind: 'Negation' } case 'Taint': diff --git a/semgrep_output_v1_j.ml b/semgrep_output_v1_j.ml index fe0fef2c..477711b8 100644 --- a/semgrep_output_v1_j.ml +++ b/semgrep_output_v1_j.ml @@ -12,6 +12,7 @@ type matching_operation = Semgrep_output_v1_t.matching_operation = And | Or | Inside + | Anywhere | XPat of string | Negation | Filter of string @@ -868,6 +869,7 @@ let write_matching_operation : _ -> matching_operation -> _ = ( | And -> Buffer.add_string ob "\"And\"" | Or -> Buffer.add_string ob "\"Or\"" | Inside -> Buffer.add_string ob "\"Inside\"" + | Anywhere -> Buffer.add_string ob "\"Anywhere\"" | XPat x -> Buffer.add_string ob "[\"XPat\","; ( @@ -910,6 +912,10 @@ let read_matching_operation = ( Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (Inside : matching_operation) + | "Anywhere" -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_gt p lb; + (Anywhere : matching_operation) | "XPat" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( @@ -967,6 +973,8 @@ let read_matching_operation = ( (Or : matching_operation) | "Inside" -> (Inside : matching_operation) + | "Anywhere" -> + (Anywhere : matching_operation) | "Negation" -> (Negation : matching_operation) | "Taint" -> diff --git a/semgrep_output_v1_j.mli b/semgrep_output_v1_j.mli index 35e76ffd..4c8a1fff 100644 --- a/semgrep_output_v1_j.mli +++ b/semgrep_output_v1_j.mli @@ -12,6 +12,7 @@ type matching_operation = Semgrep_output_v1_t.matching_operation = And | Or | Inside + | Anywhere | XPat of string | Negation | Filter of string