mirror of https://github.com/crytic/slither
parent
010d84125a
commit
4319bb3605
@ -1,65 +1,76 @@ |
|||||||
from slither.tools.properties.properties.properties import Property, PropertyType, PropertyReturn, PropertyCaller |
from slither.tools.properties.properties.properties import ( |
||||||
|
Property, |
||||||
|
PropertyType, |
||||||
|
PropertyReturn, |
||||||
|
PropertyCaller, |
||||||
|
) |
||||||
|
|
||||||
ERC20_CONFIG = [ |
ERC20_CONFIG = [ |
||||||
|
Property( |
||||||
Property(name='init_total_supply()', |
name="init_total_supply()", |
||||||
description='The total supply is correctly initialized.', |
description="The total supply is correctly initialized.", |
||||||
content=''' |
content=""" |
||||||
\t\treturn this.totalSupply() >= 0 && this.totalSupply() == initialTotalSupply;''', |
\t\treturn this.totalSupply() >= 0 && this.totalSupply() == initialTotalSupply;""", |
||||||
type=PropertyType.CODE_QUALITY, |
type=PropertyType.CODE_QUALITY, |
||||||
return_type=PropertyReturn.SUCCESS, |
return_type=PropertyReturn.SUCCESS, |
||||||
is_unit_test=True, |
is_unit_test=True, |
||||||
is_property_test=False, |
is_property_test=False, |
||||||
caller=PropertyCaller.ANY), |
caller=PropertyCaller.ANY, |
||||||
|
), |
||||||
Property(name='init_owner_balance()', |
Property( |
||||||
description="Owner's balance is correctly initialized.", |
name="init_owner_balance()", |
||||||
content=''' |
description="Owner's balance is correctly initialized.", |
||||||
\t\treturn initialBalance_owner == this.balanceOf(crytic_owner);''', |
content=""" |
||||||
type=PropertyType.CODE_QUALITY, |
\t\treturn initialBalance_owner == this.balanceOf(crytic_owner);""", |
||||||
return_type=PropertyReturn.SUCCESS, |
type=PropertyType.CODE_QUALITY, |
||||||
is_unit_test=True, |
return_type=PropertyReturn.SUCCESS, |
||||||
is_property_test=False, |
is_unit_test=True, |
||||||
caller=PropertyCaller.ANY), |
is_property_test=False, |
||||||
|
caller=PropertyCaller.ANY, |
||||||
Property(name='init_user_balance()', |
), |
||||||
description="User's balance is correctly initialized.", |
Property( |
||||||
content=''' |
name="init_user_balance()", |
||||||
\t\treturn initialBalance_user == this.balanceOf(crytic_user);''', |
description="User's balance is correctly initialized.", |
||||||
type=PropertyType.CODE_QUALITY, |
content=""" |
||||||
return_type=PropertyReturn.SUCCESS, |
\t\treturn initialBalance_user == this.balanceOf(crytic_user);""", |
||||||
is_unit_test=True, |
type=PropertyType.CODE_QUALITY, |
||||||
is_property_test=False, |
return_type=PropertyReturn.SUCCESS, |
||||||
caller=PropertyCaller.ANY), |
is_unit_test=True, |
||||||
|
is_property_test=False, |
||||||
Property(name='init_attacker_balance()', |
caller=PropertyCaller.ANY, |
||||||
description="Attacker's balance is correctly initialized.", |
), |
||||||
content=''' |
Property( |
||||||
\t\treturn initialBalance_attacker == this.balanceOf(crytic_attacker);''', |
name="init_attacker_balance()", |
||||||
type=PropertyType.CODE_QUALITY, |
description="Attacker's balance is correctly initialized.", |
||||||
return_type=PropertyReturn.SUCCESS, |
content=""" |
||||||
is_unit_test=True, |
\t\treturn initialBalance_attacker == this.balanceOf(crytic_attacker);""", |
||||||
is_property_test=False, |
type=PropertyType.CODE_QUALITY, |
||||||
caller=PropertyCaller.ANY), |
return_type=PropertyReturn.SUCCESS, |
||||||
|
is_unit_test=True, |
||||||
Property(name='init_caller_balance()', |
is_property_test=False, |
||||||
description="All the users have a positive balance.", |
caller=PropertyCaller.ANY, |
||||||
content=''' |
), |
||||||
\t\treturn this.balanceOf(msg.sender) >0 ;''', |
Property( |
||||||
type=PropertyType.CODE_QUALITY, |
name="init_caller_balance()", |
||||||
return_type=PropertyReturn.SUCCESS, |
description="All the users have a positive balance.", |
||||||
is_unit_test=True, |
content=""" |
||||||
is_property_test=False, |
\t\treturn this.balanceOf(msg.sender) >0 ;""", |
||||||
caller=PropertyCaller.ALL), |
type=PropertyType.CODE_QUALITY, |
||||||
|
return_type=PropertyReturn.SUCCESS, |
||||||
|
is_unit_test=True, |
||||||
|
is_property_test=False, |
||||||
|
caller=PropertyCaller.ALL, |
||||||
|
), |
||||||
# Note: there is a potential overflow on the addition, but we dont consider it |
# Note: there is a potential overflow on the addition, but we dont consider it |
||||||
Property(name='init_total_supply_is_balances()', |
Property( |
||||||
description="The total supply is the user and owner balance.", |
name="init_total_supply_is_balances()", |
||||||
content=''' |
description="The total supply is the user and owner balance.", |
||||||
\t\treturn this.balanceOf(crytic_owner) + this.balanceOf(crytic_user) + this.balanceOf(crytic_attacker) == this.totalSupply();''', |
content=""" |
||||||
type=PropertyType.CODE_QUALITY, |
\t\treturn this.balanceOf(crytic_owner) + this.balanceOf(crytic_user) + this.balanceOf(crytic_attacker) == this.totalSupply();""", |
||||||
return_type=PropertyReturn.SUCCESS, |
type=PropertyType.CODE_QUALITY, |
||||||
is_unit_test=True, |
return_type=PropertyReturn.SUCCESS, |
||||||
is_property_test=False, |
is_unit_test=True, |
||||||
caller=PropertyCaller.ANY), |
is_property_test=False, |
||||||
] |
caller=PropertyCaller.ANY, |
||||||
|
), |
||||||
|
] |
||||||
|
@ -1,13 +1,20 @@ |
|||||||
from slither.tools.properties.properties.properties import PropertyType, PropertyReturn, Property, PropertyCaller |
from slither.tools.properties.properties.properties import ( |
||||||
|
PropertyType, |
||||||
|
PropertyReturn, |
||||||
|
Property, |
||||||
|
PropertyCaller, |
||||||
|
) |
||||||
|
|
||||||
ERC20_NotMintable = [ |
ERC20_NotMintable = [ |
||||||
Property(name='crytic_supply_constant_ERC20PropertiesNotMintable()', |
Property( |
||||||
description='The total supply does not increase.', |
name="crytic_supply_constant_ERC20PropertiesNotMintable()", |
||||||
content=''' |
description="The total supply does not increase.", |
||||||
\t\treturn initialTotalSupply >= totalSupply();''', |
content=""" |
||||||
type=PropertyType.MEDIUM_SEVERITY, |
\t\treturn initialTotalSupply >= totalSupply();""", |
||||||
return_type=PropertyReturn.SUCCESS, |
type=PropertyType.MEDIUM_SEVERITY, |
||||||
is_unit_test=True, |
return_type=PropertyReturn.SUCCESS, |
||||||
is_property_test=True, |
is_unit_test=True, |
||||||
caller=PropertyCaller.ANY), |
is_property_test=True, |
||||||
|
caller=PropertyCaller.ANY, |
||||||
|
), |
||||||
] |
] |
||||||
|
@ -1,14 +1,20 @@ |
|||||||
from slither.tools.properties.properties.properties import Property, PropertyType, PropertyReturn, PropertyCaller |
from slither.tools.properties.properties.properties import ( |
||||||
|
Property, |
||||||
|
PropertyType, |
||||||
|
PropertyReturn, |
||||||
|
PropertyCaller, |
||||||
|
) |
||||||
|
|
||||||
ERC20_NotMintableNotBurnable = [ |
ERC20_NotMintableNotBurnable = [ |
||||||
|
Property( |
||||||
Property(name='crytic_supply_constant_ERC20PropertiesNotMintableNotBurnable()', |
name="crytic_supply_constant_ERC20PropertiesNotMintableNotBurnable()", |
||||||
description='The total supply does not change.', |
description="The total supply does not change.", |
||||||
content=''' |
content=""" |
||||||
\t\treturn initialTotalSupply == this.totalSupply();''', |
\t\treturn initialTotalSupply == this.totalSupply();""", |
||||||
type=PropertyType.MEDIUM_SEVERITY, |
type=PropertyType.MEDIUM_SEVERITY, |
||||||
return_type=PropertyReturn.SUCCESS, |
return_type=PropertyReturn.SUCCESS, |
||||||
is_unit_test=True, |
is_unit_test=True, |
||||||
is_property_test=True, |
is_property_test=True, |
||||||
caller=PropertyCaller.ANY), |
caller=PropertyCaller.ANY, |
||||||
] |
), |
||||||
|
] |
||||||
|
@ -1,11 +1,23 @@ |
|||||||
from .initialization import (InitializablePresent, InitializableInherited, |
from .initialization import ( |
||||||
InitializableInitializer, MissingInitializerModifier, MissingCalls, MultipleCalls, InitializeTarget) |
InitializablePresent, |
||||||
|
InitializableInherited, |
||||||
|
InitializableInitializer, |
||||||
|
MissingInitializerModifier, |
||||||
|
MissingCalls, |
||||||
|
MultipleCalls, |
||||||
|
InitializeTarget, |
||||||
|
) |
||||||
|
|
||||||
from .functions_ids import IDCollision, FunctionShadowing |
from .functions_ids import IDCollision, FunctionShadowing |
||||||
|
|
||||||
from .variable_initialization import VariableWithInit |
from .variable_initialization import VariableWithInit |
||||||
|
|
||||||
from .variables_order import (MissingVariable, DifferentVariableContractProxy, |
from .variables_order import ( |
||||||
DifferentVariableContractNewContract, ExtraVariablesProxy, ExtraVariablesNewContract) |
MissingVariable, |
||||||
|
DifferentVariableContractProxy, |
||||||
|
DifferentVariableContractNewContract, |
||||||
|
ExtraVariablesProxy, |
||||||
|
ExtraVariablesNewContract, |
||||||
|
) |
||||||
|
|
||||||
from .constant import WereConstant, BecameConstant |
from .constant import WereConstant, BecameConstant |
||||||
|
@ -1,13 +1,12 @@ |
|||||||
|
|
||||||
from slither.visitors.expression.expression import ExpressionVisitor |
from slither.visitors.expression.expression import ExpressionVisitor |
||||||
|
|
||||||
class HasConditional(ExpressionVisitor): |
|
||||||
|
|
||||||
|
class HasConditional(ExpressionVisitor): |
||||||
def result(self): |
def result(self): |
||||||
# == True, to convert None to false |
# == True, to convert None to false |
||||||
return self._result is True |
return self._result is True |
||||||
|
|
||||||
def _post_conditional_expression(self, expression): |
def _post_conditional_expression(self, expression): |
||||||
# if self._result is True: |
# if self._result is True: |
||||||
# raise('Slither does not support nested ternary operator') |
# raise('Slither does not support nested ternary operator') |
||||||
self._result = True |
self._result = True |
||||||
|
Loading…
Reference in new issue