Added --txnocoverage option to manticore cli (#849)
* added txnocoverage option to manticore cli * improved code readability
This commit is contained in:
parent
d5a692fc59
commit
aa792588fe
@ -65,6 +65,9 @@ def parse_arguments():
|
|||||||
parser.add_argument('--txlimit', type=positive,
|
parser.add_argument('--txlimit', type=positive,
|
||||||
help='Maximum number of symbolic transactions to run (positive integer) (Ethereum only)')
|
help='Maximum number of symbolic transactions to run (positive integer) (Ethereum only)')
|
||||||
|
|
||||||
|
parser.add_argument('--txnocoverage', action='store_true',
|
||||||
|
help='Do not use coverage as stopping criteria (Ethereum only)')
|
||||||
|
|
||||||
parser.add_argument('--txaccount', type=str, default="attacker",
|
parser.add_argument('--txaccount', type=str, default="attacker",
|
||||||
help='Account used as caller in the symbolic transactions, either "attacker" or "owner" (Ethereum only)')
|
help='Account used as caller in the symbolic transactions, either "attacker" or "owner" (Ethereum only)')
|
||||||
|
|
||||||
@ -96,7 +99,7 @@ def ethereum_cli(args):
|
|||||||
|
|
||||||
logger.info("Beginning analysis")
|
logger.info("Beginning analysis")
|
||||||
|
|
||||||
m.multi_tx_analysis(args.argv[0], args.contract, args.txlimit, args.txaccount)
|
m.multi_tx_analysis(args.argv[0], args.contract, args.txlimit, not args.txnocoverage, args.txaccount)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
@ -981,7 +981,7 @@ class ManticoreEVM(Manticore):
|
|||||||
|
|
||||||
return status
|
return status
|
||||||
|
|
||||||
def multi_tx_analysis(self, solidity_filename, contract_name=None, tx_limit=None, tx_account="attacker"):
|
def multi_tx_analysis(self, solidity_filename, contract_name=None, tx_limit=None, tx_use_coverage=True, tx_account="attacker"):
|
||||||
with open(solidity_filename) as f:
|
with open(solidity_filename) as f:
|
||||||
source_code = f.read()
|
source_code = f.read()
|
||||||
|
|
||||||
@ -1007,7 +1007,7 @@ class ManticoreEVM(Manticore):
|
|||||||
prev_coverage = 0
|
prev_coverage = 0
|
||||||
current_coverage = 0
|
current_coverage = 0
|
||||||
|
|
||||||
while current_coverage < 100:
|
while current_coverage < 100 or not tx_use_coverage:
|
||||||
try:
|
try:
|
||||||
run_symbolic_tx()
|
run_symbolic_tx()
|
||||||
except NoAliveStates:
|
except NoAliveStates:
|
||||||
@ -1018,12 +1018,13 @@ class ManticoreEVM(Manticore):
|
|||||||
if tx_limit == 0:
|
if tx_limit == 0:
|
||||||
break
|
break
|
||||||
|
|
||||||
prev_coverage = current_coverage
|
if tx_use_coverage:
|
||||||
current_coverage = self.global_coverage(contract_account)
|
prev_coverage = current_coverage
|
||||||
found_new_coverage = prev_coverage < current_coverage
|
current_coverage = self.global_coverage(contract_account)
|
||||||
|
found_new_coverage = prev_coverage < current_coverage
|
||||||
|
|
||||||
if not found_new_coverage:
|
if not found_new_coverage:
|
||||||
break
|
break
|
||||||
|
|
||||||
self.finalize()
|
self.finalize()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user