Verified Commit 0bc2e7d6 authored by Sebastian Endres's avatar Sebastian Endres
Browse files

Print input files table on run() not in __init__()

parent 520e22f2
......@@ -131,35 +131,6 @@ class PlotCli:
self.traces = list[Trace]()
cprint(f"Plotting {len(trace_triples)} traces", color="cyan", attrs=["bold"])
table = prettytable.PrettyTable()
table.hrules = prettytable.FRAME
table.vrules = prettytable.ALL
table.field_names = [
colored("left traces", color="cyan", attrs=["bold"]),
colored("right traces", color="cyan", attrs=["bold"]),
colored("keylog file", color="cyan", attrs=["bold"]),
]
for i, trace_triple in enumerate(trace_triples):
table.add_row(
[
colored(
str(create_relpath(trace_triple.left_pcap_path)),
attrs=["bold"] if i == 0 else None,
),
colored(
str(create_relpath(trace_triple.right_pcap_path)),
attrs=["bold"] if i == 0 else None,
),
create_relpath(trace_triple.keylog_path)
if trace_triple.keylog_path
else colored("-", color="grey"),
]
)
print(table)
for trace_triple in trace_triples:
left_trace = Trace(
file=trace_triple.left_pcap_path,
......@@ -905,6 +876,37 @@ class PlotCli:
def run(self):
"""Run command line interface."""
cprint(f"Plotting {len(self.traces)} traces", color="cyan", attrs=["bold"])
table = prettytable.PrettyTable()
table.hrules = prettytable.FRAME
table.vrules = prettytable.ALL
table.field_names = [
colored("left traces", color="cyan", attrs=["bold"]),
colored("right traces", color="cyan", attrs=["bold"]),
colored("keylog file", color="cyan", attrs=["bold"]),
]
for i, right_trace in enumerate(self.traces):
assert right_trace.pair_trace
table.add_row(
[
colored(
str(create_relpath(right_trace.pair_trace.input_file)),
attrs=["bold"] if i == 0 else None,
),
colored(
str(create_relpath(right_trace.input_file)),
attrs=["bold"] if i == 0 else None,
),
create_relpath(right_trace.keylog_file)
if right_trace.keylog_file
else colored("-", color="grey"),
]
)
print(table)
mapping = {
PlotMode.OFFSET_NUMBER: {
"callback": self.plot_offset_number,
......
......@@ -131,8 +131,22 @@ class Trace:
"Trace"
] = None # Trace for the other side (left / right)
@property
def input_file(self) -> Path:
return Path(self._cap.input_filename)
@property
def keylog_file(self) -> Optional[Path]:
keylog_file = self._cap._override_prefs.get("ssl.keylog_file")
if keylog_file:
return Path(keylog_file)
else:
return None
def __str__(self):
trace_file_name = Path(self._cap.input_filename).name
trace_file_name = self.input_file.name
if self._keylog_file:
return f'<Trace {trace_file_name} "{self._display_filter}" ({self._keylog_file})>'
......@@ -154,7 +168,7 @@ class Trace:
else:
# 2. use cmd tool to determine the cap length
output = subprocess.check_output(
("capinfos", "-r", "-B", "-T", "-c", self._cap.input_filename),
("capinfos", "-r", "-B", "-T", "-c", self.input_file),
text=True,
).strip()
......@@ -194,7 +208,7 @@ class Trace:
return self._packets
input_file_rel_path = create_relpath(Path(self._cap.input_filename))
input_file_rel_path = create_relpath(self.input_file)
with YaspinWrapper(
debug=self.debug,
text=f"Loading {input_file_rel_path}",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment