FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/python/ql/src/Variables/Loop.qll at codeql-cli/v2.19.1 · 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
467
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
/
Variables
/
Loop.qll
Copy path
More file actions
More file actions
Latest commit
History
History
History
39 lines (34 loc) · 1.27 KB
Breadcrumbs
codeql
/
python
/
ql
/
src
/
Variables
/
Loop.qll
Copy path
File metadata and controls
39 lines (34 loc) · 1.27 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
33
34
35
36
37
38
39
import
python
private
predicate
empty_sequence
(
Expr
e
)
{
exists
(
SsaVariable
var
|
var
.
getAUse
(
)
.
getNode
(
)
=
e
|
empty_sequence
(
var
.
getDefinition
(
)
.
getNode
(
)
)
)
or
e
instanceof
List
and
not
exists
(
e
.
(
List
)
.
getAnElt
(
)
)
or
e
instanceof
Tuple
and
not
exists
(
e
.
(
Tuple
)
.
getAnElt
(
)
)
or
e
.
(
StringLiteral
)
.
getText
(
)
.
length
(
)
=
0
}
/* This has the potential for refinement, but we err on the side of fewer false positives for now. */
private
predicate
probably_non_empty_sequence
(
Expr
e
)
{
not
empty_sequence
(
e
)
}
/** A loop which probably defines v */
private
Stmt
loop_probably_defines
(
Variable
v
)
{
exists
(
Name
defn
|
defn
.
defines
(
v
)
and
result
.
contains
(
defn
)
|
probably_non_empty_sequence
(
result
.
(
For
)
.
getIter
(
)
)
or
probably_non_empty_sequence
(
result
.
(
While
)
.
getTest
(
)
)
)
}
/** Holds if the variable used by `use` is probably defined in a loop */
predicate
probably_defined_in_loop
(
Name
use
)
{
exists
(
Stmt
loop
|
loop
=
loop_probably_defines
(
use
.
getVariable
(
)
)
|
loop
.
getAFlowNode
(
)
.
strictlyReaches
(
use
.
getAFlowNode
(
)
)
)
}
/** Holds if `s` is a loop that probably executes at least once */
predicate
loop_probably_executes_at_least_once
(
Stmt
s
)
{
probably_non_empty_sequence
(
s
.
(
For
)
.
getIter
(
)
)
or
probably_non_empty_sequence
(
s
.
(
While
)
.
getTest
(
)
)
}
Back
|
FazBrowse Home
|
New Git URL