Merge pull request #1451 from 0xalpharush/fix/upgradeability-private-immutable

upgradeability: include inherited private variables, ignore immutables
pull/1561/head
Feist Josselin 2 years ago committed by GitHub
commit 250c73e704
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      slither/tools/upgradeability/checks/variable_initialization.py
  2. 36
      slither/tools/upgradeability/checks/variables_order.py

@ -39,8 +39,8 @@ Using initialize functions to write initial values in state variables.
def _check(self):
results = []
for s in self.contract.state_variables:
if s.initialized and not s.is_constant:
for s in self.contract.state_variables_ordered:
if s.initialized and not (s.is_constant or s.is_immutable):
info = [s, " is a state variable with an initial value.\n"]
json = self.generate_result(info)
results.append(json)

@ -48,8 +48,16 @@ Do not change the order of the state variables in the updated contract.
def _check(self):
contract1 = self.contract
contract2 = self.contract_v2
order1 = [variable for variable in contract1.state_variables if not variable.is_constant]
order2 = [variable for variable in contract2.state_variables if not variable.is_constant]
order1 = [
variable
for variable in contract1.state_variables_ordered
if not (variable.is_constant or variable.is_immutable)
]
order2 = [
variable
for variable in contract2.state_variables_ordered
if not (variable.is_constant or variable.is_immutable)
]
results = []
for idx, _ in enumerate(order1):
@ -109,8 +117,16 @@ Avoid variables in the proxy. If a variable is in the proxy, ensure it has the s
def _check(self):
contract1 = self._contract1()
contract2 = self._contract2()
order1 = [variable for variable in contract1.state_variables if not variable.is_constant]
order2 = [variable for variable in contract2.state_variables if not variable.is_constant]
order1 = [
variable
for variable in contract1.state_variables_ordered
if not (variable.is_constant or variable.is_immutable)
]
order2 = [
variable
for variable in contract2.state_variables_ordered
if not (variable.is_constant or variable.is_immutable)
]
results = []
for idx, _ in enumerate(order1):
@ -228,8 +244,16 @@ Avoid variables in the proxy. If a variable is in the proxy, ensure it has the s
def _check(self):
contract1 = self._contract1()
contract2 = self._contract2()
order1 = [variable for variable in contract1.state_variables if not variable.is_constant]
order2 = [variable for variable in contract2.state_variables if not variable.is_constant]
order1 = [
variable
for variable in contract1.state_variables_ordered
if not (variable.is_constant or variable.is_immutable)
]
order2 = [
variable
for variable in contract2.state_variables_ordered
if not (variable.is_constant or variable.is_immutable)
]
results = []

Loading…
Cancel
Save