From a25932c9e39d8b231553a896434daf4fc793970f Mon Sep 17 00:00:00 2001 From: Bernhard Mueller Date: Sun, 1 Oct 2017 11:13:46 +0700 Subject: [PATCH] Change default db dir and add option to change it --- {ether => mythril}/__init__.py | 0 {rpc => mythril/ether}/__init__.py | 0 {ether => mythril/ether}/asm.py | 0 {ether => mythril/ether}/contractstorage.py | 4 ++-- {ether => mythril/ether}/ethcontract.py | 0 {ether => mythril/ether}/evm.py | 0 {ether => mythril/ether}/util.py | 2 +- mythril => mythril/mythril | 15 ++++++++------- mythril/rpc/__init__.py | 0 {rpc => mythril/rpc}/client.py | 0 {rpc => mythril/rpc}/constants.py | 0 {rpc => mythril/rpc}/exceptions.py | 0 {rpc => mythril/rpc}/utils.py | 0 setup.py | 4 ++-- 14 files changed, 13 insertions(+), 12 deletions(-) rename {ether => mythril}/__init__.py (100%) rename {rpc => mythril/ether}/__init__.py (100%) rename {ether => mythril/ether}/asm.py (100%) rename {ether => mythril/ether}/contractstorage.py (96%) rename {ether => mythril/ether}/ethcontract.py (100%) rename {ether => mythril/ether}/evm.py (100%) rename {ether => mythril/ether}/util.py (97%) rename mythril => mythril/mythril (93%) create mode 100644 mythril/rpc/__init__.py rename {rpc => mythril/rpc}/client.py (100%) rename {rpc => mythril/rpc}/constants.py (100%) rename {rpc => mythril/rpc}/exceptions.py (100%) rename {rpc => mythril/rpc}/utils.py (100%) diff --git a/ether/__init__.py b/mythril/__init__.py similarity index 100% rename from ether/__init__.py rename to mythril/__init__.py diff --git a/rpc/__init__.py b/mythril/ether/__init__.py similarity index 100% rename from rpc/__init__.py rename to mythril/ether/__init__.py diff --git a/ether/asm.py b/mythril/ether/asm.py similarity index 100% rename from ether/asm.py rename to mythril/ether/asm.py diff --git a/ether/contractstorage.py b/mythril/ether/contractstorage.py similarity index 96% rename from ether/contractstorage.py rename to mythril/ether/contractstorage.py index dc6e800f..110a9ebf 100644 --- a/ether/contractstorage.py +++ b/mythril/ether/contractstorage.py @@ -1,5 +1,5 @@ -from rpc.client import EthJsonRpc -from ether.ethcontract import ETHContract, InstanceList +from mythril.rpc.client import EthJsonRpc +from mythril.ether.ethcontract import ETHContract, InstanceList import hashlib import os import persistent diff --git a/ether/ethcontract.py b/mythril/ether/ethcontract.py similarity index 100% rename from ether/ethcontract.py rename to mythril/ether/ethcontract.py diff --git a/ether/evm.py b/mythril/ether/evm.py similarity index 100% rename from ether/evm.py rename to mythril/ether/evm.py diff --git a/ether/util.py b/mythril/ether/util.py similarity index 97% rename from ether/util.py rename to mythril/ether/util.py index d6234290..4949efc5 100644 --- a/ether/util.py +++ b/mythril/ether/util.py @@ -1,4 +1,4 @@ -from rpc.client import EthJsonRpc +from mythril.rpc.client import EthJsonRpc import codecs from ethereum.abi import encode_abi, encode_int from ethereum.utils import zpad diff --git a/mythril b/mythril/mythril similarity index 93% rename from mythril rename to mythril/mythril index 30c4fd48..e2db4d02 100755 --- a/mythril +++ b/mythril/mythril @@ -4,15 +4,15 @@ http://www.github.com/b-mueller/mythril """ -from ether import asm,evm,util -from ether.contractstorage import get_persistent_storage +from mythril.ether import asm,evm,util +from mythril.ether.contractstorage import get_persistent_storage +from mythril.rpc.client import EthJsonRpc from ethereum import utils import sys import argparse -from rpc.client import EthJsonRpc - import os +DEFAULT_DB_DIR = "~/.mythril" def searchCallback(code_hash, code, addresses, balances): print("Matched contract with code hash " + code_hash ) @@ -41,9 +41,10 @@ parser.add_argument('--sync-all', action='store_true', help='Also sync contracts parser.add_argument('--rpchost', default='127.0.0.1', help='RPC host') parser.add_argument('--rpcport', type=int, default=8545, help='RPC port') - -app_root = os.path.dirname(os.path.realpath(__file__)) -db_dir = os.path.join(app_root, "database") +try: + db_dir = os.environ['DB_DIR'] +except KeyError: + db_dir = DEFAULT_DB_DIR contract_storage = get_persistent_storage(db_dir) diff --git a/mythril/rpc/__init__.py b/mythril/rpc/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/rpc/client.py b/mythril/rpc/client.py similarity index 100% rename from rpc/client.py rename to mythril/rpc/client.py diff --git a/rpc/constants.py b/mythril/rpc/constants.py similarity index 100% rename from rpc/constants.py rename to mythril/rpc/constants.py diff --git a/rpc/exceptions.py b/mythril/rpc/exceptions.py similarity index 100% rename from rpc/exceptions.py rename to mythril/rpc/exceptions.py diff --git a/rpc/utils.py b/mythril/rpc/utils.py similarity index 100% rename from rpc/utils.py rename to mythril/rpc/utils.py diff --git a/setup.py b/setup.py index 9d98af38..6a22cdf8 100755 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ long_description = ''' setup( name='mythril', - version='0.2.3', + version='0.2.4', description='A bug hunting tool framework for the Ethereum blockchain', long_description=long_description, @@ -51,5 +51,5 @@ setup( extras_require={ }, - scripts=['mythril'] + scripts=['mythril/mythril'] )