Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax detection of initialization functions #853

Merged
merged 2 commits into from
May 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion slither/tools/upgradeability/checks/initialization.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging

from slither.core.declarations import Function
from slither.slithir.operations import InternalCall
from slither.tools.upgradeability.checks.abstract_checks import (
AbstractCheck,
Expand All @@ -14,8 +15,18 @@ class MultipleInitTarget(Exception):
pass


def _has_initiliaze_modifier(function: Function):
if not function.modifiers:
return False
return any((m.name == "initializer") for m in function.modifiers)


def _get_initialize_functions(contract):
return [f for f in contract.functions if f.name == "initialize" and f.is_implemented]
return [
f
for f in contract.functions
if (f.name == "initialize" or _has_initiliaze_modifier(f)) and f.is_implemented
]


def _get_all_internal_calls(function):
Expand Down