[Permissions] Document COG deny edge case #6395
Labels
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot#6395
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
github.com/Cog-Creators/Red-DiscordBot@ad1e1aa2ba/redbot/core/commands/commands.py (L451-L458)The current logic for processing Permissions overrides entirely resolves the
COGpermissions, then exits early if the resolved state is to deny, and only then resolvesCOMMANDpermissions. Because the process of resolvingCOGandCOMMANDpermissions is split up like this, there is no way to maintain the order of operations from[p]permissions explainbetween these two categories. The output of[p]permissions explainshould 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
permissionsdon't seem to be working as intended.1st Scene.
Where if a user has both the roles (1255859061547728966 & 1255859041620721727) they can Only use the
hugcommand and not the rest of the sub-commands under the same cog.Which they should be able to
Explanation for this
permissionssettings -falsefor everyone - on cog level (Which means at this point no one can use ANY commands from the cogPerform)1255859061547728966- Which means only1255859061547728966can use ALL the commands (including thehug) from the cog.1255859041620721727role also has an override allowing them to use just thehugcommand.(This means people having just the
1255859041620721727role can only usehugbut people with the1255859061547728966role 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 the1255859041620721727role, 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
denythe rule for the1255859041620721727role onhugcommand 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
restartthe bot (reloading doesn't solve it). Work in the sense of - by respecting thisdenyrule.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 cogshould 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
1255859041620721727role to run cog-wide & overriding the1255859061547728966role todenythehugcommand 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
github.com/Cog-Creators/Red-DiscordBot@ad1e1aa2ba/redbot/core/commands/commands.py (L451-L458)The current logic for processing Permissions overrides entirely resolves the
COGpermissions, then exits early if the resolved state is to deny, and only then resolvesCOMMANDpermissions. Because the process of resolvingCOGandCOMMANDpermissions is split up like this, there is no way to maintain the order of operations from[p]permissions explainbetween these two categories. Fixing this would require entirely rewriting howCOGlevel permissions have been implemented, and is out of scope of what we are able to do.I am modifying this issue to make the goal be documenting this behavior in
[p]permissions explain.([ref] for org members)
Behoben in
52c22b8b6:[p]permissions explainerklärt jetzt ausdrücklich, dass Cog-Regeln vor Befehlsregeln vollständig ausgewertet werden und eine Befehlsregel einen per Cog-Regel verweigerten Befehl nicht freigeben kann.Generated by Claude Code