mirror of
https://github.com/github/codeql.git
synced 2026-05-01 19:55:15 +02:00
Python: Improve customSanitizer tests
Before we didn't show how we treated the value _after_ the check. But we
do actually handle this nicely 💪
This commit is contained in:
@@ -3,9 +3,9 @@ untaintedArgumentToEnsureTaintedNotMarkedAsMissing
|
||||
failures
|
||||
isSanitizer
|
||||
| TestTaintTrackingConfiguration | test.py:21:39:21:39 | ControlFlowNode for s |
|
||||
| TestTaintTrackingConfiguration | test.py:50:10:50:29 | ControlFlowNode for emulated_escaping() |
|
||||
| TestTaintTrackingConfiguration | test.py:53:10:53:29 | ControlFlowNode for emulated_escaping() |
|
||||
isSanitizerGuard
|
||||
| TestTaintTrackingConfiguration | test.py:35:8:35:26 | ControlFlowNode for emulated_is_safe() |
|
||||
| TestTaintTrackingConfiguration | test.py:38:8:38:26 | ControlFlowNode for emulated_is_safe() |
|
||||
| TestTaintTrackingConfiguration | test_logical.py:29:8:29:17 | ControlFlowNode for is_safe() |
|
||||
| TestTaintTrackingConfiguration | test_logical.py:44:8:44:17 | ControlFlowNode for is_safe() |
|
||||
| TestTaintTrackingConfiguration | test_logical.py:52:12:52:21 | ControlFlowNode for is_safe() |
|
||||
|
||||
@@ -14,14 +14,17 @@ def emulated_authentication_check(arg):
|
||||
raise Exception("user unauthenticated")
|
||||
|
||||
|
||||
def test_custom_sanitizer():
|
||||
def test_custom_sanitizer_exception():
|
||||
s = TAINTED_STRING
|
||||
|
||||
try:
|
||||
emulated_authentication_check(s)
|
||||
ensure_not_tainted(s)
|
||||
except:
|
||||
pass
|
||||
ensure_tainted(s) # $ tainted
|
||||
raise
|
||||
|
||||
ensure_not_tainted(s)
|
||||
|
||||
|
||||
def emulated_is_safe(arg):
|
||||
@@ -34,11 +37,11 @@ def test_custom_sanitizer_guard():
|
||||
|
||||
if emulated_is_safe(s):
|
||||
ensure_not_tainted(s)
|
||||
s = TAINTED_STRING
|
||||
ensure_tainted(s) # $ tainted
|
||||
else:
|
||||
ensure_tainted(s) # $ tainted
|
||||
|
||||
ensure_tainted(s) # $ tainted
|
||||
|
||||
|
||||
def emulated_escaping(arg):
|
||||
return arg.replace("<", "?").replace(">", "?").replace("'", "?").replace("\"", "?")
|
||||
@@ -53,6 +56,9 @@ def test_escape():
|
||||
|
||||
# Make tests runable
|
||||
|
||||
test_custom_sanitizer()
|
||||
try:
|
||||
test_custom_sanitizer_exception()
|
||||
except Exception:
|
||||
pass
|
||||
test_custom_sanitizer_guard()
|
||||
test_escape()
|
||||
|
||||
Reference in New Issue
Block a user