Anand Krishnamoorthi
8a73b4bef9
Updated readme. Added bundle support. ( #61 )
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-12-06 15:47:50 -08:00
Anand Krishnamoorthi
70bf371ebf
crypto builtins ( #57 )
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-12-06 07:59:04 -08:00
Anand Krishnamoorthi
ab968c2386
Regex and Glob builtins ( #56 )
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-12-03 12:08:17 -08:00
Anand Krishnamoorthi
ed3492fd7b
Formalize concept of a Number ( #55 )
...
Number is implemented using rust_decimal::Decimal which uses a 96 bit mantissa.
TODO:
a) Support u64, i64 variants
b) Determine desired semantics for floating-point
c) Determine desired big integer length
d) Explore other big int/big float crates
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-12-01 08:45:59 -08:00
Anand Krishnamoorthi
bb0ca29753
Lock down ACI tests and more OPA test folders ( #54 )
...
Borrowed from rego-cpp
Significantly (> 10 times) faster execution.
$ cargo test -r --test aci
aci/mount_device passed 9.597958ms
aci/mount_overlay passed 10.159208ms
aci/scratch_mount passed 8.598875ms
aci/create_container passed 10.237292ms
aci/shutdown_container passed 6.904084ms
aci/scratch_unmount passed 6.530875ms
aci/unmount_overlay passed 5.958875ms
aci/unmount_device passed 5.657834ms
aci/load_fragment passed 6.049917ms
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-12-01 08:32:11 -08:00
Anand Krishnamoorthi
639ba72c90
Fix scheduling regression ( #53 )
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-11-27 10:02:37 -08:00
eric-therond
ef36d9bed5
add full api to engine ( #50 )
...
Signed-off-by: eric-therond <eric.therond.fr@gmail.com >
2023-11-27 09:08:40 -08:00
Anand Krishnamoorthi
3514594c56
Use Rc<str> instead of string. ( #52 )
...
This reduces std::mem::size_of::<Value>() to 16 bytes.
String values are also efficiently copied like Objects, arrays, sets etc.
When multiple function rules are evaluated, ensure that constant argument values
match before running the rule. If actual parameter does not match the constant parameter,
then the rule is skipped.
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-11-24 17:45:49 -08:00
Anand Krishnamoorthi
4db2270dcf
More library functions ( #51 )
...
- units.parse, units.parse_bytes
- json.is_valid, json.marshal, json.unmarshal
- yaml.is_valid, yaml.marshal, yaml.unmarshal
- object.subset
- set_diff
* Also print number of errors due to each missing function
* Also lock down fully passing OPA suites
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-11-22 14:19:23 -08:00
Luong-Minh Nguyen
e838d5af65
Added semver.is_valid and semver.compare ( #49 )
...
* Completed semver.is_valid and semver.compare
* Addressed PR comments
Signed-off-by: Minh Nguyen <luonguyen@microsoft.com >
---------
Signed-off-by: Minh Nguyen <luonguyen@microsoft.com >
Co-authored-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-11-16 16:05:02 -08:00
Anand Krishnamoorthi
a75f7c51df
OPA conformance tests ( #45 )
...
Run regorus against OPA test suite.
To run full test suite:
cargo test --test opa
To run specific folder (e.g semver):
cargo test --test opa -- semver
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-11-15 17:09:53 -08:00
Anand Krishnamoorthi
72070a7061
Avoid dependency on `source lifetime. ( #43 )
...
This allows holding onto objects, caching results etc easily.
However it does introduce the overhead of ref counting.
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-11-15 09:25:12 -08:00
Anand Krishnamoorthi
a1d0f8576a
Allow with modifier for builtin and user functions ( #42 )
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-11-12 21:39:59 -08:00
Anand Krishnamoorthi
1c492144b3
Special cases of refs to data ( #41 )
...
1. Numeric indices will be converted to strings for refs beginning with `data`
if there is not valid numeric key
2. Error out if input document already contains value for a ref
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-11-11 00:15:56 -08:00
Anand Krishnamoorthi
02c6c6b827
Fix scheduling statements that don't create bindings ( #40 )
...
Ensure that definitions are added even if no var is being defined.
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-11-09 16:24:43 -08:00
Anand Krishnamoorthi
0af8b6ea12
Ability to run the OPA testsuite ( #39 )
...
`OPA_TESTS_DIR=path/to/testsuite cargo test opa -- --shot-output` to run opa tests.
Failing test cases are saved in target/opa/folder for investigation.
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-11-09 15:11:33 -08:00
Anand Krishnamoorthi
d69b413c8e
Engine ( #38 )
...
- Avoid lifetime parameter for Source, Span. Use Rc instead.
- Engine for simplified API
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-11-07 23:15:28 -08:00
Anand Krishnamoorthi
a751cd69e1
Use Ref for storing ast nodes in collections. ( #37 )
...
cmp, eq is done as pointer comparison which makes retrieval super fast.
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-11-05 22:32:00 -08:00
Anand Krishnamoorthi
d3fd0a3a78
all, any deprecated functions ( #35 )
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-11-04 13:22:40 -07:00
Anand Krishnamoorthi
c53d002347
Improvements ( #33 )
...
1. Skip recording undefined variables
2. Parse `in` correctly if it is not imported.
3. base64.decode
4. Handle `with` modifier for qualified data and input.
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-11-01 21:57:06 -07:00
Anand Krishnamoorthi
6228eaab4a
Order query expression results ( #32 )
...
Expressions are scheduled based on dependencies and thusthe gathered
expression values may not be in the same order as in source.
Reorder to match the source.
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-10-31 13:26:33 -07:00
Anand Krishnamoorthi
519cce5b33
Scheduling of statements in user queries ( #31 )
...
Nested queries (comprehensions) are handled correctly.
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-10-31 10:52:51 -07:00
Anand Krishnamoorthi
7a3d5e7e02
eval, lex, parse commands ( #30 )
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-10-30 21:45:43 -07:00
Anand Krishnamoorthi
63ecc44a48
eval_user_query for OPA style results ( #29 )
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-10-30 10:44:02 -07:00
Anand Krishnamoorthi
800e594d52
Arity for builtins ( #28 )
...
Old-style function call
Utility for running opa yaml tests
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-10-24 10:11:50 -07:00
Anand Krishnamoorthi
951bb6b14c
Handle chained _ ( #27 )
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-10-17 19:32:42 -07:00
Anand Krishnamoorthi
2436467fbd
Minimize PR 22 ( #26 )
...
* specific functions added to eval different rego components
Signed-off-by: eric-therond <eric.therond.fr@gmail.com >
* allow multiple inputs and results
Signed-off-by: eric-therond <eric.therond.fr@gmail.com >
* prepare_for_eval is necessary to be called
Signed-off-by: eric-therond <eric.therond.fr@gmail.com >
* test with the suggested code examples and clean scopes
Signed-off-by: eric-therond <eric.therond.fr@gmail.com >
* try to refactor first steps of evaluations
Signed-off-by: eric-therond <eric.therond.fr@gmail.com >
* improve coverage and fix clean state internal evaluation
Signed-off-by: eric-therond <eric.therond.fr@gmail.com >
* add getters and setters and fix clean function
Signed-off-by: eric-therond <eric.therond.fr@gmail.com >
* Tests are single input by default. Multi input specified via "many!" marker.
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
---------
Signed-off-by: eric-therond <eric.therond.fr@gmail.com >
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
Co-authored-by: eric-therond <eric.therond.fr@gmail.com >
2023-10-09 14:27:31 -07:00
Anand Krishnamoorthi
b7420aceba
Fix clippy warning ( #25 )
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-09-27 08:40:36 -07:00
eric-therond
8a9652b8d2
negation of an undefined value should return true ( #21 )
...
Signed-off-by: eric-therond <eric.therond.fr@gmail.com >
2023-06-29 09:44:19 -07:00
Anand Krishnamoorthi
796da46ae8
Ensure that scopes are cleaned up correctly upon error. ( #20 )
...
When evaluating rules, upon error the last pushed scope wasn't being
popped from the stack of scopes. This causes incorrect behavior
when there are multiple definitions for the same rule name.
The fix is to make sure that the scopes are popped manually upon encountering errors.
Once the interpreter logic is locked down, then we need to clean up scope management
using Drop functions so that the cleanup happens even during short circuited return.
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-06-23 08:57:47 -07:00
eric-therond
e08d13df53
fix bitwise.and and add tests ( #19 )
...
Signed-off-by: eric-therond <eric.therond.fr@gmail.com >
2023-06-22 11:27:58 -07:00
eric-therond
910ef32ffb
support of or-functions ( #18 )
...
* support of multiple definitions of the same function
* handle functions producing an error
Signed-off-by: eric-therond <eric.therond.fr@gmail.com >
2023-06-16 09:30:17 -07:00
Anand Krishnamoorthi
7789de41b6
Statement Scheduler Implementation
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-04-09 20:28:59 -07:00
Anand Krishnamoorthi
cba0af0d3f
json.filter, object.filter, object.get, object.keys, object.remove
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-03-07 21:27:27 +05:30
Anand Krishnamoorthi
112623c762
tracing::trace builtin
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-03-05 16:39:42 +05:30
Anand Krishnamoorthi
3c3cd312fc
More string functions
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-03-01 22:13:09 +05:30
Anand Krishnamoorthi
27c5afd8ee
strings: concat and contains
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-03-01 22:13:09 +05:30
Anand Krishnamoorthi
89e26e37a2
string concat (WIP)
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-03-01 22:13:09 +05:30
Anand Krishnamoorthi
32028a311e
Test for multi-assign
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-02-28 09:38:40 +05:30
Anand Krishnamoorthi
8e0ddbcff2
Support dependencies between vars defined in same statement
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-02-28 09:38:40 +05:30
Anand Krishnamoorthi
34eee1f17f
Statement scheduler (WIP)
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-02-28 09:38:40 +05:30
Anand Krishnamoorthi
31e1c63281
Tests for aggregates builtins
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-02-28 09:38:40 +05:30
Anand Krishnamoorthi
6b87e99fb9
Tests for numbers builtins
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-02-28 09:38:40 +05:30
Anand Krishnamoorthi
17257f9f1d
Tests for arrays builtins
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-02-28 09:38:40 +05:30
Anand Krishnamoorthi
c4ae2d4cc2
Tests for types functions
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-02-28 09:38:40 +05:30
Anand Krishnamoorthi
ae3866b1ab
Destructuring of arrays and objects in some-in expressions
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-02-28 09:38:40 +05:30
Anand Krishnamoorthi
cf4fbdbb90
some .. in implementation
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-02-28 09:38:40 +05:30
Anand Krishnamoorthi
eded43bdc6
Fix key, value in membership and some-in
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-02-28 09:38:40 +05:30
Anand Krishnamoorthi
351483d100
Implement every statement ( #4 )
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-02-28 09:38:40 +05:30
Anand Krishnamoorthi
2a1924efa5
Set loop index variable if not "_" ( #3 )
...
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com >
2023-02-28 09:38:40 +05:30