Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' into refactor-events
* master:
  Make gas calculation faithfulness configurable (#1279)
  Fix terminated states resurrection (#1326)
  Make is_human a property (#1323)
  added warning and error to sys_arch_prctl (#1319)
  • Loading branch information
disconnect3d committed Jan 8, 2019
2 parents 913dbd5 + c9eb624 commit 19feb3d
Show file tree
Hide file tree
Showing 24 changed files with 1,580 additions and 1,340 deletions.
10 changes: 5 additions & 5 deletions manticore/ethereum/detectors.py
Expand Up @@ -217,7 +217,7 @@ def _context_key(self):
return f'{self.name}.call_locations'

def will_open_transaction_callback(self, state, tx):
if tx.is_human():
if tx.is_human:
state.context[self._context_key] = []

def will_execute_instruction_callback(self, state, instruction, arguments):
Expand Down Expand Up @@ -277,14 +277,14 @@ def _read_storage_name(self):

def will_open_transaction_callback(self, state, tx):
# Reset reading log on new human transactions
if tx.is_human():
if tx.is_human:
state.context[self._read_storage_name] = set()
state.context['{:s}.locations'.format(self.name)] = dict()

def did_close_transaction_callback(self, state, tx):
world = state.platform
#Check if it was an internal tx
if not tx.is_human():
if not tx.is_human:
# Check is the tx was successful
if tx.result:
# Check if gas was enough for a reentrancy attack
Expand Down Expand Up @@ -482,7 +482,7 @@ def did_execute_instruction_callback(self, state, instruction, arguments, result
self._check_finding(state, what)
elif mnemonic == 'RETURN':
world = state.platform
if world.current_transaction.is_human():
if world.current_transaction.is_human:
# If an overflowded value is returned to a human
offset, size = arguments
data = world.current_vm.read_buffer(offset, size)
Expand Down Expand Up @@ -528,7 +528,7 @@ def _get_retval_taints(self, state):

def will_open_transaction_callback(self, state, tx):
# Reset reading log on new human transactions
if tx.is_human():
if tx.is_human:
state.context[self._stack_name] = []
state.context[self._stack_name].append(set())

Expand Down
32 changes: 25 additions & 7 deletions manticore/ethereum/manticore.py
Expand Up @@ -429,27 +429,45 @@ def _all_state_ids(self):

@property
def running_states(self):
""" Iterates over the running states"""
"""
Iterates over running states giving the possibility to change state data.
The state data change must be done in a loop, e.g. `for state in running_states: ...`
as we re-save the state when the generator comes back to the function.
This means it is not possible to change the state used by Manticore with `states = list(m.running_states)`.
"""
for state_id in self._running_state_ids:
state = self.load(state_id)
yield state
self.save(state, state_id=state_id) # overwrite old
# Re-save the state in case the user changed its data
self.save(state, state_id=state_id)

@property
def terminated_states(self):
""" Iterates over the terminated states"""
"""
Iterates over the terminated states.
See also `running_states`.
"""
for state_id in self._terminated_state_ids:
state = self.load(state_id)
yield state
self.save(state, state_id=state_id) # overwrite old
# Re-save the state in case the user changed its data
self.save(state, state_id=state_id, final=True)

@property
def all_states(self):
""" Iterates over the all states (terminated and alive)"""
"""
Iterates over the all states (running and terminated)
See also `running_states`.
"""
for state_id in self._all_state_ids:
state = self.load(state_id)
yield state
self.save(state, state_id=state_id) # overwrite old
# Re-save the state in case the user changed its data
self.save(state, state_id=state_id, final=state_id in self._terminated_state_ids)

def count_states(self):
""" Total states count """
Expand Down Expand Up @@ -1175,7 +1193,7 @@ def _terminate_state_callback(self, state, state_id, e):

#we initiated the Tx; we need process the outcome for now.
#Fixme incomplete.
if tx.is_human():
if tx.is_human:
if tx.sort == 'CREATE':
if tx.result == 'RETURN':
world.set_code(tx.address, tx.return_data)
Expand Down

0 comments on commit 19feb3d

Please sign in to comment.