First step to fix the solc_args option

pull/553/head
Maxime Biais 6 years ago
parent 3d463c25d1
commit b51eee3605
No known key found for this signature in database
GPG Key ID: F3EA910F71E3C894
  1. 2
      mythril/mythril.py
  2. 10
      mythril/support/signatures.py

@ -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_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([i for i in solc_args.split(" ") if i != ""])
try:
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()

Loading…
Cancel
Save