@@ -234,6 +234,7 @@ type options <ocaml from="Rule_options" t="t"> = abstract
234
234
*)
235
235
236
236
type formula = {
237
+ (* alt: have ?all: ... ?any: ... ?regex: ... ?pattern: ... with only one *)
237
238
f: formula_bis;
238
239
(* alt: we could instead do 'All of formula list * condition list' below
239
240
* but syntactically we also allow 'where' with pattern:, regex:, etc.
@@ -263,18 +264,34 @@ type formula_bis = [
263
264
(* TODO? Taint of taint_spec *)
264
265
]
265
266
266
- (* TODO *)
267
- type condition = raw_json
268
-
269
- type condition_TODO = [
267
+ (* Just like for formula, we're using an adapter to transform
268
+ * conditions in YAML like:
269
+ *
270
+ * where:
271
+ * - metavariable: $X
272
+ * regex: $Z
273
+ *
274
+ * which when turned into JSON gives:
275
+ *
276
+ * XXX
277
+ *
278
+ * which we must transform in an ATD-compliant:
279
+ *
280
+ * YYY
281
+ *)
282
+ type condition = [
270
283
(* either a single string or an array in JSON, that is
271
284
* {focus: "$FOO"}, but also {focus: ["$FOO", "$BAR"]}
272
285
*)
273
- | Focus of mvar list
274
- | Comparison of comparison
275
- | Metavariable of (mvar * metavariable_cond)
286
+ | Focus <json name="F"> of focus
287
+ | Comparison <json name="C"> of comparison
288
+ | Metavariable <json name="M"> of metavariable_cond
276
289
]
277
- <json adapter.ocaml="Rule_schema_v2_adapter.Where">
290
+ <json adapter.ocaml="Rule_schema_v2_adapter.Condition">
291
+
292
+ type focus = {
293
+ focus: mvar list;
294
+ }
278
295
279
296
type mvar = string
280
297
@@ -284,11 +301,21 @@ type comparison = {
284
301
~strip: bool;
285
302
}
286
303
287
- type metavariable_cond = [
288
- | Type of string
289
- (* TODO: for metavariable-regex, can also enable constant_propagation *)
290
- | Formula of formula
291
- | Analyzer of string
304
+ type metavariable_cond = {
305
+ metavariable: mvar;
306
+ (* alt: have ?type: ... ?types:... ?regex: ... *)
307
+ c: metavariable_cond_bis;
308
+ }
309
+
310
+ type metavariable_cond_bis = [
311
+ | Type <json name="type"> of string
312
+ | Types <json name="types"> of string list
313
+ (* alt: we could remove Regex as Formula itself as a Regex
314
+ * TODO: for metavariable-regex, can also enable constant_propagation
315
+ *)
316
+ | Regex <json name="regex"> of regex
317
+ | Formula <json name="F"> of formula
318
+ | Analyzer <json name="analyzer"> of string
292
319
]
293
320
294
321
(*****************************************************************************)
0 commit comments