Files
codeql/python/ql/test/library-tests/dataflow/exceptions/test.py
2024-04-23 09:40:44 +02:00

36 lines
715 B
Python

import sys
import os
sys.path.append(os.path.dirname(os.path.dirname((__file__))))
from testlib import expects
# These are defined so that we can evaluate the test code.
NONSOURCE = "not a source"
SOURCE = "source"
def is_source(x):
return x == "source" or x == b"source" or x == 42 or x == 42.0 or x == 42j
def SINK(x):
if is_source(x):
print("OK")
else:
print("Unexpected flow", x)
def SINK_F(x):
if is_source(x):
print("Unexpected flow", x)
else:
print("OK")
def test_as_binding():
try:
e_with_source = Exception()
e_with_source.a = SOURCE
raise e_with_source
except Exception as e:
SINK(e.a) # $ MISSING: flow