Remove references to xrefs command

pull/94/head
Bernhard Mueller 7 years ago
parent bf8301b66b
commit c8e0f73aea
  1. 11
      myth
  2. 17
      mythril/ether/ethcontract.py
  3. 10
      tests/ethcontract_test.py

11
myth

@ -72,7 +72,6 @@ database.add_argument('--init-db', action='store_true', help='initialize the con
database.add_argument('-s', '--search', help='search the contract database', metavar='EXPRESSION') database.add_argument('-s', '--search', help='search the contract database', metavar='EXPRESSION')
utilities = parser.add_argument_group('utilities') utilities = parser.add_argument_group('utilities')
utilities.add_argument('--xrefs', action='store_true', help='get xrefs from a contract')
utilities.add_argument('--hash', help='calculate function signature hash', metavar='SIGNATURE') utilities.add_argument('--hash', help='calculate function signature hash', metavar='SIGNATURE')
utilities.add_argument('--storage', help='read state variables from storage index, use with -a', metavar='INDEX,NUM_SLOTS,[array]') utilities.add_argument('--storage', help='read state variables from storage index, use with -a', metavar='INDEX,NUM_SLOTS,[array]')
utilities.add_argument('--solv', help='specify solidity compiler version. If not present, will try to install it (Experimental)', metavar='SOLV') utilities.add_argument('--solv', help='specify solidity compiler version. If not present, will try to install it (Experimental)', metavar='SOLV')
@ -130,7 +129,7 @@ with open(signatures_file) as f:
# Parse cmdline args # Parse cmdline args
if not (args.search or args.init_db or args.hash or args.disassemble or args.graph or args.xrefs or args.fire_lasers or args.storage or args.truffle): if not (args.search or args.init_db or args.hash or args.disassemble or args.graph or args.fire_lasers or args.storage or args.truffle):
parser.print_help() parser.print_help()
sys.exit() sys.exit()
@ -202,12 +201,10 @@ if args.address or args.init_db:
else: else:
try: try:
host, port = args.rpc.split(":") host, port = args.rpc.split(":")
rpcconfig = (host, port, args.rpctls) rpcconfig = (host, int(port), args.rpctls)
except ValueError: except ValueError:
exitWithError(args.outform, "Invalid RPC argument, use HOST:PORT") exitWithError(args.outform, "Invalid RPC argument, use 'ganache', 'infura-[network]' or 'HOST:PORT'")
rpcconfig = (host, int(port), args.tls)
if (rpcconfig): if (rpcconfig):
@ -352,8 +349,6 @@ elif args.disassemble:
easm_text = contracts[0].get_easm() easm_text = contracts[0].get_easm()
sys.stdout.write(easm_text) sys.stdout.write(easm_text)
elif args.xrefs:
print("\n".join(contracts[0].get_xrefs()))
elif args.graph or args.fire_lasers: elif args.graph or args.fire_lasers:
if not contracts: if not contracts:

@ -29,23 +29,6 @@ class ETHContract(persistent.Persistent):
'disassembly': self.disassembly 'disassembly': self.disassembly
} }
def get_xrefs(self):
instruction_list = Disassembly(self.code).instruction_list
xrefs = []
for instruction in instruction_list:
if instruction['opcode'] == "PUSH20":
if instruction['argument']:
addr = instruction['argument']
if (re.match(r'^0x[a-zA-Z0-9]{40}$', addr) and addr != "0xffffffffffffffffffffffffffffffffffffffff"):
if addr not in xrefs:
xrefs.append(addr)
return xrefs
def get_easm(self): def get_easm(self):
return Disassembly(self.code).get_easm() return Disassembly(self.code).get_easm()

@ -36,13 +36,3 @@ class MatchesExpressionTestCase(ETHContractTestCase):
self.assertTrue(contract.matches_expression("code#PUSH1# or code#PUSH1#"),'Unexpected result in expression matching') self.assertTrue(contract.matches_expression("code#PUSH1# or code#PUSH1#"),'Unexpected result in expression matching')
self.assertFalse(contract.matches_expression("func#abcdef#"),'Unexpected result in expression matching') self.assertFalse(contract.matches_expression("func#abcdef#"),'Unexpected result in expression matching')
class GetXrefsTestCase(ETHContractTestCase):
def runTest(self):
contract = ETHContract(self.code)
xrefs = contract.get_xrefs()
self.assertEqual(xrefs[0], "0xc3b2ae46792547a96b9f84405e36d0e07edcd05c", 'Error getting xrefs from contract')
Loading…
Cancel
Save