From 9ee0014a1bd4f1db1364ec8a5a3eba94f49784f9 Mon Sep 17 00:00:00 2001 From: Nikhil Parasaram Date: Wed, 31 Oct 2018 22:40:13 +0530 Subject: [PATCH 1/2] Pass solc binary to other functions --- mythril/ether/soliditycontract.py | 10 +++++----- mythril/mythril.py | 9 +++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/mythril/ether/soliditycontract.py b/mythril/ether/soliditycontract.py index 14995b8b..da142c71 100644 --- a/mythril/ether/soliditycontract.py +++ b/mythril/ether/soliditycontract.py @@ -25,18 +25,18 @@ class SourceCodeInfo: self.code = code -def get_contracts_from_file(input_file, solc_args=None): - data = get_solc_json(input_file, solc_args=solc_args) +def get_contracts_from_file(input_file, solc_args=None, solc_binary="solc"): + data = get_solc_json(input_file, solc_args=solc_args, solc_binary=solc_binary) for key, contract in data["contracts"].items(): filename, name = key.split(":") if filename == input_file and len(contract["bin-runtime"]): - yield SolidityContract(input_file, name, solc_args) + yield SolidityContract(input_file=input_file, name=name, solc_args=solc_args, solc_binary=solc_binary) class SolidityContract(ETHContract): - def __init__(self, input_file, name=None, solc_args=None): + def __init__(self, input_file, name=None, solc_args=None, solc_binary="solc"): - data = get_solc_json(input_file, solc_args=solc_args) + data = get_solc_json(input_file, solc_args=solc_args, solc_binary=solc_binary) self.solidity_files = [] diff --git a/mythril/mythril.py b/mythril/mythril.py index d5dbd76f..728f47c6 100644 --- a/mythril/mythril.py +++ b/mythril/mythril.py @@ -375,13 +375,18 @@ class Mythril(object): if contract_name is not None: contract = SolidityContract( - file, contract_name, solc_args=self.solc_args + input_file=file, + name=contract_name, + solc_args=self.solc_args, + solc_binary=self.solc_binary ) self.contracts.append(contract) contracts.append(contract) else: for contract in get_contracts_from_file( - file, solc_args=self.solc_args + input_file=file, + solc_args=self.solc_args, + solc_binary=self.solc_binary ): self.contracts.append(contract) contracts.append(contract) From 973148db669331c8826b5692546e2511e52a079c Mon Sep 17 00:00:00 2001 From: Nikhil Parasaram Date: Wed, 31 Oct 2018 22:47:49 +0530 Subject: [PATCH 2/2] Reformat code with black --- mythril/ether/soliditycontract.py | 7 ++++++- mythril/mythril.py | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mythril/ether/soliditycontract.py b/mythril/ether/soliditycontract.py index da142c71..fdf10fc0 100644 --- a/mythril/ether/soliditycontract.py +++ b/mythril/ether/soliditycontract.py @@ -30,7 +30,12 @@ def get_contracts_from_file(input_file, solc_args=None, solc_binary="solc"): for key, contract in data["contracts"].items(): filename, name = key.split(":") if filename == input_file and len(contract["bin-runtime"]): - yield SolidityContract(input_file=input_file, name=name, solc_args=solc_args, solc_binary=solc_binary) + yield SolidityContract( + input_file=input_file, + name=name, + solc_args=solc_args, + solc_binary=solc_binary, + ) class SolidityContract(ETHContract): diff --git a/mythril/mythril.py b/mythril/mythril.py index 728f47c6..6477d3b2 100644 --- a/mythril/mythril.py +++ b/mythril/mythril.py @@ -378,7 +378,7 @@ class Mythril(object): input_file=file, name=contract_name, solc_args=self.solc_args, - solc_binary=self.solc_binary + solc_binary=self.solc_binary, ) self.contracts.append(contract) contracts.append(contract) @@ -386,7 +386,7 @@ class Mythril(object): for contract in get_contracts_from_file( input_file=file, solc_args=self.solc_args, - solc_binary=self.solc_binary + solc_binary=self.solc_binary, ): self.contracts.append(contract) contracts.append(contract)