From fa3ba105be60dcd0603e34c1eb85b7da28a9f047 Mon Sep 17 00:00:00 2001 From: Josselin Date: Fri, 3 Apr 2020 17:18:15 +0200 Subject: [PATCH] Add psender Improve properties --- slither/tools/properties/platforms/echidna.py | 1 + .../properties/properties/ercs/erc20/properties/transfer.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/slither/tools/properties/platforms/echidna.py b/slither/tools/properties/platforms/echidna.py index 052c6d8b5..f02783429 100644 --- a/slither/tools/properties/platforms/echidna.py +++ b/slither/tools/properties/platforms/echidna.py @@ -14,6 +14,7 @@ def generate_echidna_config(output_dir: Path, addresses: Addresses) -> str: content = 'prefix: crytic_\n' content += f'deployer: "{addresses.owner}"\n' content += f'sender: ["{addresses.user}", "{addresses.attacker}"]\n' + content += f'psender: "{addresses.user}"\n' content += 'coverage: true\n' filename = 'echidna_config.yaml' write_file(output_dir, filename, content) diff --git a/slither/tools/properties/properties/ercs/erc20/properties/transfer.py b/slither/tools/properties/properties/ercs/erc20/properties/transfer.py index 922f0e0fb..02860e4ab 100644 --- a/slither/tools/properties/properties/ercs/erc20/properties/transfer.py +++ b/slither/tools/properties/properties/ercs/erc20/properties/transfer.py @@ -64,6 +64,10 @@ ERC20_Transferable = [ description='No one should be able to send tokens to the address 0x0 (transferFrom).', content=''' \t\tuint balance = this.balanceOf(msg.sender); +\t\tif (balance == 0){ +\t\t\trevert(); +\t\t} +\t\tapprove(msg.sender, balance); \t\treturn transferFrom(msg.sender, address(0x0), this.balanceOf(msg.sender));''', type=PropertyType.CODE_QUALITY, return_type=PropertyReturn.FAIL_OR_THROW,