Skip to content

Commit 6e5599b

Browse files
committed
Add the taint_output flag
1 parent 91f738e commit 6e5599b

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/crashd/dwarf/dwarf_source_code.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ def show_tainted_source(zelos, binary_path, trace, taint_path):
326326
zelos.config.source_code_path,
327327
)
328328

329-
# The remaining is debug-only output
330-
return
329+
if not zelos.config.taint_output == "terminal":
330+
return
331331

332332
# print("generated .zcov file")
333333
crash_line = None
@@ -339,23 +339,22 @@ def show_tainted_source(zelos, binary_path, trace, taint_path):
339339
source_path[(file, line)] = v
340340
if file in files:
341341
if crash_line is None:
342-
new_line = colored(
342+
files[file][line] = colored(
343343
# f"!0x{k:x}" +
344344
files[file][line] + str(v) + "\n",
345345
color="red",
346346
)
347347
crash_line = line
348348
changed_file_lines[file].append(line)
349349
else:
350-
new_line = colored(
350+
files[file][line] = colored(
351351
# f"*0x{k:x}" +
352352
files[file][line] + str(v) + "\n",
353353
color="white",
354354
attrs=["bold"],
355355
)
356356
changed_file_lines[file].append(line)
357357

358-
files[file][line] = new_line
359358
# print("Updated source lines with data flow")
360359
count = 0
361360
# Get first trace line that is in the source
@@ -405,10 +404,11 @@ def show_tainted_source(zelos, binary_path, trace, taint_path):
405404
i += 1
406405
if lines_to_print[-1] != "...\n":
407406
lines_to_print.append("...\n")
408-
# print("".join(lines_to_print))
407+
print("".join(lines_to_print))
408+
409409
# print("Changed lines: ")
410-
# print(changed_lines)
411-
# print("Num lines: ", len(changed_lines))
410+
# print(changed_file_lines)
411+
# print("Num lines: ", len(changed_file_lines))
412412

413413

414414
def process_file(filename, zelos_module_base):

src/crashd/taint/taint.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@
5454
help="Starts taint tracking when the specified ZML condition is met.",
5555
)
5656

57+
CommandLineOption(
58+
"taint_output", default="", help="Specify taint output location.",
59+
)
60+
5761
CommandLineOption(
5862
"source_code_path", default="", help="path to search for source code files"
5963
)

0 commit comments

Comments
 (0)