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