FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/python/ql/src/Classes/InconsistentMRO.ql at codeql-cli/v2.15.4 · github/codeql · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
github
/
codeql
Public
Notifications
You must be signed in to change notification settings
Fork
2.1k
Star
10k
Code
Issues
997
Pull requests
454
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql
/
python
/
ql
/
src
/
Classes
/
InconsistentMRO.ql
Copy path
More file actions
More file actions
Latest commit
History
History
History
30 lines (26 loc) · 946 Bytes
Breadcrumbs
codeql
/
python
/
ql
/
src
/
Classes
/
InconsistentMRO.ql
Copy path
File metadata and controls
30 lines (26 loc) · 946 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* @name Inconsistent method resolution order
* @description Class definition will raise a type error at runtime due to inconsistent method resolution order(MRO)
* @kind problem
* @tags reliability
* correctness
* @problem.severity error
* @sub-severity high
* @precision very-high
* @id py/inconsistent-mro
*/
import
python
ClassObject
left_base
(
ClassObject
type
,
ClassObject
base
)
{
exists
(
int
i
|
i
>
0
and
type
.
getBaseType
(
i
)
=
base
and
result
=
type
.
getBaseType
(
i
-
1
)
)
}
predicate
invalid_mro
(
ClassObject
t
,
ClassObject
left
,
ClassObject
right
)
{
t
.
isNewStyle
(
)
and
left
=
left_base
(
t
,
right
)
and
left
=
right
.
getAnImproperSuperType
(
)
}
from
ClassObject
t
,
ClassObject
left
,
ClassObject
right
where
invalid_mro
(
t
,
left
,
right
)
select
t
,
"Construction of class "
+
t
.
getName
(
)
+
" can fail due to invalid method resolution order(MRO) for bases $@ and $@."
,
left
,
left
.
getName
(
)
,
right
,
right
.
getName
(
)
Back
|
FazBrowse Home
|
New Git URL