mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Python: adjust test.
This commit is contained in:
@@ -440,22 +440,15 @@ class PathNormalizationTest extends InlineExpectationsTest {
|
||||
class SafeAccessCheckTest extends InlineExpectationsTest {
|
||||
SafeAccessCheckTest() { this = "SafeAccessCheckTest" }
|
||||
|
||||
override string getARelevantTag() { result in ["checks", "branch"] }
|
||||
override string getARelevantTag() { result = "SafeAccessCheck" }
|
||||
|
||||
override predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
exists(location.getFile().getRelativePath()) and
|
||||
exists(Path::SafeAccessCheck c, DataFlow::Node checks, boolean branch |
|
||||
c.checks(checks.asCfgNode(), branch) and
|
||||
exists(Path::SafeAccessCheck c |
|
||||
location = c.getLocation() and
|
||||
(
|
||||
element = checks.toString() and
|
||||
value = prettyNodeForInlineTest(checks) and
|
||||
tag = "checks"
|
||||
or
|
||||
element = branch.toString() and
|
||||
value = branch.toString() and
|
||||
tag = "branch"
|
||||
)
|
||||
element = c.toString() and
|
||||
value = prettyNodeForInlineTest(c) and
|
||||
tag = "SafeAccessCheck"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
s = "taintedString"
|
||||
|
||||
if s.startswith("tainted"): # $checks=s branch=true
|
||||
if s.startswith("tainted"):
|
||||
s2 = s # $SafeAccessCheck=s
|
||||
pass
|
||||
|
||||
sw = s.startswith
|
||||
if sw("safe"): # $ MISSING: checks=s branch=true
|
||||
if sw("safe"):
|
||||
s2 = s # $ MISSING: SafeAccessCheck=s
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user