-
-
Notifications
You must be signed in to change notification settings - Fork 466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug]Adding a policy that contains double quotes will cause an exception in the eval function #440
Comments
|
model.conf:
policy:
request:
|
@Wan95u plz provide full Java code (better in a test case format) |
@hsluoyz main code
Request
policy
|
@Wan95u Could you please provide more details on how you added the policy, such as which adapter you're using and the type of database? I performed some tests, and the results were correct even without calling public class MyTest {
@Test
public void jCasbin() {
Request.Sub sub = new Request().new Sub();
sub.setName("n3");
sub.setAge(1);
Request.Obj obj = new Request().new Obj();
obj.setField(Arrays.asList("f1", "f2"));
Request request = new Request();
request.setSub(sub);
request.setObj(obj);
request.setAct("read");
Policy policy = new Policy();
policy.setSub("");
policy.setObj("let test=seq.set('n3','n4');include(test,r.sub.name)");
policy.setAct("read");
Enforcer enforcer = new Enforcer("examples/test.conf");
// addPolicy
boolean flag = enforcer.addPolicy(policy.rule());
System.out.println("add policy:" + flag);
// verify
AviatorEvaluatorInstance aviatorEval = enforcer.getAviatorEval();
aviatorEval.setOption(Options.TRACE_EVAL, true);
EnforceResult enforceResult = enforcer.enforceEx(request.getSub(), request.getObj(), request.getAct());
System.out.println(enforceResult);
}
} |
@tx2002
I used casbin-spring-boot-starter:1.7.0, which is jscasbin:1.55.0.database type is mysql yaml:
|
jcasbin version
1.5.5
What happened
When adding a new policy, if the rule contains double quotes, the Assertion.policy will also contain double quotes, causing the eval function to fail. Restarting the program and calling Helper.loadPolicyLine() will split the double quotes. I would like to ask about the original intention behind the design of both.
The text was updated successfully, but these errors were encountered: