FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/python/ql/src/Classes/MutatingDescriptor.ql at codeql-cli-2.11.3 · github/codeql · GitHub
github
/
codeql
Public
Notifications
You must be signed in to change notification settings
Fork
2.1k
Star
10.1k
Code
Issues
1k
Pull requests
468
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
/
MutatingDescriptor.ql
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (29 loc) · 1.03 KB
Breadcrumbs
codeql
/
python
/
ql
/
src
/
Classes
/
MutatingDescriptor.ql
Copy path
File metadata and controls
32 lines (29 loc) · 1.03 KB
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
31
32
/**
* @name Mutation of descriptor in `__get__` or `__set__` method.
* @description Descriptor objects can be shared across many instances. Mutating them can cause strange side effects or race conditions.
* @kind problem
* @tags reliability
* correctness
* @problem.severity error
* @sub-severity low
* @precision very-high
* @id py/mutable-descriptor
*/
import
python
predicate
mutates_descriptor
(
ClassObject
cls
,
SelfAttributeStore
s
)
{
cls
.
isDescriptorType
(
)
and
exists
(
PyFunctionObject
f
,
PyFunctionObject
get_set
|
exists
(
string
name
|
cls
.
lookupAttribute
(
name
)
=
get_set
|
name
=
"__get__"
or
name
=
"__set__"
or
name
=
"__delete__"
)
and
cls
.
lookupAttribute
(
_
)
=
f
and
get_set
.
getACallee
*
(
)
=
f
and
not
f
.
getName
(
)
=
"__init__"
and
s
.
getScope
(
)
=
f
.
getFunction
(
)
)
}
from
ClassObject
cls
,
SelfAttributeStore
s
where
mutates_descriptor
(
cls
,
s
)
select
s
,
"Mutation of descriptor $@ object may lead to action-at-a-distance effects or race conditions for properties."
,
cls
,
cls
.
getName
(
)
Back
|
FazBrowse Home
|
New Git URL