Fixes #20239: Prevent shared mutable state in PluginMenuItem/PluginMenuButton #633

Closed
opened 2026-04-05 16:58:05 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @jnovinger on 1/8/2026

Fixes: #20239

PluginMenuItem and PluginMenuButton classes used mutable class-level defaults for permissions and buttons attributes, causing permission leakage between instances when these attributes were modified without explicit parameters.

Changed to initialize these attributes as fresh lists per instance in __init__ when not explicitly provided, following standard Python pattern for avoiding mutable default arguments.

*Originally created by @jnovinger on 1/8/2026* ### Fixes: #20239 `PluginMenuItem` and `PluginMenuButton` classes used mutable class-level defaults for `permissions` and `buttons` attributes, causing permission leakage between instances when these attributes were modified without explicit parameters. Changed to initialize these attributes as fresh lists per instance in `__init__` when not explicitly provided, following standard Python pattern for avoiding mutable default arguments.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#633