Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
138
Merge Requests
138
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
02670c15
Commit
02670c15
authored
Mar 18, 2021
by
Aurel
Committed by
Arnaud Fontaine
Jan 27, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make patch work with Zope2
parent
66968313
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
product/ERP5Type/patches/Restricted.py
product/ERP5Type/patches/Restricted.py
+22
-6
No files found.
product/ERP5Type/patches/Restricted.py
View file @
02670c15
...
...
@@ -16,9 +16,14 @@ import copy
import
sys
import
types
from
RestrictedPython.transformer
import
RestrictingNodeTransformer
try
:
from
RestrictedPython.transformer
import
FORBIDDEN_FUNC_NAMES
except
:
# BBB
FORBIDDEN_FUNC_NAMES
=
frozenset
([
'printed'
,])
_MARKER
=
[]
def
checkNameLax
(
self
,
node
,
name
,
allow_magic_methods
=
False
):
def
checkNameLax
(
self
,
node
,
name
=
_MARKER
,
allow_magic_methods
=
False
):
"""Check names if they are allowed.
In ERP5 we are much more lax that than in Zope's original restricted
...
...
@@ -26,22 +31,33 @@ def checkNameLax(self, node, name, allow_magic_methods=False):
runtime checks to prevent access to forbidden attributes from objects.
We don't allow defining attributes ending with __roles__ though.
If ``allow_magic_methods is True`` names in `ALLOWED_FUNC_NAMES`
are additionally allowed although their names start with `_`.
"""
if
name
is
None
:
return
if
name
is
_MARKER
:
# we use same implementation for checkName and checkAttrName which access
# the name in different ways ( see RestrictionMutator 3.6.0 )
name
=
node
.
attrname
if
name
.
endswith
(
'__roles__'
):
self
.
error
(
node
,
'"%s" is an invalid variable name because '
'it ends with "__roles__".'
%
name
)
elif
name
in
FORBIDDEN_FUNC_NAMES
:
self
.
error
(
node
,
'"{name}" is a reserved name.'
.
format
(
name
=
name
))
RestrictingNodeTransformer
.
check_name
=
checkNameLax
# XXX we might want to pach visit_Attribute too
try
:
from
RestrictedPython.transformer
import
RestrictingNodeTransformer
RestrictingNodeTransformer
.
check_name
=
checkNameLax
except
ImportError
:
# BBB Restriced 3.6.0
from
RestrictedPython.RestrictionMutator
import
RestrictionMutator
RestrictionMutator
.
checkName
=
RestrictionMutator
.
checkAttrName
=
checkNameLax
from
Acquisition
import
aq_acquire
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment