app.engine.dsl_ast module¶
AST node definitions and the field-access whitelist for the strategy DSL.
This module is pure data + small pure helpers - no I/O, no service dependencies, no async. It is imported by the validator, the interpreter, and the execution context. Keeping it dependency-free is what allows the adversarial test suite to import the whitelist directly and assert on it without spinning up the rest of the app.
Two pieces live here:
The grammar of allowed nodes:
NODE_*constants plus the operator whitelists used bycompareandarithnodes.The
FIELD_RESOLVERSmap - the only legal targets of afieldnode’spath. Anything outside this map (or thedata.<key>prefix) is rejected at validation time, not at runtime. This is what keeps a malicious tenant from writing{"type":"field","path":"__builtins__"}and getting an interpreter handler to evaluate it.
The data.* namespace is open - keys are arbitrary because callers
supply data per-event - but the resolver only snapshots scalar values
from the request payload, never live attribute lookups.
- class app.engine.dsl_ast.FieldResolution(path, kind, method=None, arg_fn=None)[source]¶
Bases:
objectHow to obtain the value of a whitelisted
field.pathat runtime.- Parameters:
path (str)
kind (str)
method (str | None)
arg_fn (Callable[[Any], Tuple[Any, ...]] | None)
- app.engine.dsl_ast.is_valid_data_path(path)[source]¶
data.<key>where<key>is[A-Za-z0-9_]+.- Parameters:
path (str)
- Return type:
bool
- app.engine.dsl_ast.is_parent_field_path(path)[source]¶
parent.points/parent.case_name- only valid in post_rules.- Parameters:
path (str)
- Return type:
bool
- app.engine.dsl_ast.is_known_field_path(path)[source]¶
Either a whitelisted analytic/static path, a parent.* path (context-restricted by validator), or a well-formed data.* key.
- Parameters:
path (str)
- Return type:
bool
- app.engine.dsl_ast.is_valid_case_name(value)[source]¶
Return whether
valueis a syntactically valid case name.A valid case name is a string matching the case-name pattern (
_CASE_NAME_RE).- Parameters:
value (Any) – Candidate value to check.
- Returns:
bool –
Trueifvalueis a well-formed case name.- Return type:
bool