mirror of
https://github.com/github/codeql.git
synced 2026-03-30 20:28:15 +02:00
python: add tests for guards compared to booleans
This commit is contained in:
@@ -192,6 +192,49 @@ def test_with_exception_neg():
|
||||
|
||||
ensure_not_tainted(s)
|
||||
|
||||
def test_comparison_with_bool():
|
||||
s = TAINTED_STRING
|
||||
|
||||
if is_safe(s) == True:
|
||||
ensure_not_tainted(s) # $ SPURIOUS: tainted
|
||||
else:
|
||||
ensure_tainted(s) # $ tainted
|
||||
|
||||
if is_safe(s) == False:
|
||||
ensure_tainted(s) # $ tainted
|
||||
else:
|
||||
ensure_not_tainted(s) # $ SPURIOUS: tainted
|
||||
|
||||
if is_safe(s) != True:
|
||||
ensure_tainted(s) # $ tainted
|
||||
else:
|
||||
ensure_not_tainted(s) # $ SPURIOUS: tainted
|
||||
|
||||
if is_safe(s) != False:
|
||||
ensure_not_tainted(s) # $ SPURIOUS: tainted
|
||||
else:
|
||||
ensure_tainted(s) # $ tainted
|
||||
|
||||
if is_safe(s) is True:
|
||||
ensure_not_tainted(s) # $ SPURIOUS: tainted
|
||||
else:
|
||||
ensure_tainted(s) # $ tainted
|
||||
|
||||
if is_safe(s) is False:
|
||||
ensure_tainted(s) # $ tainted
|
||||
else:
|
||||
ensure_not_tainted(s) # $ SPURIOUS: tainted
|
||||
|
||||
if is_safe(s) is not True:
|
||||
ensure_tainted(s) # $ tainted
|
||||
else:
|
||||
ensure_not_tainted(s) # $ SPURIOUS: tainted
|
||||
|
||||
if is_safe(s) is not False:
|
||||
ensure_not_tainted(s) # $ SPURIOUS: tainted
|
||||
else:
|
||||
ensure_tainted(s) # $ tainted
|
||||
|
||||
# Make tests runable
|
||||
|
||||
test_basic()
|
||||
@@ -211,3 +254,4 @@ try:
|
||||
test_with_exception_neg()
|
||||
except:
|
||||
pass
|
||||
test_comparison_with_bool()
|
||||
|
||||
Reference in New Issue
Block a user