plone / plone/documentation

Which modules are whitelisted in RestrictedPython by default?

Open
#465 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

31 needs: help 33 needs: docs 99 tag: Plone 6.x
Dominant language
Makefile
Stars
106
Forks
190
Avg merge
3d 2h
Merged PRs (30d)
1

Description

I can find documentation on how to whitelist a module in RestrictedPython, but not which modules come whitelisted by default. Only vague assertions that RestrictedPython gives limited access, but to what? If this is documented somewhere, please let me know, otherwise it would be good to add.

For example, I was reading this doc on Creating content from PFG. The Custom Script Adapter in PFG uses RestrictedPython, and it imports DateTime, so that is obviously whitelisted. I also tried importing getToolByName from Products.CMFCore.utils, and that works, too. But I wanted to modernize the example to use plone.api instead of invokeFactory, but importing plone.api is not allowed. Which is odd, because I wanted to use it to simply do what invokeFactory is doing. I'm not arguing for whitelisting of plone.api (this has been discussed elsewhere), but it would save people time to know what is and is not whitelisted.

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 with the Creating content from PFG documentation linked in the issue and inspect how RestrictedPython handles imports for the Custom Script Adapter. Identify the modules available by default, including the examples mentioned, and document the allowed imports and relevant limitations. Done means readers can determine what is and is not whitelisted without trial and error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.