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
Currently escapeAssertion does a rather brutal regex replace operation to convert r.*/p.* into r_*/p_* respectively. However it does not consider the case where the expression could contain a string literal. So if you have a rule that have some sort of string literal like p.obj == "r.something" it will fail in a very subtle manner.
const{ newEnforcer, newModel }=require("casbin");constMY_RESOURCE_NAME="r.my_resource";// change this to e.g. "a.my_resource" and it will work(asyncfunction(){constmodel=newModel();model.addDef("r","r","act, obj");model.addDef("p","p","act, obj, rule");model.addDef("e","e","some(where (p.eft == allow))");model.addDef("m","m","r.act == p.act && r.obj == p.obj && eval(p.rule)");constenforcer=awaitnewEnforcer(model);enforcer.addPolicy("alice",MY_RESOURCE_NAME,`p.obj == "${MY_RESOURCE_NAME}"`);// does not work because internally it becomes `p_obj == "r_my_resource"`console.log(awaitenforcer.enforce("alice",MY_RESOURCE_NAME));})();
The text was updated successfully, but these errors were encountered:
Currently
escapeAssertion
does a rather brutal regex replace operation to convertr.*
/p.*
intor_*
/p_*
respectively. However it does not consider the case where the expression could contain a string literal. So if you have a rule that have some sort of string literal likep.obj == "r.something"
it will fail in a very subtle manner.The text was updated successfully, but these errors were encountered: