Python: adjust test.

This commit is contained in:
Anders Schack-Mulligen
2022-06-20 14:52:02 +02:00
parent 1b13790a36
commit a7c268f804
2 changed files with 9 additions and 14 deletions

View File

@@ -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"
)
}
}

View File

@@ -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