- parser: allow non-string index at any position; not just last
- impl Default for Context
- Fix width of OPA test results table
- Allow non string compoenent anywhere in rule ref; not just as last item.
- Normalize want_result before comparison.
- Ensure that object rules are created even if no definition succeed,
- Sort want_result values for "refheads/general, multiple result-set entries"
The entries are in reverse order of how OPA and regorus produce.
- Emit PASS status for each OPA testpoint
- Detect rule conflicts
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
- ignore worktrees
- feature guard time module
- Apply with modifiers before evaluating loop expressions
- Support value modifier for functions
- stubs for http.send and io.jwt.decode_verify
- Initialize with-document after initializing init data
- In case of conflict, with modifier override init-data values.
- In case of conflict, subsequent with modifier overrides earlier ones.
- Ensure that zero parameter functions are evaluated and added to document
- opa.runtime builtin
returns:
- git commit hash
- environment vars
- regorus features enabled
- builtins available
- deprecated builtins available
- If `sort_bindings` is specified, sort the bindings in OPA tests
- gather inputs, used vars and comprehensions in with modifiers
- For refs starting with `data`, ensure that modules are evaluated before looking up
value of the expression. Thie ensures that modules that have only been partly populated
(E.g via with mods) are completely evaluated before the value is looked up
- Mark rules overridden using with modifiers are evaluated.
- Exclude env vars in opa.runtime.
- Include regorus version in OPA runtime
- update to opa v0.60.0
- scheduler: Handle function refs in with modifers. Error out only if
a truly undefined ref.
- Handle undefined params, parameter expression evaluation errors before
applying with modifiers.
- When applying with modifiers, first determine whether the target is a
function. If so, handle cleanly.
- concat: raise error only in strict mode
- In strict mode, propagate errors raised by function rule execution
in case of multiple function definitions for same rule
- skip "withkeyword/builtin-builtin: arity 0" test which can never pass.
- When a mock has is being applied, clear with_function so that
other mocks won't be applied during the evaluation of the mock.
- Ability to specify strictness in tests
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
The walk builtin generates values and implicitly creates a loop over the values.
Hoist walk calls as loops and handle them. Also handle cases where return value
is bound to an extra parameter.
Closes#83
- Switch to scientific crate. Large values are printed in scientific notations.
Regular values are printed as u64, i64 or f64.
- Skip copying commit hooks in git worktrees
- urlquery.decode, urlquery.encode, urlquery.encode_object
- substring, indexof_n string builtins
- Make sprintf more OPA conformant
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
- object.union
- object.union_n
- treat negative integers as two separate tokens (Sub and Number)
when seen in arithmetic expressions
- Ensure that fully query string is parsed
- Evaluate queries in a separate module instead of the last read module.
This correctly handles queries of the form `x = data.test.y` where x is
already a ref in `data.test`
- Handle queries producing multiple outputs in test infrastructure
- Add tests for engine
- Add tests locking down valid queries
- Update opa.passing
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
- Remove unnecessary memory allocations
- Add --non-strict flag
- Ensure that only empty modules (ones without rules) are initialzed prior to evaluating rules.
- Record rule as entry for each of its prefixes.
For example, for a rule a.b.c =... in package test, record it in
rules["data.test.a"], rules["data.test.a.b"] and rules["data.test.a.b.c"]
This allows evaluating the correct list of rules based on expessions
a.b.c, a.b, a, data.test.a.b.c, data.test.a.b, data.test.a
Closes#69Closes#70
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
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>
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>
- 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>
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>
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>
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>
`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>
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>
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>
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>