You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Version 1.77.0 breaks runtime evaluation of custom functions with multiple arguments.
Assume following ABAC model:
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub_rule, obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = eval(p.sub_rule) && r.obj == p.obj && r.act == p.act
When we register a custom function named hasNameAndAge and add a policy to the enforcer as follows, then the enforcer throws runtime exceptions. In this case Execute 'eval' function error, nested exception is: EOF while reading string at index: 20
@Test
public void testEvalCustomFunction() {
Enforcer e = new Enforcer("examples/abac_rule_model.conf", "examples/abac_rule_policy.csv");
HasNameAndAge customFunction = new HasNameAndAge();
e.addFunction(customFunction.getName(), customFunction);
List<String> rule = new ArrayList<>();
rule.add("hasNameAndAge('alice,green', 18)");
rule.add("data1");
rule.add("read");
e.addPolicy(rule);
TestEvalRule aliceGreen = new TestEvalRule("alice,green", 18);
testEnforce(e, aliceGreen, "data1", "read", true);
}
public static class HasNameAndAge extends CustomFunction {
@Override
public String getName() {
return "hasNameAndAge";
}
@Override
public AviatorObject call(Map<String, Object> env, AviatorObject arg1, AviatorObject arg2) {
String name = FunctionUtils.getStringValue(arg1, env);
Number age = FunctionUtils.getNumberValue(arg2, env);
TestEvalRule sub = (TestEvalRule) env.get("r_sub");
return name.equals(sub.getName()) && age.intValue() == sub.getAge() ? AviatorBoolean.TRUE : AviatorBoolean.FALSE;
}
}
Although this is a rather simple custom function and example, it demonstrates a major flaw in the change that was introduced with this commit, specifically the following snippet:
if (hasEval) {
pvals = splitCommaDelimitedList(pvals);
}
The text was updated successfully, but these errors were encountered:
Version
1.77.0
breaks runtime evaluation of custom functions with multiple arguments.Assume following ABAC model:
When we register a custom function named
hasNameAndAge
and add a policy to the enforcer as follows, then the enforcer throws runtime exceptions. In this caseExecute 'eval' function error, nested exception is: EOF while reading string at index: 20
Although this is a rather simple custom function and example, it demonstrates a major flaw in the change that was introduced with this commit, specifically the following snippet:
The text was updated successfully, but these errors were encountered: