rego-cpp

A C++ interpreter for the OPA policy language Rego

MIT License

Downloads
2.5K
Stars
33

Bot releases are hidden (Show)

rego-cpp - v0.4.2 Latest Release

Published by matajoh 4 months ago

Point release updating the Trieste version.

This change should address build instability due to snmalloc updates.

rego-cpp - v0.4.1

Published by matajoh 4 months ago

Point release containing doc updates and bug fixes.

  • Updated the docs to reflect the new interfaces and outputs

Bug Fixes

  • Fixed an issue with actions attached to an In statement for some builds/environments
  • Fixed a bug with modules that start with comments
  • Fixed a bug with comprehension contexts when an assigned variable is shadowed in the body of the comprehension
rego-cpp - v0.4.0 - Upgrade to Rego v0.65.0

Published by matajoh 4 months ago

This minor version release updates rego-cpp to use the latest version of Trieste and also brings it into line with OPA Rego v0.65.0, while fixing many bugs and adding some quality of life improvements.

New Features

  • Updated the supported version of Rego to v0.65.0.
  • json.marshal_with_options
  • numbers.range_step
  • rego.v1 import and behaviour, plus a set of tests in regov1.yaml
  • The interpreter now returns more than one Result when appropriate, and separates out the Bindings and Terms.
  • The output of rego is now JSON instead of plain text
  • Added regoOutputSize, regoExpressions, regoBindingsAtIndex, and regoExpressionsAtIndex to the C API
  • Updated the Python and Rust wrappers to use the new API
  • Updated to latest version of Trieste
  • Uses Trieste's YAML and JSON parsers and emitters
  • Uses Trieste's more robust Unicode support
  • Passes broken up into a Reader, which parses Rego files, and a Rewriter which performs unification
  • Added the encoding and graphs builtins
  • Added set_log_level_from_string and setLogLevelFromString to make it easier to set the log level. All executables now use this option.

Improvements

  • The Interpreter caches intermediate versions of all modules, reducing query execution time
  • All of the early passes have been rewritten and are more efficient, resulting in reduced parsing time
  • The reduction of the input passes (and their restriction to a single file) along with other optimizations to header files has resulted in reduced compile times
  • The rego_fuzzer xecutable allows for more fine-grained fuzzing and testing of the Rego toolchain
  • Multiple bug fixes

Deprecation

  • The regoSetInputJSON method is a misnomer, as the input does not strictly need to be JSON. This has been replaced with an (otherwise identical) function called regoSetInputTerm which does the same thing, and the JSON version has been deprecated.

Breaking Changes

  • Output of rego tool has changed. Any downstream tooling that was parsing that will need to be updated to parse the JSON.
  • rego::wf_result has changed. Any tooling that was using the output node directly will need to be updated
  • the add_* methods on Interpreter, as they now perform parsing, now produce either a nullptr if successful or an error Node.
    Downstream consumers that were checking the boolean return value will need to be updated. Behavior in the C API is unchanged, but
    there will now be detailed parse/compile errors when an individual module etc. fails to compile.
  • The rego_trieste executable has been replaced by the new rego_fuzzer executable

New Test Coverage

  • base64builtins
  • base64urlbuiltins
  • hexbuiltins
  • jsonbuiltins
  • reachable
  • urlbuiltins
rego-cpp - v0.3.11

Published by matajoh 9 months ago

Minor improvements and bug fixes.

New Features

  • Updated to more recent Trieste version
  • More sophisticated logging

Bug fixes

  • Comprehensions over local variables were not properly capturing the local (regression due to optimization)
  • Local variable initializations were order-dependent (regression due to optimization)
  • In some circumstances, indexing the data object with an undefined key caused a segfault.

Other

  • Various CI changes due to issues with Github actions.
rego-cpp - v0.3.10 - Performance improvements

Published by matajoh about 1 year ago

Instrumentation and optimization.

New Features

  • A new REGOCPP_ACTION_METRICS option is available. When turned on, it will compile rego-cpp with
    instrumentation to measure the number of times a Trieste action is executed and how long is spent
    in each.
  • A new internal join method.

