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
Titouan Soulard
erp5
Commits
6a2c8eba
Commit
6a2c8eba
authored
Mar 22, 2023
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testSecurity: check dynamically generated methods as well.
parent
37c3fc43
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
product/ERP5/tests/testSecurity.py
product/ERP5/tests/testSecurity.py
+8
-5
No files found.
product/ERP5/tests/testSecurity.py
View file @
6a2c8eba
...
...
@@ -75,7 +75,7 @@ class TestSecurityMixin(ERP5TypeTestCase):
allowed_method_id_list
=
[
'om_icons'
,]
app
=
self
.
portal
.
aq_parent
meta_type_set
=
set
([
None
])
error_
set
=
set
()
error_
dict
=
{}
for
_
,
obj
in
app
.
ZopeFind
(
app
,
search_sub
=
1
):
meta_type
=
getattr
(
obj
,
'meta_type'
,
None
)
if
meta_type
in
meta_type_set
:
...
...
@@ -88,17 +88,20 @@ class TestSecurityMixin(ERP5TypeTestCase):
continue
method
=
getattr
(
obj
,
method_id
)
if
isinstance
(
method
,
MethodType
)
and
\
getattr
(
method
,
'
func_name
'
,
None
)
is
not
None
and
\
getattr
(
method
,
'
__name__
'
,
None
)
is
not
None
and
\
method
.
__doc__
and
\
not
hasattr
(
obj
,
'%s__roles__'
%
method_id
)
and
\
not
hasattr
(
method
,
'__roles__'
)
and
\
method
.
__module__
:
if
method
.
__module__
==
'Products.ERP5Type.Accessor.WorkflowState'
and
method
.
func_code
.
co_name
==
'serialize'
:
if
method
.
__module__
==
'Products.ERP5Type.Accessor.WorkflowState'
and
method
.
__code__
.
co_name
==
'serialize'
:
continue
func_code
=
method
.
__code__
error_set
.
add
((
func_code
.
co_filename
,
func_code
.
co_firstlineno
,
method_id
))
if
not
hasattr
(
func_code
,
'co_filename'
):
# ERP5 Accessor
func_code
=
method
.
__func__
.
__class__
.
__init__
.
__code__
error_dict
[(
func_code
.
co_filename
,
func_code
.
co_firstlineno
)]
=
method_id
error_list
=
[]
for
filename
,
lineno
,
method_id
in
sorted
(
error_set
):
for
(
filename
,
lineno
),
method_id
in
sorted
(
error_dict
.
items
()
):
# ignore security problems with non ERP5 documents, unless running in debug mode.
if
os
.
environ
.
get
(
'erp5_debug_mode'
)
or
'/erp5/'
in
filename
or
'<portal_components'
in
filename
:
error_list
.
append
(
'%s:%s %s'
%
(
filename
,
lineno
,
method_id
))
...
...
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