question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow the explaination in `enforceEx` and `enforceExWithMatcher` methods in the CoreEnforcer to be accessed externally

See original GitHub issue

The current implementation of the CoreEnforcer prints the explanation on the log but does not allow it to be accessed externally.

The methods should allow the explanation to be passed externally. The below two methods should be

public boolean enforceEx(List<String> explain, Object... rvals) {
       return enforce("", explain, rvals);
}
    
 public boolean enforceExWithMatcher(String matcher, List<String> explain,  Object... rvals) {
        return enforce(matcher, explain, rvals);
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
aryalrabincommented, Oct 14, 2022

You don’t have to make any changes to Hit Policy:. The actual explanation is never returned back in jcasbin. Python or Go versions return multiple values with explanations back. https://github.com/casbin/pycasbin/blob/6f6b1279cddef182ddce98a8c806130d67666f91/casbin/core_enforcer.py#L459 https://github.com/casbin/casbin/blob/63b2757cc60362d974921cb9065809b617d8b527/enforcer.go#L707

However, jcasbin only logs the Hit policy: and does not expose the explanation. If you look at current implementation below

 public boolean enforceEx(Object... rvals) {
        List<String> explain = new ArrayList<>();
        return enforce("", explain, rvals);
    }

 public boolean enforceExWithMatcher(String matcher, Object... rvals) {
        List<String> explain = new ArrayList<>();
        return enforce(matcher, explain, rvals);
    }

Both enforceEx, enforceExWithMatcher print the Hit policy: in the log and never expose an explanation.

The above enforceEx, enforceExWithMatcher methods simply should let an explanation be passed as

public boolean enforceEx(List<String> explain, Object... rvals) {
       return enforce("", explain, rvals);
}
    
 public boolean enforceExWithMatcher(String matcher, List<String> explain,  Object... rvals) {
        return enforce(matcher, explain, rvals);
}

The business necessity is that the policy is dynamically populated from AD and contains metadata at the end. These metadata are required for compliance and some critical business rules.

the example policy will look like p, bob, data2, write, sensitivity, pii, mask

0reactions
github-actions[bot]commented, Oct 23, 2022

🎉 This issue has been resolved in version 1.31.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

Core Enforcer (move) - Bulbapedia
Core Enforcer (Japanese: コアパニッシャー Core Punisher) is a damage-dealing Dragon-type move introduced in Generation VII. It is one of the signature moves ...
Read more >
Casbin Easy Tasks for Beginners/Student Applicants - GitHub
enforceSync ignores subject, always returns true if policy exists for object and method. node-casbin#292 opened by FabianSellmann enhancement
Read more >
Core Enforcer - Pokémon Rulings Compendium
So I think I can use Zygarde's "Core Enforcer" attack without a Fairy energy attached, but what about the part of the attack...
Read more >
Why did core enforcer have to be a special attack? - GameFAQs
Holy s*** I am aware that it is a special attack and therefore looks like one. I'm saying I wish it was a...
Read more >
Core Enforcer | SM | Smogon Strategy Pokedex
If the user moves after the target, the target's Ability is rendered ineffective as long as it remains active. If the target uses...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found