Improvements

  • ValueDef now caches its str and json representations instead of computing them each time.
    This has had a significant impact on unification (~5x speedup)
  • Use of the new join method reduces allocations and copies for common string operations
  • The unifier can now act over Object, Set, and Array nodes directly.
  • The functions pass has been refactored to produce fewer temporary variables and to perform
    fewer rewrites, reducing its runtime by half.
  • The local variable fixing that used to happen in implicit_enums now happens in its own pass, enum_locals.
rego-cpp - v0.3.9

Published by matajoh about 1 year ago

Fixing several impactful bugs.

Bug fixes

  • The ACI tests were incorrectly written in such a way that they would always pass. This has been addressed,
    and safeguards put in place in the test driver to detect this in the future.
  • Some statements nested in an every block would break the conditions if the item sequence was an array for
    which multiple elements could be identified by the some that were valid (see the new every_some test for
    a minimal reproduction). This has been fixed.
  • Dead links were being incorrectly identified in some cases. This has been addressed by making the check
    more precise and moving it to the functions pass.
  • Var lookups into a virtual or base document would resolve the entire document, causing needless recursion.
    This has been fixed.
rego-cpp - Python and Rust wrappers

Published by matajoh about 1 year ago

This release marks the first versions of the Rust and Python APIs, along with their example code.

Adding new examples for Python and Rust usage.

Python API

  • wrappers/python/ contains a Python package, regopy, which wraps the library
    and exposes a Python API. It is published on PyPi here

Rust API

  • wrappers/rust/ contains a Rust crate, regorust, which wraps the library
    and exposes a Rust API. It is published on crates.io here

Bug Fixes

  • Fixed a bug where to_json() was incorrectly sorting arrays when the sort
    flag was set to true.
  • Removes a memory leak caused by a cyclic graph of Unifiers
  • Fixes various use-after-free violations caused by missing clone() invocations.

New Features

  • The C++ API is now documented using Doxygen. The documentation can be found
    here.
  • Logging levels have been added and can be set via the API (instead of just
    binary enabled/disabled)
  • The library can now be built to target the C++ 17 standard (for older compilers)

Breaking changes

  • C API: The regoSetLoggingEnabled function has been replaced with
    regoSetLoggingLevel. This is also reflected in the C++ and Rust APIs.h
  • C API: The regoSetExecutablePath function has been removed due to the
    Interpreter::executable() property being removed from the C++ API.
  • The to_json method flag rego_set has been changed to set_as_array and
    the order of its flag inverted (it is now false by default).
  • C API: The regoAddInput* functions are now named regoSetInput* and can
    be used multiple times on the same interpreter.
  • C API: regoGet/SetStrictBuiltInErrors has been added.
  • The public headers have been reduced to just two files:
    • rego.hh which contains the C++ API
    • rego_c.h which contains the C API
  • The rego.hh header is now a C++ header and will not compile in C.
  • Many definitions have been moved to the (non-public) internal.hh header,
    and code which relied on having access to those definitions will break.
rego-cpp - Adding the C API

Published by matajoh about 1 year ago

Adding a C API.

New Features

  • rego_c.h contains a C API for the library
  • examples/c contains an example that builds an interpreter using the C API

Breaking Change
The project was incorrectly configured to set the PUBLIC CMake build directory to include/rego instead of include. This meant that projects consuming the library using CMake FetchContent would include header files without a rego/ prefix, which would cause problems long term. This has been fixed, but as a result any projects using the library via CMake FetchContent will need to update their #include statements to include the rego/ prefix.

rego-cpp - Adding `regex`, `bits`, `casts`, and `types` builtins

Published by matajoh about 1 year ago

Adding further builtins and test coverage, plus some minor
refactoring.

Adds the bits, casts, types builtins. Also adds the regex
builtins with the exception of regex.globs_match, which we will
add later along with the globs builtins.

