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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Paul Graydon
erp5
Commits
a2dcc631
Commit
a2dcc631
authored
Mar 10, 2021
by
Aurel
Committed by
Jérome Perrin
Jan 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip : update patches & import for zope4
parent
87f3ba91
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
30 deletions
+33
-30
product/ERP5Type/CopySupport.py
product/ERP5Type/CopySupport.py
+8
-10
product/ERP5Type/patches/DA.py
product/ERP5Type/patches/DA.py
+2
-3
product/ERP5Type/patches/Restricted.py
product/ERP5Type/patches/Restricted.py
+21
-15
product/ZSQLCatalog/ZSQLCatalog.py
product/ZSQLCatalog/ZSQLCatalog.py
+2
-2
No files found.
product/ERP5Type/CopySupport.py
View file @
a2dcc631
...
@@ -21,8 +21,6 @@ from AccessControl.Permission import Permission
...
@@ -21,8 +21,6 @@ from AccessControl.Permission import Permission
from
OFS.ObjectManager
import
ObjectManager
from
OFS.ObjectManager
import
ObjectManager
from
OFS.CopySupport
import
CopyContainer
as
OriginalCopyContainer
from
OFS.CopySupport
import
CopyContainer
as
OriginalCopyContainer
from
OFS.CopySupport
import
CopyError
from
OFS.CopySupport
import
CopyError
from
OFS.CopySupport
import
eNotSupported
,
eNoItemsSpecified
,
eNoData
from
OFS.CopySupport
import
eNotFound
,
eInvalid
from
OFS.CopySupport
import
_cb_encode
,
_cb_decode
,
cookie_path
from
OFS.CopySupport
import
_cb_encode
,
_cb_decode
,
cookie_path
from
OFS.CopySupport
import
sanity_check
from
OFS.CopySupport
import
sanity_check
from
Products.ERP5Type
import
Permissions
from
Products.ERP5Type
import
Permissions
...
@@ -70,7 +68,7 @@ class CopyContainer:
...
@@ -70,7 +68,7 @@ class CopyContainer:
return
OriginalCopyContainer
.
manage_copyObjects
(
self
,
ids
,
REQUEST
,
return
OriginalCopyContainer
.
manage_copyObjects
(
self
,
ids
,
REQUEST
,
RESPONSE
)
RESPONSE
)
if
uids
is
None
and
REQUEST
is
not
None
:
if
uids
is
None
and
REQUEST
is
not
None
:
r
eturn
eNoItemsSpecified
r
aise
BadRequest
(
'No items specified'
)
elif
uids
is
None
:
elif
uids
is
None
:
raise
ValueError
(
'uids must be specified'
)
raise
ValueError
(
'uids must be specified'
)
...
@@ -80,7 +78,7 @@ class CopyContainer:
...
@@ -80,7 +78,7 @@ class CopyContainer:
for
uid
in
uids
:
for
uid
in
uids
:
ob
=
self
.
getPortalObject
().
portal_catalog
.
getObject
(
uid
)
ob
=
self
.
getPortalObject
().
portal_catalog
.
getObject
(
uid
)
if
not
ob
.
cb_isCopyable
():
if
not
ob
.
cb_isCopyable
():
raise
CopyError
(
eNotSupported
%
uid
)
raise
CopyError
(
'Not Supported'
)
m
=
Moniker
.
Moniker
(
ob
)
m
=
Moniker
.
Moniker
(
ob
)
oblist
.
append
(
m
.
dump
())
oblist
.
append
(
m
.
dump
())
cp
=
(
0
,
oblist
)
cp
=
(
0
,
oblist
)
...
@@ -185,7 +183,7 @@ class CopyContainer:
...
@@ -185,7 +183,7 @@ class CopyContainer:
# Use default methode
# Use default methode
return
OriginalCopyContainer
.
manage_cutObjects
(
self
,
ids
,
REQUEST
)
return
OriginalCopyContainer
.
manage_cutObjects
(
self
,
ids
,
REQUEST
)
if
uids
is
None
and
REQUEST
is
not
None
:
if
uids
is
None
and
REQUEST
is
not
None
:
r
eturn
eNoItemsSpecified
r
aise
BadRequest
(
'No items specified'
)
elif
uids
is
None
:
elif
uids
is
None
:
raise
ValueError
(
'uids must be specified'
)
raise
ValueError
(
'uids must be specified'
)
...
@@ -195,7 +193,7 @@ class CopyContainer:
...
@@ -195,7 +193,7 @@ class CopyContainer:
for
uid
in
uids
:
for
uid
in
uids
:
ob
=
self
.
getPortalObject
().
portal_catalog
.
getObject
(
uid
)
ob
=
self
.
getPortalObject
().
portal_catalog
.
getObject
(
uid
)
if
not
ob
.
cb_isMoveable
():
if
not
ob
.
cb_isMoveable
():
raise
CopyError
(
eNotSupported
%
id
)
raise
CopyError
(
'Not Supported'
)
m
=
Moniker
.
Moniker
(
ob
)
m
=
Moniker
.
Moniker
(
ob
)
oblist
.
append
(
m
.
dump
())
oblist
.
append
(
m
.
dump
())
cp
=
(
1
,
oblist
)
# 0->1 This is the difference with manage_copyObject
cp
=
(
1
,
oblist
)
# 0->1 This is the difference with manage_copyObject
...
@@ -439,7 +437,7 @@ class CopyContainer:
...
@@ -439,7 +437,7 @@ class CopyContainer:
try
:
try
:
cp
=
_cb_decode
(
cp
)
cp
=
_cb_decode
(
cp
)
except
:
except
:
raise
CopyError
(
eInvalid
)
raise
CopyError
(
"Clipboard Error"
)
oblist
=
[]
oblist
=
[]
op
=
cp
[
0
]
op
=
cp
[
0
]
app
=
self
.
getPhysicalRoot
()
app
=
self
.
getPhysicalRoot
()
...
@@ -448,7 +446,7 @@ class CopyContainer:
...
@@ -448,7 +446,7 @@ class CopyContainer:
try
:
try
:
ob
=
m
.
bind
(
app
)
ob
=
m
.
bind
(
app
)
except
:
except
:
raise
CopyError
(
eNotFound
)
raise
CopyError
(
'Item Not Found'
)
self
.
_verifyObjectPaste
(
ob
,
validate_src
=
op
+
1
)
self
.
_verifyObjectPaste
(
ob
,
validate_src
=
op
+
1
)
oblist
.
append
(
ob
)
oblist
.
append
(
ob
)
result
=
[]
result
=
[]
...
@@ -475,7 +473,7 @@ class CopyContainer:
...
@@ -475,7 +473,7 @@ class CopyContainer:
)[
op
]
)[
op
]
for
ob
in
oblist
:
for
ob
in
oblist
:
if
not
getattr
(
ob
,
is_doable_id
)():
if
not
getattr
(
ob
,
is_doable_id
)():
raise
CopyError
(
eNotSupported
%
escape
(
ob
.
getId
())
)
raise
CopyError
(
'Not Supported'
)
try
:
try
:
ob
.
_notifyOfCopyTo
(
self
,
op
=
op
)
ob
.
_notifyOfCopyTo
(
self
,
op
=
op
)
except
:
except
:
...
@@ -595,7 +593,7 @@ class CopyContainer:
...
@@ -595,7 +593,7 @@ class CopyContainer:
elif
REQUEST
is
not
None
and
'__cp'
in
REQUEST
:
elif
REQUEST
is
not
None
and
'__cp'
in
REQUEST
:
cp
=
REQUEST
[
'__cp'
]
cp
=
REQUEST
[
'__cp'
]
if
cp
is
None
:
if
cp
is
None
:
raise
CopyError
(
eNoData
)
raise
CopyError
(
"No Data"
)
op
,
result
=
self
.
__duplicate
(
op
,
result
=
self
.
__duplicate
(
cp
,
cp
,
duplicate
=
False
,
duplicate
=
False
,
...
...
product/ERP5Type/patches/DA.py
View file @
a2dcc631
...
@@ -17,11 +17,10 @@ import re
...
@@ -17,11 +17,10 @@ import re
try
:
from
IOBTree
import
Bucket
try
:
from
IOBTree
import
Bucket
except
:
Bucket
=
lambda
:{}
except
:
Bucket
=
lambda
:{}
from
Shared.DC.ZRDB.Aqueduct
import
decodestring
,
parse
from
Shared.DC.ZRDB.Aqueduct
import
decodestring
,
parse
from
Shared.DC.ZRDB.DA
import
DA
,
DatabaseError
,
SQLMethodTracebackSupplement
from
Shared.DC.ZRDB.DA
import
DA
,
DatabaseError
,
SQLMethodTracebackSupplement
,
getBrain
from
Shared.DC.ZRDB
import
RDB
from
Shared.DC.ZRDB
import
RDB
from
Shared.DC.ZRDB.Results
import
Results
from
Shared.DC.ZRDB.Results
import
Results
from
App.Extensions
import
getBrain
from
AccessControl
import
ClassSecurityInfo
,
getSecurityManager
from
AccessControl
import
ClassSecurityInfo
,
getSecurityManager
from
Products.ERP5Type.Globals
import
InitializeClass
from
Products.ERP5Type.Globals
import
InitializeClass
from
Acquisition
import
aq_base
,
aq_parent
from
Acquisition
import
aq_base
,
aq_parent
from
zLOG
import
LOG
,
INFO
,
ERROR
from
zLOG
import
LOG
,
INFO
,
ERROR
...
...
product/ERP5Type/patches/Restricted.py
View file @
a2dcc631
...
@@ -16,26 +16,32 @@ import copy
...
@@ -16,26 +16,32 @@ import copy
import
sys
import
sys
import
types
import
types
from
RestrictedPython.
RestrictionMutator
import
RestrictionMutato
r
from
RestrictedPython.
transformer
import
RestrictingNodeTransforme
r
_MARKER
=
[]
_MARKER
=
[]
def
checkNameLax
(
self
,
node
,
name
=
_MARKER
):
def
checkNameLax
(
self
,
node
,
name
,
allow_magic_methods
=
False
):
"""
Verifies that a name being assigned is safe
.
"""
Check names if they are allowed
.
In ERP5 we are much more lax that than in Zope's original restricted
In ERP5 we are much more lax that than in Zope's original restricted
python and allow to using names starting with _, because we rely on
python and allow to using names starting with _, because we rely on
runtime checks to prevent access to forbidden attributes from objects.
runtime checks to prevent access to forbidden attributes from objects.
We don't allow defining attributes ending with __roles__ though.
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
_MARKER
:
if
name
is
None
:
# we use same implementation for checkName and checkAttrName which access
return
# the name in different ways ( see RestrictionMutator 3.6.0 )
name
=
node
.
attrname
if
name
.
endswith
(
'__roles__'
):
if
name
.
endswith
(
'__roles__'
):
self
.
error
(
node
,
'"%s" is an invalid variable name because '
self
.
error
(
node
,
'"%s" is an invalid variable name because '
'it ends with "__roles__".'
%
name
)
'it ends with "__roles__".'
%
name
)
elif
name
in
FORBIDDEN_FUNC_NAMES
:
self
.
error
(
node
,
'"{name}" is a reserved name.'
.
format
(
name
=
name
))
RestrictionMutator
.
checkName
=
RestrictionMutator
.
checkAttrName
=
checkNameLax
RestrictingNodeTransformer
.
check_name
=
checkNameLax
# XXX we might want to pach visit_Attribute too
from
Acquisition
import
aq_acquire
from
Acquisition
import
aq_acquire
...
@@ -49,17 +55,17 @@ from AccessControl.ZopeGuards import (safe_builtins, _marker, Unauthorized,
...
@@ -49,17 +55,17 @@ from AccessControl.ZopeGuards import (safe_builtins, _marker, Unauthorized,
# TODO: add buffer/bytearray
# TODO: add buffer/bytearray
def
add_builtins
(
**
kw
):
def
add_builtins
(
**
kw
):
assert
not
set
(
safe_builtins
).
intersection
(
kw
)
assert
not
set
(
safe_builtins
).
intersection
(
kw
)
,
"%r intersect %r
\
n
%r"
%
(
safe_builtins
,
kw
,
set
(
safe_builtins
).
intersection
(
kw
))
safe_builtins
.
update
(
kw
)
safe_builtins
.
update
(
kw
)
del
safe_builtins
[
'dict'
]
del
safe_builtins
[
'dict'
]
del
safe_builtins
[
'list'
]
del
safe_builtins
[
'list'
]
add_builtins
(
Ellipsis
=
Ellipsis
,
NotImplemented
=
NotImplemented
,
add_builtins
(
Ellipsis
=
Ellipsis
,
NotImplemented
=
NotImplemented
,
dict
=
dict
,
list
=
list
,
set
=
set
,
frozenset
=
frozenset
)
dict
=
dict
,
list
=
list
)
#
, set=set, frozenset=frozenset)
add_builtins
(
bin
=
bin
,
classmethod
=
classmethod
,
format
=
format
,
object
=
object
,
add_builtins
(
bin
=
bin
,
classmethod
=
classmethod
,
format
=
format
,
object
=
object
,
property
=
property
,
s
lice
=
slice
,
s
taticmethod
=
staticmethod
,
property
=
property
,
staticmethod
=
staticmethod
,
super
=
super
,
type
=
type
)
super
=
super
,
type
=
type
)
# slice=slice,
def
guarded_next
(
iterator
,
default
=
_marker
):
def
guarded_next
(
iterator
,
default
=
_marker
):
"""next(iterator[, default])
"""next(iterator[, default])
...
@@ -81,7 +87,7 @@ def guarded_next(iterator, default=_marker):
...
@@ -81,7 +87,7 @@ def guarded_next(iterator, default=_marker):
if
default
is
_marker
:
if
default
is
_marker
:
raise
raise
return
default
return
default
add_builtins
(
next
=
guarded_next
)
#
add_builtins(next=guarded_next)
_safe_class_attribute_dict
=
{}
_safe_class_attribute_dict
=
{}
import
inspect
import
inspect
...
@@ -237,7 +243,7 @@ from AccessControl.ZopeGuards import _dict_white_list
...
@@ -237,7 +243,7 @@ from AccessControl.ZopeGuards import _dict_white_list
# (closure) directly to ignore defaultdict like dict/list
# (closure) directly to ignore defaultdict like dict/list
from
RestrictedPython.Guards
import
full_write_guard
from
RestrictedPython.Guards
import
full_write_guard
ContainerAssertions
[
defaultdict
]
=
_check_access_wrapper
(
defaultdict
,
_dict_white_list
)
ContainerAssertions
[
defaultdict
]
=
_check_access_wrapper
(
defaultdict
,
_dict_white_list
)
full_write_guard
.
func_closure
[
1
].
cell_contents
.
__self__
[
defaultdict
]
=
True
#XXX
full_write_guard.func_closure[1].cell_contents.__self__[defaultdict] = True
ContainerAssertions
[
OrderedDict
]
=
_check_access_wrapper
(
OrderedDict
,
_dict_white_list
)
ContainerAssertions
[
OrderedDict
]
=
_check_access_wrapper
(
OrderedDict
,
_dict_white_list
)
OrderedDict
.
__guarded_setitem__
=
OrderedDict
.
__setitem__
.
__func__
OrderedDict
.
__guarded_setitem__
=
OrderedDict
.
__setitem__
.
__func__
...
...
product/ZSQLCatalog/ZSQLCatalog.py
View file @
a2dcc631
...
@@ -27,7 +27,7 @@ from Acquisition import Implicit, aq_base
...
@@ -27,7 +27,7 @@ from Acquisition import Implicit, aq_base
from
Persistence
import
Persistent
from
Persistence
import
Persistent
from
DocumentTemplate.DT_Util
import
InstanceDict
,
TemplateDict
from
DocumentTemplate.DT_Util
import
InstanceDict
,
TemplateDict
from
DocumentTemplate.DT_Util
import
Eval
from
DocumentTemplate.DT_Util
import
Eval
from
AccessControl.Permission
import
name_trans
from
AccessControl.Permission
import
getPermissionIdentifier
from
AccessControl.Permissions
import
import_export_objects
,
\
from
AccessControl.Permissions
import
import_export_objects
,
\
manage_zcatalog_entries
manage_zcatalog_entries
from
.SQLCatalog
import
CatalogError
from
.SQLCatalog
import
CatalogError
...
@@ -1364,7 +1364,7 @@ InitializeClass(ZCatalog)
...
@@ -1364,7 +1364,7 @@ InitializeClass(ZCatalog)
def
p_name
(
name
):
def
p_name
(
name
):
return
'_'
+
string
.
translate
(
name
,
name_trans
)
+
'_Permission'
return
getPermissionIdentifier
(
name
)
def
absattr
(
attr
):
def
absattr
(
attr
):
if
callable
(
attr
):
return
attr
()
if
callable
(
attr
):
return
attr
()
...
...
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