mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
OPA conformance (#71)
- 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 #69 Closes #70 Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
ad3282caf4
commit
e61b406547
@@ -10,10 +10,13 @@ fn rego_eval(
|
||||
input: Option<String>,
|
||||
query: String,
|
||||
enable_tracing: bool,
|
||||
non_strict: bool,
|
||||
) -> Result<()> {
|
||||
// Create engine.
|
||||
let mut engine = regorus::Engine::new();
|
||||
|
||||
engine.set_strict_builtin_errors(!non_strict);
|
||||
|
||||
// Load files from given bundles.
|
||||
for dir in bundles.iter() {
|
||||
let entries =
|
||||
@@ -130,6 +133,10 @@ enum RegorusCommand {
|
||||
/// Enable tracing.
|
||||
#[arg(long, short)]
|
||||
trace: bool,
|
||||
|
||||
// Non strict execution
|
||||
#[arg(long, short)]
|
||||
non_strict: bool,
|
||||
},
|
||||
|
||||
/// Tokenize a Rego policy.
|
||||
@@ -171,7 +178,8 @@ fn main() -> Result<()> {
|
||||
input,
|
||||
query,
|
||||
trace,
|
||||
} => rego_eval(&bundles, &data, input, query, trace),
|
||||
non_strict,
|
||||
} => rego_eval(&bundles, &data, input, query, trace, non_strict),
|
||||
RegorusCommand::Lex { file, verbose } => rego_lex(file, verbose),
|
||||
RegorusCommand::Parse { file } => rego_parse(file),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user