mirror of https://github.com/crytic/slither
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.2 KiB
29 lines
1.2 KiB
from ..utils.patches import create_patch
|
|
|
|
class FormatUnusedState:
|
|
|
|
@staticmethod
|
|
def format(slither, patches, elements):
|
|
for element in elements:
|
|
if element['type'] == "variable":
|
|
FormatUnusedState.create_patch(slither, patches,
|
|
element['source_mapping']['filename_absolute'],
|
|
element['source_mapping']['filename_relative'],
|
|
element['source_mapping']['start'])
|
|
|
|
@staticmethod
|
|
def create_patch(slither, patches, in_file, in_file_relative, modify_loc_start):
|
|
in_file_str = slither.source_code[in_file].encode('utf-8')
|
|
old_str_of_interest = in_file_str[modify_loc_start:]
|
|
old_str = old_str_of_interest.decode('utf-8').partition(';')[0]\
|
|
+ old_str_of_interest.decode('utf-8').partition(';')[1]
|
|
create_patch(patches,
|
|
"unused-state",
|
|
in_file_relative,
|
|
in_file,
|
|
int(modify_loc_start),
|
|
int(modify_loc_start + len(old_str_of_interest.decode('utf-8').partition(';')[0]) + 1),
|
|
old_str,
|
|
"")
|
|
|
|
|
|
|