From c302316469f38b9fba57ae8450cb9cf514182157 Mon Sep 17 00:00:00 2001 From: Cooper Pierce Date: Tue, 8 Oct 2024 09:20:40 -0700 Subject: [PATCH] feat: also allow modules for metavariable-name (#295) Similar to `type` and `types`, extends the existing support for `module` to also allow for `modules`. - [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 --- rule_schema_v1.yaml | 14 +++++++++++--- rule_schema_v2.atd | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/rule_schema_v1.yaml b/rule_schema_v1.yaml index a660858a..66074644 100644 --- a/rule_schema_v1.yaml +++ b/rule_schema_v1.yaml @@ -659,15 +659,23 @@ $defs: title: Kind keyword type: string module: - title: Kind keyword + title: A module name type: string + modules: + title: A list of module names + type: array + items: + type: string required: - metavariable anyOf: - required: - kind - - required: - - module + - oneOf: + - required: + - module + - required: + - modules additionalProperties: false required: - semgrep-internal-metavariable-name diff --git a/rule_schema_v2.atd b/rule_schema_v2.atd index 00b1fc24..bfaa1742 100644 --- a/rule_schema_v2.atd +++ b/rule_schema_v2.atd @@ -415,6 +415,7 @@ type metavariable_cond = { ?kind: string option; (* for semgrep-internal-metavariable-name; consider renaming? for v2 *) ?module_ : string option; + ?modules: string list option; (* this covers regex:/pattern:, but also all:/any: with optional where: * CHECK: language is valid only when combined with a formula