[p]permissions acl setguild is broken for Postgres driver #3796

Closed
opened 2020-04-27 01:57:32 +02:00 by Jackenmen · 2 comments
Jackenmen commented 2020-04-27 01:57:32 +02:00 (Migrated from github.com)

Command bugs

Command name

[p]permissions acl setguild

What cog is this command from?

Permissions

What were you expecting to happen?

I expected ACL to be set properly

What actually happened?

The whole ACL for the guild got borked:
image

  • default and 176070082584248320 are keys that are result of using [p]permissions acl setguild
  • 8 represents how it should look - the rule was added with a [p]permissions addguildrule deny 8 57287406247743488 command right after setting ACL

For the reference, this is how YAML file given to [p]permissions acl setguild looks:

COG: {}
COMMAND:
  ping:
    default: false
    176070082584248320: true
  roll:
    default: true
    176070082584248320: false

How can we reproduce this issue?

Use [p]permissions acl setguild on a bot using Postgres driver.

# Command bugs #### Command name `[p]permissions acl setguild` #### What cog is this command from? Permissions #### What were you expecting to happen? I expected ACL to be set properly #### What actually happened? The whole ACL for the guild got borked: ![image](https://user-images.githubusercontent.com/6032823/80323132-ccd88500-8829-11ea-8fc6-37e91ceb19f7.png) - `default` and `176070082584248320` are keys that are result of using `[p]permissions acl setguild` - `8` represents how it should look - the rule was added with a `[p]permissions addguildrule deny 8 57287406247743488` command right after setting ACL For the reference, this is how YAML file given to `[p]permissions acl setguild` looks: ```yaml COG: {} COMMAND: ping: default: false 176070082584248320: true roll: default: true 176070082584248320: false ``` #### How can we reproduce this issue? Use `[p]permissions acl setguild` on a bot using Postgres driver.
mikeshardmind commented 2020-05-02 23:32:36 +02:00 (Migrated from github.com)

I looked into this a little bit after a question I got about it. I can replicate the issue, and it appears to be related to use of set raw on a config base group, but I admittedly did not look into this in large detail and am only relaying the minimal amount of looking into this I've already done since I haven't looked further and am unlikely to do so.

Given what I remember about the internals of the drivers, I'd check for proper filling of the identifier info container class in this interaction as a next step should someone else look into this more.

I looked into this a little bit after a question I got about it. I can replicate the issue, and it appears to be related to use of set raw on a config base group, but I admittedly did not look into this in large detail and am only relaying the minimal amount of looking into this I've already done since I haven't looked further and am unlikely to do so. Given what I remember about the internals of the drivers, I'd check for proper filling of the identifier info container class in this interaction as a next step should someone else look into this more.
Tobotimus commented 2020-05-07 10:18:39 +02:00 (Migrated from github.com)

Yeah @mikeshardmind is right, and the issue is actually rather simple. In config.Group.set_raw(), the IdentifierData.add_identifier() method is being used rather naively, since the primary key can be incomplete.

I'd say just add another method: IdentifierData.get_child(), which recognises whether or not an extra "key" will need to be a primary key or an identifier, then use this in Group.set_raw() instead.

It works by coincidence with the JSON driver because JSON doesn't really have a logical distinction between primary keys and identifiers.

Yeah @mikeshardmind is right, and the issue is actually rather simple. In `config.Group.set_raw()`, the `IdentifierData.add_identifier()` method is being used rather naively, since the primary key can be incomplete. I'd say just add another method: `IdentifierData.get_child()`, which recognises whether or not an extra "key" will need to be a primary key or an identifier, then use this in `Group.set_raw()` instead. It works by coincidence with the JSON driver because JSON doesn't really have a logical distinction between primary keys and identifiers.
Sign in to join this conversation.
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 milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot#3796
No description provided.