mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
feat: OPA v0.68.0. Engine::set_rego_v1 (#305)
Provide ability in the engine to treat subsequently loaded policies as rego.v1. Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
edd0ccca5b
commit
af5071446b
+229
-115
@@ -1,115 +1,229 @@
|
||||
aggregates
|
||||
all
|
||||
any
|
||||
arithmetic
|
||||
array
|
||||
assignments
|
||||
base64builtins
|
||||
base64urlbuiltins
|
||||
baseandvirtualdocs
|
||||
bitsand
|
||||
bitsnegate
|
||||
bitsor
|
||||
bitsshiftleft
|
||||
bitsshiftright
|
||||
bitsxor
|
||||
casts
|
||||
comparisonexpr
|
||||
completedoc
|
||||
compositebasedereference
|
||||
compositereferences
|
||||
comprehensions
|
||||
containskeyword
|
||||
cryptohmacequal
|
||||
cryptohmacmd5
|
||||
cryptohmacsha1
|
||||
cryptohmacsha256
|
||||
cryptohmacsha512
|
||||
cryptomd5
|
||||
cryptosha1
|
||||
cryptosha256
|
||||
dataderef
|
||||
defaultkeyword
|
||||
disjunction
|
||||
elsekeyword
|
||||
embeddedvirtualdoc
|
||||
eqexpr
|
||||
evaltermexpr
|
||||
every
|
||||
example
|
||||
fix1863
|
||||
functionerrors
|
||||
functions
|
||||
globmatch
|
||||
globquotemeta
|
||||
helloworld
|
||||
hexbuiltins
|
||||
indexing
|
||||
indirectreferences
|
||||
inputvalues
|
||||
intersection
|
||||
jsonbuiltins
|
||||
jsonfilter
|
||||
jsonfilteridempotent
|
||||
jsonremove
|
||||
jsonremoveidempotent
|
||||
jsonschema
|
||||
jwtbuiltins
|
||||
negation
|
||||
nestedreferences
|
||||
numbersrange
|
||||
numbersrangestep
|
||||
objectfilter
|
||||
objectfilteridempotent
|
||||
objectfilternonstringkey
|
||||
objectget
|
||||
objectkeys
|
||||
objectremove
|
||||
objectremoveidempotent
|
||||
objectremovenonstringkey
|
||||
objectunion
|
||||
objectunionn
|
||||
partialdocconstants
|
||||
partialiter
|
||||
partialobjectdoc
|
||||
partialsetdoc
|
||||
planner-ir
|
||||
rand
|
||||
reachable
|
||||
refheads
|
||||
regexfind
|
||||
regexfindallstringsubmatch
|
||||
regexisvalid
|
||||
regexmatch
|
||||
regexmatchtemplate
|
||||
regexreplace
|
||||
regexsplit
|
||||
replacen
|
||||
semvercompare
|
||||
semverisvalid
|
||||
sets
|
||||
sprintf
|
||||
strings
|
||||
subset
|
||||
toarray
|
||||
topdowndynamicdispatch
|
||||
toset
|
||||
time
|
||||
trim
|
||||
trimleft
|
||||
trimprefix
|
||||
trimright
|
||||
trimspace
|
||||
trimsuffix
|
||||
type
|
||||
typebuiltin
|
||||
typenamebuiltin
|
||||
undos
|
||||
union
|
||||
units
|
||||
urlbuiltins
|
||||
uuid
|
||||
varreferences
|
||||
virtualdocs
|
||||
walkbuiltin
|
||||
withkeyword
|
||||
v0/aggregates
|
||||
v0/all
|
||||
v0/any
|
||||
v0/arithmetic
|
||||
v0/array
|
||||
v0/assignments
|
||||
v0/base64builtins
|
||||
v0/base64urlbuiltins
|
||||
v0/baseandvirtualdocs
|
||||
v0/bitsand
|
||||
v0/bitsnegate
|
||||
v0/bitsor
|
||||
v0/bitsshiftleft
|
||||
v0/bitsshiftright
|
||||
v0/bitsxor
|
||||
v0/casts
|
||||
v0/comparisonexpr
|
||||
v0/completedoc
|
||||
v0/compositebasedereference
|
||||
v0/compositereferences
|
||||
v0/comprehensions
|
||||
v0/containskeyword
|
||||
v0/cryptohmacequal
|
||||
v0/cryptohmacmd5
|
||||
v0/cryptohmacsha1
|
||||
v0/cryptohmacsha256
|
||||
v0/cryptohmacsha512
|
||||
v0/cryptomd5
|
||||
v0/cryptosha1
|
||||
v0/cryptosha256
|
||||
v0/dataderef
|
||||
v0/defaultkeyword
|
||||
v0/disjunction
|
||||
v0/elsekeyword
|
||||
v0/embeddedvirtualdoc
|
||||
v0/eqexpr
|
||||
v0/evaltermexpr
|
||||
v0/every
|
||||
v0/example
|
||||
v0/fix1863
|
||||
v0/functionerrors
|
||||
v0/functions
|
||||
v0/globmatch
|
||||
v0/globquotemeta
|
||||
v0/helloworld
|
||||
v0/hexbuiltins
|
||||
v0/indexing
|
||||
v0/indirectreferences
|
||||
v0/inputvalues
|
||||
v0/intersection
|
||||
v0/jsonbuiltins
|
||||
v0/jsonfilter
|
||||
v0/jsonfilteridempotent
|
||||
v0/jsonremove
|
||||
v0/jsonremoveidempotent
|
||||
v0/jsonschema
|
||||
v0/jwtbuiltins
|
||||
v0/negation
|
||||
v0/nestedreferences
|
||||
v0/numbersrange
|
||||
v0/numbersrangestep
|
||||
v0/objectfilter
|
||||
v0/objectfilteridempotent
|
||||
v0/objectfilternonstringkey
|
||||
v0/objectget
|
||||
v0/objectkeys
|
||||
v0/objectremove
|
||||
v0/objectremoveidempotent
|
||||
v0/objectremovenonstringkey
|
||||
v0/objectunion
|
||||
v0/objectunionn
|
||||
v0/partialdocconstants
|
||||
v0/partialiter
|
||||
v0/partialobjectdoc
|
||||
v0/partialsetdoc
|
||||
v0/planner-ir
|
||||
v0/rand
|
||||
v0/reachable
|
||||
v0/refheads
|
||||
v0/regexfind
|
||||
v0/regexfindallstringsubmatch
|
||||
v0/regexisvalid
|
||||
v0/regexmatch
|
||||
v0/regexmatchtemplate
|
||||
v0/regexreplace
|
||||
v0/regexsplit
|
||||
v0/replacen
|
||||
v0/semvercompare
|
||||
v0/semverisvalid
|
||||
v0/sets
|
||||
v0/sprintf
|
||||
v0/strings
|
||||
v0/subset
|
||||
v0/toarray
|
||||
v0/topdowndynamicdispatch
|
||||
v0/toset
|
||||
v0/time
|
||||
v0/trim
|
||||
v0/trimleft
|
||||
v0/trimprefix
|
||||
v0/trimright
|
||||
v0/trimspace
|
||||
v0/trimsuffix
|
||||
v0/type
|
||||
v0/typebuiltin
|
||||
v0/typenamebuiltin
|
||||
v0/undos
|
||||
v0/union
|
||||
v0/units
|
||||
v0/urlbuiltins
|
||||
v0/uuid
|
||||
v0/varreferences
|
||||
v0/virtualdocs
|
||||
v0/walkbuiltin
|
||||
v0/withkeyword
|
||||
v1/aggregates
|
||||
v1/all
|
||||
v1/any
|
||||
v1/arithmetic
|
||||
v1/array
|
||||
v1/assignments
|
||||
v1/base64builtins
|
||||
v1/base64urlbuiltins
|
||||
v1/baseandvirtualdocs
|
||||
v1/bitsand
|
||||
v1/bitsnegate
|
||||
v1/bitsor
|
||||
v1/bitsshiftleft
|
||||
v1/bitsshiftright
|
||||
v1/bitsxor
|
||||
v1/casts
|
||||
v1/comparisonexpr
|
||||
v1/completedoc
|
||||
v1/compositebasedereference
|
||||
v1/compositereferences
|
||||
v1/comprehensions
|
||||
v1/containskeyword
|
||||
v1/cryptohmacequal
|
||||
v1/cryptohmacmd5
|
||||
v1/cryptohmacsha1
|
||||
v1/cryptohmacsha256
|
||||
v1/cryptohmacsha512
|
||||
v1/cryptomd5
|
||||
v1/cryptosha1
|
||||
v1/cryptosha256
|
||||
v1/dataderef
|
||||
v1/defaultkeyword
|
||||
v1/disjunction
|
||||
v1/elsekeyword
|
||||
v1/embeddedvirtualdoc
|
||||
v1/eqexpr
|
||||
v1/evaltermexpr
|
||||
v1/every
|
||||
v1/example
|
||||
v1/fix1863
|
||||
v1/functionerrors
|
||||
v1/functions
|
||||
v1/globmatch
|
||||
v1/globquotemeta
|
||||
v1/helloworld
|
||||
v1/hexbuiltins
|
||||
v1/indexing
|
||||
v1/indirectreferences
|
||||
v1/inputvalues
|
||||
v1/intersection
|
||||
v1/jsonbuiltins
|
||||
v1/jsonfilter
|
||||
v1/jsonfilteridempotent
|
||||
v1/jsonremove
|
||||
v1/jsonremoveidempotent
|
||||
v1/jsonschema
|
||||
v1/jwtbuiltins
|
||||
v1/negation
|
||||
v1/nestedreferences
|
||||
v1/numbersrange
|
||||
v1/numbersrangestep
|
||||
v1/objectfilter
|
||||
v1/objectfilteridempotent
|
||||
v1/objectfilternonstringkey
|
||||
v1/objectget
|
||||
v1/objectkeys
|
||||
v1/objectremove
|
||||
v1/objectremoveidempotent
|
||||
v1/objectremovenonstringkey
|
||||
v1/objectunion
|
||||
v1/objectunionn
|
||||
v1/partialdocconstants
|
||||
v1/partialiter
|
||||
v1/partialobjectdoc
|
||||
v1/partialsetdoc
|
||||
v1/planner-ir
|
||||
v1/rand
|
||||
v1/reachable
|
||||
v1/refheads
|
||||
v1/regexfind
|
||||
v1/regexfindallstringsubmatch
|
||||
v1/regexisvalid
|
||||
v1/regexmatch
|
||||
v1/regexmatchtemplate
|
||||
v1/regexreplace
|
||||
v1/regexsplit
|
||||
v1/replacen
|
||||
v1/semvercompare
|
||||
v1/semverisvalid
|
||||
v1/sets
|
||||
v1/sprintf
|
||||
v1/strings
|
||||
v1/subset
|
||||
v1/toarray
|
||||
v1/topdowndynamicdispatch
|
||||
v1/toset
|
||||
v1/time
|
||||
v1/trim
|
||||
v1/trimleft
|
||||
v1/trimprefix
|
||||
v1/trimright
|
||||
v1/trimspace
|
||||
v1/trimsuffix
|
||||
v1/type
|
||||
v1/typebuiltin
|
||||
v1/typenamebuiltin
|
||||
v1/undos
|
||||
v1/union
|
||||
v1/units
|
||||
v1/urlbuiltins
|
||||
v1/uuid
|
||||
v1/varreferences
|
||||
v1/virtualdocs
|
||||
v1/walkbuiltin
|
||||
|
||||
+6
-3
@@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize};
|
||||
use walkdir::WalkDir;
|
||||
|
||||
const OPA_REPO: &str = "https://github.com/open-policy-agent/opa";
|
||||
const OPA_BRANCH: &str = "v0.67.0";
|
||||
const OPA_BRANCH: &str = "v0.68.0";
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
@@ -51,12 +51,14 @@ struct YamlTest {
|
||||
cases: Vec<TestCase>,
|
||||
}
|
||||
|
||||
fn eval_test_case(case: &TestCase) -> Result<Value> {
|
||||
fn eval_test_case(case: &TestCase, is_rego_v1_test: bool) -> Result<Value> {
|
||||
let mut engine = Engine::new();
|
||||
|
||||
#[cfg(feature = "coverage")]
|
||||
engine.set_enable_coverage(true);
|
||||
|
||||
engine.set_rego_v1(is_rego_v1_test);
|
||||
|
||||
if let Some(data) = &case.data {
|
||||
engine.add_data(data.clone())?;
|
||||
}
|
||||
@@ -172,6 +174,7 @@ fn run_opa_tests(opa_tests_dir: String, folders: &[String]) -> Result<()> {
|
||||
continue;
|
||||
}
|
||||
|
||||
let is_rego_v1_test = path_dir_str.starts_with("v1/");
|
||||
let entry = status.entry(path_dir_str).or_insert((0, 0, 0));
|
||||
|
||||
let yaml_str = std::fs::read_to_string(&path_str)?;
|
||||
@@ -216,7 +219,7 @@ fn run_opa_tests(opa_tests_dir: String, folders: &[String]) -> Result<()> {
|
||||
|
||||
print!("{:4}: {:90}", entry.2, case.note);
|
||||
entry.2 += 1;
|
||||
match (eval_test_case(&case), &case.want_result) {
|
||||
match (eval_test_case(&case, is_rego_v1_test), &case.want_result) {
|
||||
(Ok(actual), Some(expected))
|
||||
if is_json_schema_test && json_schema_tests_check(&actual, &expected) =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user