New Features

  • bits builtins
  • casts builtins
  • types builtins
  • regex builtins (w/out regex.globs_match)
  • Miscellaneous builtins
    • any
    • all

New Test Coverage

  • any
  • all
  • bitsand
  • bitsnegate
  • bitsor
  • bitsshiftleft
  • bitsshiftright
  • bitsxor
  • casts
  • regexfind
  • regexfindallstringsubmatch
  • regexisvalid
  • regexmatch
  • regexreplace
  • regexsplit
  • regexmatchtemplate

Improvements

  • unwrap_arg and the associated UnwrapOpt struct provide a
    straightforward way to unwrap arguments for built-ins while producing
    the expected error messages for type mismatch.
  • unwrap provides a set-based way to do optional unwrapping of terms.
rego-cpp - Milestone 0.3.0

Published by matajoh about 1 year ago

Minor release. From this point the implementation passes the Rego
test suite and can be considered a compatible Rego implementation.

Adds the semver, objects, and units builtins.

New Features

  • semver builtins
  • objects builtins
  • units builtins
  • Miscellaneous builtins
    • cast_array
    • cast_set
    • opa.runtime
    • json.marshal
    • time.now_ns

New Test Coverage

  • assignments
  • baseandvirtualdocs
  • completedoc
  • compositereferences
  • comprehensions
  • containskeyword
  • dataderef
  • defaultkeyword
  • disjunction
  • elsekeyword
  • embeddedvirtualdoc
  • eqexpr
  • evaltermexpr
  • every
  • example
  • fix1863
  • functionerrors
  • functions
  • indirectreferences
  • inputvalues
  • negation
  • nestedreferences
  • object*
  • partialdocconstants
  • partialiter
  • partialobjectdoc
  • partialsetdoc
  • refheads
  • semver*
  • subset
  • toarray
  • topdowndynamicdispatch
  • toset
  • type
  • undos
  • units
  • varreferences
  • virtualdocs
  • withkeyword
rego-cpp - Milestone 0.2.3

Published by matajoh about 1 year ago

Adding the remainder of the missing language features, bringing the implementation fully
compliant with the published v0.55.0 grammar.

New Features

  • Array, Set, and Object comprehensions
  • every keyword
  • import support
  • with keyword
  • Basic built-in framework in place. Added some builtins as well:
    • print
    • startswith
    • endswith
    • count
    • to_number
    • union
    • intersection
  • bin-infix support
  • ref package names

Bug fixes

  • Nested enumeration was not working properly. This has been fixed.

Improvements

  • Turning on unification logging can be done on the command line (no recompile needed)
  • Passes have been broken out for better comprehensibility
  • Build time has been reduced
rego-cpp - Milestone 0.2.2

Published by matajoh over 1 year ago

Adding the in, if, contains, and else keywords.

New Features

  • Added future keyword support to the runtime
  • Added in, if, contains, and else keywords to the runtime
  • Added partial set rule construction
  • Added partial object rule construction

Bug fixes

  • Else rule bodies were not previously handled correctly when the else keyword
    was omitted. This has been fixed.
  • ExprCall nodes can now (correctly) be a RefHead.

Improvements

  • Function calls are now represented interally via a ExprCall node as opposed to
    a RefArgCall node, to better reflect the target grammar.
rego-cpp - v0.2.1

Published by matajoh over 1 year ago

Addresses various minor improvements, bugs, and documentation issues.

Bug fixes

  • Fixed a segfault when an input, data, or module file did not exist
  • Fixed a segfault when a lookdown returns zero definitions
  • Fixed various typos and errors in the documentation
  • Fixed a potential infinite rewrite loop in the RuleBody pass

Improvements

  • Rule values will no longer always be UnifyBody nodes but will be Term nodes
    in cases when the rule returns a constant value.
  • The code now uses the well-formed child indexing wherever possible for increased
    robustness.
rego-cpp - v0.2.0 - Initial Release

Published by matajoh over 1 year ago

Package Rankings
Top 22.3% on Pypi.org
Related Projects