plone / plone/plone.api

Use safer (not None) user argument default value in all functions where authenticated member is fallback

Open
#150 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
101
Forks
62
Avg merge
15h 15m
Merged PRs (30d)
1

Description

plone.api.user.revoke_roles(user=plone.api.user.get(…)) can have dangerous side effects if the user value returned by Products.CMFPlone.RegistrationTool.get_member_by_login_name() returns None value for user (exceptions are supressed in call, this is possible). The same side-effect of unintentionally modifying or querying the authenticated user is possible in such cases.

Maybe using None as a default argument value for the user keyword argument is insufficient as a marker. I would suggest some other kind of marker be used to disambiguate intended omission from incidental NoneType value.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading plone.api.user.revoke_roles, plone.api.user.get, and the use of Products.CMFPlone.RegistrationTool.get_member_by_login_name() described in the report. Determine the marker and scope needed across the affected functions; done should prevent an incidental None from being treated as omission while preserving the authenticated-user fallback when omission is intentional.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, security
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.