Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the restrictions #267

Open
vanillajonathan opened this issue Jan 19, 2024 · 5 comments
Open

Document the restrictions #267

vanillajonathan opened this issue Jan 19, 2024 · 5 comments

Comments

@vanillajonathan
Copy link

I read the documentation and vaguely get the idea that RestrictedPython is a restricted subset of Python, but the documentation does not explain what is restricted and why.

The documentation should list what is restricted and give a reason as for why that is restricted, as well as list what is not restricted.

Reading the source code gives some hints:

  • Matrix multiplication (@) is currently not allowed.
  • nonlocal is not allowed.
  • await/async is not allowed.
  • There is a range function with a limit of 1000.
  • list("string") is not allowed. Why?
  • tuple("string") is not allowed. Why?

What about...

  • infinite loops such as while True?
  • recursion?
  • nested for loops?
  • "foo".zfill(99999999999999999)
  • "foo".ljust(99999999999999999, ".")
  • 1024**1024**1024
  • String repeat "foo" * 1024**1024
@d-maurer
Copy link
Contributor

d-maurer commented Jan 19, 2024 via email

@vanillajonathan
Copy link
Author

Yes, I understand that RestrictedPython uses the ast module to parse the code into an abstract syntax tree and that it uses the ast.NodeTransformer.

I never said that I did not like the list, tuple or range definitions. I pointed out that the documentation does not mention those, and that I had to read the source code to find those, and that I not know why those are not allowed.

I would like the documentation to include a list of features that are not allowed and an explanation why, and a list of features which are restricted and how they are restricted and why.

Furthermore I would like the documentation to include information about what is not restricted that I should be aware of.

@d-maurer
Copy link
Contributor

d-maurer commented Jan 19, 2024 via email

@vanillajonathan
Copy link
Author

You looked at the code and found out some things you think should get
documented.

Yes, a few while briefly looking through some of the code, but I wouldn't always know the rationale behind the decisions, even if I perhaps could guess.

What about signing a contributor agreement and add those things to
the documentation?

I tend to shy away from contributing to projects where signing a CLA is required.
I haven't even used RestrictedPython, just looked at the documentation to try to figure out what it restricts and what it doesn't.

@d-maurer
Copy link
Contributor

d-maurer commented Jan 20, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants