Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
| test.py:16 | fail | const_eq_clears_taint | ts |
| test.py:18 | ok | const_eq_clears_taint | ts |
| test.py:24 | fail | const_eq_clears_taint2 | ts |
| test.py:29 | ok | non_const_eq_preserves_taint | ts |
| test.py:31 | ok | non_const_eq_preserves_taint | ts |
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import experimental.dataflow.tainttracking.TestTaintLib
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Add taintlib to PATH so it can be imported during runtime without any hassle
import sys; import os; sys.path.append(os.path.dirname(os.path.dirname((__file__))))
from taintlib import *

# This has no runtime impact, but allows autocomplete to work
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from ..taintlib import *


# Actual tests

def const_eq_clears_taint():
ts = TAINTED_STRING
if ts == "safe":
ensure_not_tainted(ts)
# ts should still be tainted after exiting the if block
ensure_tainted(ts)

def const_eq_clears_taint2():
ts = TAINTED_STRING
if ts != "safe":
return
ensure_not_tainted(ts)

def non_const_eq_preserves_taint(x="foo"):
ts = TAINTED_STRING
if ts == ts:
ensure_tainted(ts)
if ts == x:
ensure_tainted(ts)


# Make tests runable

const_eq_clears_taint()
const_eq_clears_taint2()
non_const_eq_preserves_taint()