From ef98d051c26a307ca36e89a5e5be9803f6306d3d Mon Sep 17 00:00:00 2001 From: Bernhard Mueller Date: Fri, 1 Feb 2019 12:54:47 +0700 Subject: [PATCH] More fixes --- mythril/analysis/modules/suicide.py | 11 ++++---- .../outputs_expected/suicide.sol.o.json | 20 ++++++++++++- .../outputs_expected/suicide.sol.o.jsonv2 | 28 ++++++++++++++++++- .../outputs_expected/suicide.sol.o.markdown | 2 +- .../outputs_expected/suicide.sol.o.text | 2 +- 5 files changed, 53 insertions(+), 10 deletions(-) diff --git a/mythril/analysis/modules/suicide.py b/mythril/analysis/modules/suicide.py index 417dd590..b9cfce4e 100644 --- a/mythril/analysis/modules/suicide.py +++ b/mythril/analysis/modules/suicide.py @@ -65,16 +65,15 @@ class SuicideModule(DetectionModule): node.constraints + [to == 0xDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF], ) - description_tail = "Anyone can kill this contract and withdraw its balance to an arbitrary " - "account." + description_tail = ( + "Anyone can kill this contract and withdraw its balance to an arbitrary " + "address." + ) except UnsatError: transaction_sequence = solver.get_transaction_sequence( state, node.constraints ) - description_tail = ( - "Arbitrary senders can kill this contract." - - ) + description_tail = "Arbitrary senders can kill this contract." debug = json.dumps(transaction_sequence, indent=4) self._cache_address[instruction["address"]] = True diff --git a/tests/testdata/outputs_expected/suicide.sol.o.json b/tests/testdata/outputs_expected/suicide.sol.o.json index cc30095d..39921898 100644 --- a/tests/testdata/outputs_expected/suicide.sol.o.json +++ b/tests/testdata/outputs_expected/suicide.sol.o.json @@ -1 +1,19 @@ -{"error": null, "issues": [{"address": 146, "contract": "Unknown", "debug": "", "description": "The contract can be killed by anyone.\nAnyone can kill this contract and withdraw its balance to an arbitrary ", "function": "kill(address)", "max_gas_used": 263, "min_gas_used": 168, "severity": "High", "sourceMap": null, "swc-id": "106", "title": "Unprotected Selfdestruct"}], "success": true} \ No newline at end of file +{ + "error" : null, + "issues" : [ + { + "title" : "Unprotected Selfdestruct", + "swc-id" : "106", + "severity" : "High", + "contract" : "Unknown", + "description" : "The contract can be killed by anyone.\nAnyone can kill this contract and withdraw its balance to an arbitrary address.", + "function" : "kill(address)", + "min_gas_used" : 168, + "max_gas_used" : 263, + "debug" : "", + "sourceMap" : null, + "address" : 146 + } + ], + "success" : true +} diff --git a/tests/testdata/outputs_expected/suicide.sol.o.jsonv2 b/tests/testdata/outputs_expected/suicide.sol.o.jsonv2 index c1149545..ee5c2c44 100644 --- a/tests/testdata/outputs_expected/suicide.sol.o.jsonv2 +++ b/tests/testdata/outputs_expected/suicide.sol.o.jsonv2 @@ -1 +1,27 @@ -[{"issues": [{"description": {"head": "The contract can be killed by anyone.", "tail": "Anyone can kill this contract and withdraw its balance to an arbitrary "}, "extra": {}, "locations": [{"sourceMap": "146:1:0"}], "severity": "High", "swcID": "SWC-106", "swcTitle": "Unprotected SELFDESTRUCT Instruction"}], "meta": {}, "sourceFormat": "evm-byzantium-bytecode", "sourceList": ["0x2fb801366b61a05b30550481a1c8f7d5f20de0b93d9f2f2ce2b28c4e322033c9"], "sourceType": "raw-bytecode"}] \ No newline at end of file +[ + { + "issues" : [ + { + "swcTitle" : "Unprotected SELFDESTRUCT Instruction", + "locations" : [ + { + "sourceMap" : "146:1:0" + } + ], + "extra" : {}, + "description" : { + "tail" : "Anyone can kill this contract and withdraw its balance to an arbitrary address.", + "head" : "The contract can be killed by anyone." + }, + "severity" : "High", + "swcID" : "SWC-106" + } + ], + "sourceFormat" : "evm-byzantium-bytecode", + "meta" : {}, + "sourceType" : "raw-bytecode", + "sourceList" : [ + "0x2fb801366b61a05b30550481a1c8f7d5f20de0b93d9f2f2ce2b28c4e322033c9" + ] + } +] \ No newline at end of file diff --git a/tests/testdata/outputs_expected/suicide.sol.o.markdown b/tests/testdata/outputs_expected/suicide.sol.o.markdown index 1020f1bf..f31b9f3f 100644 --- a/tests/testdata/outputs_expected/suicide.sol.o.markdown +++ b/tests/testdata/outputs_expected/suicide.sol.o.markdown @@ -11,4 +11,4 @@ ### Description The contract can be killed by anyone. -Anyone can kill this contract and withdraw its balance to an arbitrary +Anyone can kill this contract and withdraw its balance to an arbitrary address. diff --git a/tests/testdata/outputs_expected/suicide.sol.o.text b/tests/testdata/outputs_expected/suicide.sol.o.text index 6cec5846..45dd0295 100644 --- a/tests/testdata/outputs_expected/suicide.sol.o.text +++ b/tests/testdata/outputs_expected/suicide.sol.o.text @@ -6,6 +6,6 @@ Function name: kill(address) PC address: 146 Estimated Gas Usage: 168 - 263 The contract can be killed by anyone. -Anyone can kill this contract and withdraw its balance to an arbitrary +Anyone can kill this contract and withdraw its balance to an arbitrary address. --------------------