[Permissions] Document COG deny edge case #6395
Labels
Category: Cogs - Permissions
This is related to the Permissions cog.
Status: PRs Welcome
No one is currently assigned to this issue, but we'd be grateful if anyone made a PR.
Type: Bug
Unexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing.
Milestone
Red-DiscordBot/redbot/core/commands/commands.py
Lines 451 to 458 in ad1e1aa
The current logic for processing Permissions overrides entirely resolves the
COG
permissions, then exits early if the resolved state is to deny, and only then resolvesCOMMAND
permissions. Because the process of resolvingCOG
andCOMMAND
permissions is split up like this, there is no way to maintain the order of operations from[p]permissions explain
between these two categories. The output of[p]permissions explain
should be modified to clarify this limitation explicitly.The original issue is maintained below for reproduction steps.
Original issue
What Red version are you using?
3.5.9
What were you trying to do?
I've got a few scenarios where the
permissions
don't seem to be working as intended.1st Scene.
Where if a user has both the roles (1255859061547728966 & 1255859041620721727) they can Only use the
hug
command and not the rest of the sub-commands under the same cog.Which they should be able to
Explanation for this
permissions
settings -false
for everyone - on cog level (Which means at this point no one can use ANY commands from the cogPerform
)1255859061547728966
- Which means only1255859061547728966
can use ALL the commands (including thehug
) from the cog.1255859041620721727
role also has an override allowing them to use just thehug
command.(This means people having just the
1255859041620721727
role can only usehug
but people with the1255859061547728966
role can use every commands including hug.)The issue comes when the user has both the roles (
1255859061547728966
&1255859041620721727
) - where the cog stops the user from running every other command besidehug
. Which is weird and shouldn't be happening as the permissions rule for the1255859041620721727
role, is not conflicting with the cog's rule by any means.So, in this case - the cog should be able to let the user run every single command that the cog offers. That includes
hug
& other commands.Scene 2
Now, at this point if you
deny
the rule for the1255859041620721727
role onhug
command with -Then the cog starts to act very weird
hug
- Intended behavior as you've set the rule to denyhug
- Not intended behavior.The cog starts to work once you
restart
the bot (reloading doesn't solve it). Work in the sense of - by respecting thisdeny
rule.What did you expect to happen?
Expected Behavior:
When there's NO conflict (cog & command both states to
true
) between the cog & its commands, in the permissions rule settings - thepermissions cog
should allow the user (having both the roles) run all the commands regardless of the roles positions in the hierarchy. By taking both the rules from cog & command into account.Because if you just switch the ruleset by allowing the
1255859041620721727
role to run cog-wide & overriding the1255859061547728966
role todeny
thehug
command then the cog do take both the rules into account.In this case, the cog takes both the rule-sets into account and lets the user (having both the roles) to run every other command beside
hug
- which is intended behavior.What actually happened?
Cog did not let the user (having both the roles) run the commands - when there's no conflict.
How can we reproduce this error?
Anything else?
N/A
The text was updated successfully, but these errors were encountered: