Add --solc-args option

pull/79/head
Bernhard Mueller 7 years ago
parent 62eb0b9677
commit 7c0deddadb
  1. 7
      myth
  2. 4
      mythril/ether/soliditycontract.py
  3. 12
      mythril/ether/util.py

@ -81,6 +81,7 @@ utilities.add_argument('--solv', help='specify solidity compiler version. If not
options = parser.add_argument_group('options')
options.add_argument('--sync-all', action='store_true', help='Also sync contracts with zero balance')
options.add_argument('--max-depth', type=int, default=12, help='Maximum recursion depth for symbolic execution')
options.add_argument('--solc-args', help='Extra arguments for solc')
options.add_argument('--enable-physics', type=bool, default=False, help='enable graph physics simulation')
options.add_argument('-v', type=int, help='log level (0-2)', metavar='LOG_LEVEL')
@ -95,6 +96,8 @@ rpc.add_argument('--infura-ropsten', action='store_true', help='Preset: Infura N
# Get config values
args = parser.parse_args()
try:
mythril_dir = os.environ['MYTHRIL_DIR']
except KeyError:
@ -130,8 +133,6 @@ else:
# Parse cmdline args
args = parser.parse_args()
if not (args.search or args.init_db or args.hash or args.disassemble or args.graph or args.xrefs or args.fire_lasers or args.storage or args.truffle):
parser.print_help()
sys.exit()
@ -293,7 +294,7 @@ elif (len(args.solidity_file)):
try:
signatures.add_signatures_from_file(file, sigs) # Parse file for new function signatures
contract = SolidityContract(file, contract_name)
contract = SolidityContract(file, contract_name, solc_args=args.solc_args)
logging.info("Analyzing contract %s:%s" % (file, contract.name))

@ -20,9 +20,9 @@ class SolidityFile:
class SolidityContract(ETHContract):
def __init__(self, input_file, name=None):
def __init__(self, input_file, name=None, solc_args=None):
data = get_solc_json(input_file)
data = get_solc_json(input_file, solc_args=solc_args)
self.solidity_files = []

@ -16,10 +16,18 @@ def safe_decode(hex_encoded_string):
return bytes.fromhex(hex_encoded_string)
def get_solc_json(file, solc_binary="solc"):
def get_solc_json(file, solc_binary="solc", solc_args=None):
cmd = [solc_binary, "--combined-json", "bin,bin-runtime,srcmap-runtime", '--allow-paths', "."]
if solc_args:
cmd.extend(solc_args.split(" "))
cmd.append(file)
try:
p = Popen([solc_binary, "--combined-json", "bin,bin-runtime,srcmap-runtime", '--allow-paths', ".", file], stdout=PIPE, stderr=PIPE)
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
ret = p.returncode

Loading…
Cancel
Save