Fix false positives on constructor (#1729)

pull/1730/head
Nikhil Parasaram 2 years ago committed by GitHub
parent c309a2b46e
commit b509a2c1cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      mythril/analysis/module/modules/external_calls.py
  2. 4
      mythril/analysis/module/modules/state_change_external_calls.py
  3. 6
      mythril/analysis/report.py

@ -71,6 +71,9 @@ class ExternalCalls(DetectionModule):
:param state:
:return:
"""
if state.environment.active_function_name == "constructor":
return []
gas = state.mstate.stack[-1]
to = state.mstate.stack[-2]

@ -42,6 +42,7 @@ class StateChangeCallsAnnotation(StateAnnotation):
def get_issue(
self, global_state: GlobalState, detector: DetectionModule
) -> Optional[PotentialIssue]:
if not self.state_change_states:
return None
constraints = Constraints()
@ -146,6 +147,9 @@ class StateChangeAfterCall(DetectionModule):
def _analyze_state(self, global_state: GlobalState) -> List[PotentialIssue]:
if global_state.environment.active_function_name == "constructor":
return []
annotations = cast(
List[StateChangeCallsAnnotation],
list(global_state.get_annotations(StateChangeCallsAnnotation)),

@ -146,11 +146,7 @@ class Issue:
"""
if self.address and isinstance(contract, SolidityContract):
is_constructor = False
if (
contract.creation_code
in self.transaction_sequence["steps"][-1]["input"]
and self.function == "constructor"
):
if self.function == "constructor":
is_constructor = True
if self.source_location:

Loading…
Cancel
Save