Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add memcheck tests for the new splitter aspects #9146

Merged
merged 4 commits into from
May 2, 2024
Merged
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
50 changes: 47 additions & 3 deletions tests/appsec/iast/fixtures/propagation_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
make some changes
"""
import os
import sys


ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
Expand Down Expand Up @@ -114,25 +115,68 @@ def propagation_path_5_prop(origin_string1, tainted_string_2):


def propagation_memory_check(origin_string1, tainted_string_2):
import os.path

if type(origin_string1) is str:
string1 = str(origin_string1) # 1 Range
else:
string1 = str(origin_string1, encoding="utf-8") # 1 Range
# string1 = taintsource
if type(tainted_string_2) is str:
string2 = str(tainted_string_2) # 1 Range
else:
string2 = str(tainted_string_2, encoding="utf-8") # 1 Range
# string2 = taintsource2
string3 = string1 + string2 # 2 Ranges
# taintsource1taintsource2
string4 = "-".join([string3, string3, string3]) # 6 Ranges
# taintsource1taintsource2-taintsource1taintsource2-taintsource1taintsource2
string5 = string4[0 : (len(string4) - 1)]
# taintsource1taintsource2-taintsource1taintsource2-taintsource1taintsource
string6 = string5.title()
# Taintsource1Taintsource2-Taintsource1Taintsource2-Taintsource1Taintsource
string7 = string6.upper()
# TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE
string8 = "%s_notainted" % string7
string9 = "notainted_{}".format(string8)
# TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE_notainted
string9 = "notainted#{}".format(string8)
# notainted#TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE_notainted
string10 = string9.split("#")[1]
# TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE_notainted
string11 = "notainted#{}".format(string10)
# TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE_notainted
string12 = string11.rsplit("#")[1]
string13 = string12 + "\n" + "notainted"
# TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE_notainted\nnotainted
string14 = string13.splitlines()[0] # string14 = string12
# TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE_notainted
string15 = os.path.join("foo", "bar", string14)
# /foo/bar/TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE_notainted
string16 = os.path.split(string15)[1]
# TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE_notainted
string17 = string16 + ".jpg"
# TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE_notainted.jpg
string18 = os.path.splitext(string17)[0]
# TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE_notainted
string19 = os.path.join(os.sep + string18, "nottainted_notdir")
# /TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE_notainted/nottainted_notdir
string20 = os.path.dirname(string19)
# /TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE_notainted
string21 = os.path.basename(string20)
# TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE_notainted

if sys.version_info >= (3, 12):
string22 = os.sep + string21
# /TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE_notainted
string23 = os.path.splitroot(string22)[2]
# TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE2-TAINTSOURCE1TAINTSOURCE_notainted
else:
string23 = string21

try:
# label propagation_memory_check
m = open(ROOT_DIR + "/" + string9 + ".txt")
m = open(ROOT_DIR + "/" + string23 + ".txt")
_ = m.read()
except Exception:
pass
return string9
return string23
Loading