Merge pull request #553 from maxme/issue/fix-solc-args-option

Fix a couple of issues with the solc-args option
pull/558/head
Nikhil Parasaram 6 years ago committed by GitHub
commit 0e7b853270
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      mythril/ether/util.py
  2. 2
      mythril/mythril.py
  3. 10
      mythril/support/signatures.py

@ -18,10 +18,17 @@ def safe_decode(hex_encoded_string):
def get_solc_json(file, solc_binary="solc", solc_args=None):
cmd = [solc_binary, "--combined-json", "bin,bin-runtime,srcmap,srcmap-runtime", '--allow-paths', "."]
cmd = [solc_binary, "--combined-json", "bin,bin-runtime,srcmap,srcmap-runtime"]
if solc_args:
cmd.extend(solc_args.split(" "))
cmd.extend(solc_args.split())
if not "--allow-paths" in cmd:
cmd.extend(["--allow-paths", "."])
else:
for i, arg in enumerate(cmd):
if arg == "--allow-paths":
cmd[i + 1] += ",."
cmd.append(file)

@ -317,7 +317,7 @@ class Mythril(object):
try:
# import signatures from solidity source
self.sigs.import_from_solidity_source(file)
self.sigs.import_from_solidity_source(file, solc_binary=self.solc_binary, solc_args=self.solc_args)
# Save updated function signatures
self.sigs.write() # dump signatures to disk (previously opened file or default location)

@ -177,13 +177,13 @@ class SignatureDb(object):
"""
return self.get(sighash=item)
def import_from_solidity_source(self, file_path):
def import_from_solidity_source(self, file_path, solc_binary="solc", solc_args=None):
"""
Import Function Signatures from solidity source files
:param file_path: solidity source code file path
:return: self
"""
self.signatures.update(SignatureDb.get_sigs_from_file(file_path))
self.signatures.update(SignatureDb.get_sigs_from_file(file_path, solc_binary=solc_binary, solc_args=solc_args))
return self
@staticmethod
@ -206,13 +206,15 @@ class SignatureDb(object):
proxies=proxies))
@staticmethod
def get_sigs_from_file(file_name):
def get_sigs_from_file(file_name, solc_binary="solc", solc_args=None):
"""
:param file_name: accepts a filename
:return: their signature mappings
"""
sigs = {}
cmd = ["solc", "--hashes", file_name]
cmd = [solc_binary, "--hashes", file_name]
if solc_args:
cmd.extend(solc_args.split())
try:
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()

Loading…
Cancel
Save