Skip to content

Commit

Permalink
Perform a nesting decoding (#1754)
Browse files Browse the repository at this point in the history
* Perform a nesting decoding

* Remove unwanted statement
  • Loading branch information
norhh committed Apr 5, 2023
1 parent 4c16585 commit c0e8b67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 10 additions & 5 deletions mythril/analysis/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ def add_code_info(self, contract):
else:
self.source_mapping = self.address

@staticmethod
def decode_bytes(val):
if isinstance(val, bytes):
return val.decode()
elif isinstance(val, list) or isinstance(val, tuple):
return [Issue.decode_bytes(x) for x in val]
else:
return val

def resolve_function_names(self):
"""Resolves function names for each step"""

Expand All @@ -197,11 +206,7 @@ def resolve_function_names(self):
if step["resolved_input"] is not None:
step["resolved_input"] = list(step["resolved_input"])
for i, val in enumerate(step["resolved_input"]):
if type(val) != bytes:
continue
# Some of the bytes violate UTF-8 and UTF-16 translates the input to Japanese
# We cannot directly use bytes, as it's not serialisable using JSON, hence this hack.
step["resolved_input"][i] = str(step["resolved_input"][i])
step["resolved_input"][i] = Issue.decode_bytes(val)

step["resolved_input"] = tuple(step["resolved_input"])

Expand Down
1 change: 1 addition & 0 deletions mythril/interfaces/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ def execute_command(
else None,
transaction_count=args.transaction_count,
)

outputs = {
"json": report.as_json(),
"jsonv2": report.as_swc_standard_format(),
Expand Down

0 comments on commit c0e8b67

Please sign in to comment.