|
|
@ -224,36 +224,33 @@ class Mythril(object): |
|
|
|
# Figure out solc binary and version |
|
|
|
# Figure out solc binary and version |
|
|
|
# Only proper versions are supported. No nightlies, commits etc (such as available in remix) |
|
|
|
# Only proper versions are supported. No nightlies, commits etc (such as available in remix) |
|
|
|
|
|
|
|
|
|
|
|
if version: |
|
|
|
if not version: |
|
|
|
# tried converting input to semver, seemed not necessary so just slicing for now |
|
|
|
return os.environ.get("SOLC") or "solc" |
|
|
|
if version == str(solc.main.get_solc_version())[:6]: |
|
|
|
|
|
|
|
logging.info("Given version matches installed version") |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
solc_binary = os.environ["SOLC"] |
|
|
|
|
|
|
|
except KeyError: |
|
|
|
|
|
|
|
solc_binary = "solc" |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
if util.solc_exists(version): |
|
|
|
|
|
|
|
logging.info("Given version is already installed") |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
solc.install_solc("v" + version) |
|
|
|
|
|
|
|
except SolcError: |
|
|
|
|
|
|
|
raise CriticalError( |
|
|
|
|
|
|
|
"There was an error when trying to install the specified solc version" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
solc_binary = os.path.join( |
|
|
|
# tried converting input to semver, seemed not necessary so just slicing for now |
|
|
|
os.environ.get("HOME", str(Path.home())), |
|
|
|
main_version = solc.main.get_solc_version_string() |
|
|
|
".py-solc/solc-v" + version, |
|
|
|
main_version_number = re.match(r"\d+.\d+.\d+", main_version) |
|
|
|
"bin/solc", |
|
|
|
if main_version is None: |
|
|
|
) |
|
|
|
raise CriticalError( |
|
|
|
logging.info("Setting the compiler to " + str(solc_binary)) |
|
|
|
"Could not extract solc version from string {}".format(main_version) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
if version == main_version_number: |
|
|
|
|
|
|
|
logging.info("Given version matches installed version") |
|
|
|
|
|
|
|
solc_binary = os.environ.get("SOLC") or "solc" |
|
|
|
else: |
|
|
|
else: |
|
|
|
try: |
|
|
|
solc_binary = util.solc_exists(version) |
|
|
|
solc_binary = os.environ["SOLC"] |
|
|
|
if solc_binary: |
|
|
|
except KeyError: |
|
|
|
logging.info("Given version is already installed") |
|
|
|
solc_binary = "solc" |
|
|
|
else: |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
solc.install_solc("v" + version) |
|
|
|
|
|
|
|
except SolcError: |
|
|
|
|
|
|
|
raise CriticalError( |
|
|
|
|
|
|
|
"There was an error when trying to install the specified solc version" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logging.info("Setting the compiler to %s", solc_binary) |
|
|
|
|
|
|
|
|
|
|
|
return solc_binary |
|
|
|
return solc_binary |
|
|
|
|
|
|
|
|
|
|
|
def set_api_leveldb(self, leveldb): |
|
|
|
def set_api_leveldb(self, leveldb): |
|
|
|