Adds SlitherException instead of tracking error in dict.

pull/348/head
rajeevgopalakrishna 5 years ago
parent 0907fb5006
commit 1af9e02716
  1. 20
      slither/tools/upgradeability/__main__.py
  2. 7
      slither/tools/upgradeability/compare_variables_order.py

@ -7,6 +7,7 @@ import os
from slither import Slither
from slither.utils.colors import red, yellow, set_colorization_enabled
from crytic_compile import cryticparser
from slither.exceptions import SlitherException
from .compare_variables_order import compare_variables_order_implementation, compare_variables_order_proxy
from .compare_function_ids import compare_function_ids
@ -106,13 +107,24 @@ def main():
else:
v2 = Slither(args.new_version, **vars(args))
v2_name = v1_name if not args.new_contract_name else args.new_contract_name
json_results['check-initialization-v2'] = check_initialization(v2)
json_results['compare-function-ids'] = compare_function_ids(v2, v2_name, proxy, proxy_name)
results = compare_variables_order_proxy(v2, v2_name, proxy, proxy_name)
output_error = results.get('output-error', '')
results = {}
output_error = ''
try:
results = compare_variables_order_proxy(v2, v2_name, proxy, proxy_name)
except SlitherException as se:
output_error = str(se)
json_results['compare-variables-order-proxy'] = results
results = compare_variables_order_implementation(v1, v1_name, v2, v2_name)
output_error += results.get('output-error', '')
try:
results = compare_variables_order_implementation(v1, v1_name, v2, v2_name)
except SlitherException as se:
output_error += str(se)
json_results['compare-variables-order-implementation'] = results
if output_error == '':

@ -5,6 +5,7 @@ import logging
from slither import Slither
from slither.utils.function import get_function_id
from slither.utils.colors import red, green, yellow
from slither.exceptions import SlitherException
logger = logging.getLogger("VariablesOrder")
logger.setLevel(logging.INFO)
@ -71,15 +72,13 @@ def compare_variables_order_proxy(implem, implem_name, proxy, proxy_name):
if contract_implem is None:
info = 'Contract {} not found in {}'.format(implem_name, implem.filename)
logger.info(red(info))
results['output-error'] = info
return results
raise SlitherException(info)
contract_proxy = proxy.get_contract_from_name(proxy_name)
if contract_proxy is None:
info = 'Contract {} not found in {}'.format(proxy_name, proxy.filename)
logger.info(red(info))
results['output-error'] = info
return results
raise SlitherException(info)
order_implem = [(variable.name, variable.type) for variable in contract_implem.state_variables if not variable.is_constant]
order_proxy = [(variable.name, variable.type) for variable in contract_proxy.state_variables if not variable.is_constant]

Loading…
Cancel
Save