mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
Indexes allow associating extra data with nodes in the AST using an array and then quickly looking up the array to fetch the extra data. - Index eidx for expressions - Index sidx for statements - Index qidx for queries. AST nodes are not cloneable. Therefore once a module is created, it is not possible to accidentally create two nodes with the same index inadvertently via clone. Also added IndexChecker in debug builds. When a module is parsed, it will assert that indexes have been constructed correctly. AST Cleanup - Make literal expressions (null, val, number, string etc) also structs to match all other expressions - Merge True and False nodes into a single Bool node. Also update dependencies. Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
179 lines
4.0 KiB
YAML
179 lines
4.0 KiB
YAML
# Copyright (c) Microsoft Corporation.
|
|
# Licensed under the MIT License.
|
|
|
|
cases:
|
|
- note: contains
|
|
rego: |
|
|
package test
|
|
import future.keywords
|
|
|
|
deny.a contains 0, "bar" in ["bar1"] if true
|
|
num_expressions: 11
|
|
num_statements: 1
|
|
num_queries: 1
|
|
policy:
|
|
- spec:
|
|
head:
|
|
set:
|
|
refr:
|
|
refdot:
|
|
refr:
|
|
var: deny
|
|
eidx: 3
|
|
field: a
|
|
eidx: 4
|
|
key:
|
|
inexpr:
|
|
key:
|
|
number: 0
|
|
eidx: 5
|
|
value:
|
|
string: bar
|
|
eidx: 6
|
|
collection:
|
|
array:
|
|
- string: bar1
|
|
eidx: 7
|
|
eidx: 8
|
|
eidx: 9
|
|
bodies:
|
|
- query:
|
|
qidx: 0
|
|
stmts:
|
|
- literal:
|
|
expr:
|
|
bool: true
|
|
eidx: 10
|
|
sidx: 0
|
|
- note: old-syntax
|
|
rego: |
|
|
package test
|
|
import future.keywords.if
|
|
|
|
# The following are not sets
|
|
x1 if true
|
|
x2 { true }
|
|
|
|
# The following are sets
|
|
y.a { true }
|
|
y["b"] { true }
|
|
|
|
# The following are not sets
|
|
z.a if { true }
|
|
z["b"] if { true }
|
|
num_expressions: 21
|
|
num_statements: 6
|
|
num_queries: 6
|
|
policy:
|
|
- spec:
|
|
head:
|
|
compr:
|
|
refr:
|
|
var: x1
|
|
eidx: 4
|
|
bodies:
|
|
- query:
|
|
qidx: 0
|
|
stmts:
|
|
- literal:
|
|
expr:
|
|
bool: true
|
|
eidx: 5
|
|
sidx: 0
|
|
- spec:
|
|
head:
|
|
compr:
|
|
refr:
|
|
var: x2
|
|
eidx: 6
|
|
bodies:
|
|
- query:
|
|
qidx: 1
|
|
stmts:
|
|
- literal:
|
|
expr:
|
|
bool: true
|
|
eidx: 7
|
|
sidx: 1
|
|
|
|
- spec:
|
|
head:
|
|
set:
|
|
refr:
|
|
refdot:
|
|
refr:
|
|
var: y
|
|
eidx: 8
|
|
field: a
|
|
eidx: 9
|
|
bodies:
|
|
- query:
|
|
qidx: 2
|
|
stmts:
|
|
- literal:
|
|
expr:
|
|
bool: true
|
|
eidx: 10
|
|
sidx: 2
|
|
|
|
- spec:
|
|
head:
|
|
set:
|
|
refr:
|
|
var: y
|
|
eidx: 11
|
|
key:
|
|
string: b
|
|
eidx: 12
|
|
bodies:
|
|
- query:
|
|
qidx: 3
|
|
stmts:
|
|
- literal:
|
|
expr:
|
|
bool: true
|
|
eidx: 13
|
|
sidx: 3
|
|
|
|
- spec:
|
|
head:
|
|
compr:
|
|
refr:
|
|
refdot:
|
|
refr:
|
|
var: z
|
|
eidx: 14
|
|
field: a
|
|
eidx: 15
|
|
bodies:
|
|
- query:
|
|
qidx: 4
|
|
stmts:
|
|
- literal:
|
|
expr:
|
|
bool: true
|
|
eidx: 16
|
|
sidx: 4
|
|
|
|
- spec:
|
|
head:
|
|
compr:
|
|
refr:
|
|
refbrack:
|
|
refr:
|
|
var: z
|
|
eidx: 17
|
|
index:
|
|
string: b
|
|
eidx: 18
|
|
eidx: 19
|
|
bodies:
|
|
- query:
|
|
qidx: 5
|
|
stmts:
|
|
- literal:
|
|
expr:
|
|
bool: true
|
|
eidx: 20
|
|
sidx: 5
|