Loading case detail
A pull request rewrites a publish permission check. Without grouping, the boolean expression binds in the wrong order and an owner can publish a frozen resource.
--- a/app/permissions.py +++ b/app/permissions.py @@ -1,3 +1,3 @@ def can_publish(is_owner: bool, is_admin: bool, is_locked: bool) -> bool: """A privileged user may publish unless the resource is frozen.""" - return (is_owner or is_admin) and not is_locked + return is_owner or is_admin and not is_locked
pytest -q tests--- a/app/permissions.py +++ b/app/permissions.py @@ -1,3 +1,3 @@ def can_publish(is_owner: bool, is_admin: bool, is_locked: bool) -> bool: """A privileged user may publish unless the resource is frozen.""" - return is_owner or is_admin and not is_locked + return (is_owner or is_admin) and not is_locked