mirror of
https://github.com/github/codeql.git
synced 2025-12-19 18:33:16 +01:00
37 lines
1.1 KiB
Plaintext
37 lines
1.1 KiB
Plaintext
import python
|
|
import semmle.python.dataflow.new.DataFlow
|
|
import TestUtilities.InlineExpectationsTest
|
|
|
|
class GlobalReadTest extends InlineExpectationsTest {
|
|
GlobalReadTest() { this = "GlobalReadTest" }
|
|
|
|
override string getARelevantTag() { result = "reads" }
|
|
|
|
override predicate hasActualResult(Location location, string element, string tag, string value) {
|
|
exists(DataFlow::ModuleVariableNode n, DataFlow::Node read |
|
|
read = n.getARead() and
|
|
value = n.getVariable().getId() and
|
|
value != "print" and
|
|
tag = "reads" and
|
|
location = read.getLocation() and
|
|
element = read.toString()
|
|
)
|
|
}
|
|
}
|
|
|
|
class GlobalWriteTest extends InlineExpectationsTest {
|
|
GlobalWriteTest() { this = "GlobalWriteTest" }
|
|
|
|
override string getARelevantTag() { result = "writes" }
|
|
|
|
override predicate hasActualResult(Location location, string element, string tag, string value) {
|
|
exists(DataFlow::ModuleVariableNode n, DataFlow::Node read |
|
|
read = n.getAWrite() and
|
|
value = n.getVariable().getId() and
|
|
tag = "writes" and
|
|
location = read.getLocation() and
|
|
element = read.toString()
|
|
)
|
|
}
|
|
}
|