From 5eee87acb9f7bc98d6daec7cd7c73cfd64845b64 Mon Sep 17 00:00:00 2001 From: Josselin Date: Sat, 5 Mar 2022 18:41:30 +0100 Subject: [PATCH] Add support for string.concat Fix #1075 --- .../core/declarations/solidity_variables.py | 1 + slither/slithir/convert.py | 12 ++ slither/slithir/operations/member.py | 2 +- ...ts_and_global_variables-0.8.12-compact.zip | Bin 10273 -> 9664 bytes ...s_and_global_variables-0.8.12-compact.json | 3 +- .../units_and_global_variables-0.8.12.sol | 119 ++++++++++++++++++ 6 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 tests/ast-parsing/units_and_global_variables-0.8.12.sol diff --git a/slither/core/declarations/solidity_variables.py b/slither/core/declarations/solidity_variables.py index 9ce0314994..225644cb31 100644 --- a/slither/core/declarations/solidity_variables.py +++ b/slither/core/declarations/solidity_variables.py @@ -71,6 +71,7 @@ "abi.encodeWithSelector()": ["bytes"], "abi.encodeWithSignature()": ["bytes"], "bytes.concat()": ["bytes"], + "string.concat()": ["string"], # abi.decode returns an a list arbitrary types "abi.decode()": [], "type(address)": [], diff --git a/slither/slithir/convert.py b/slither/slithir/convert.py index a1ebef0638..91c7394e91 100644 --- a/slither/slithir/convert.py +++ b/slither/slithir/convert.py @@ -944,6 +944,18 @@ def extract_tmp_call(ins: TmpCall, contract: Optional[Contract]): # pylint: dis s.set_expression(ins.expression) return s + if ins.ori.variable_left == ElementaryType("string") and ins.ori.variable_right == Constant( + "concat" + ): + s = SolidityCall( + SolidityFunction("string.concat()"), + ins.nbr_arguments, + ins.lvalue, + ins.type_call, + ) + s.set_expression(ins.expression) + return s + msgcall = HighLevelCall( ins.ori.variable_left, ins.ori.variable_right, diff --git a/slither/slithir/operations/member.py b/slither/slithir/operations/member.py index c835f58e02..7dca0cf792 100644 --- a/slither/slithir/operations/member.py +++ b/slither/slithir/operations/member.py @@ -22,7 +22,7 @@ def __init__(self, variable_left, variable_right, result): # f.h(1); # } # } - # Can be an ElementaryType because of bytes.concat + # Can be an ElementaryType because of bytes.concat, string.concat assert is_valid_rvalue(variable_left) or isinstance( variable_left, (Contract, Enum, Function, CustomError, SolidityImportPlaceHolder, ElementaryType), diff --git a/tests/ast-parsing/compile/units_and_global_variables-0.8.12-compact.zip b/tests/ast-parsing/compile/units_and_global_variables-0.8.12-compact.zip index 53f9c93b5768b91d0905d30db2b979710ee51399..0026bf0dc1e53c522f52c87c760c17daf3ff00b0 100644 GIT binary patch delta 9513 zcmV+^CDz)ZP{2zYP)h>@KL7#%4gma=WmMetJ7C3TEA=|sp*-%F;TtjCXP6-^SM6sUdrvX9eHN3V;RIN~~rh&ki?{(+mxeY8> z^?Y>?;^FkRZKw?-qfWD091n9p|I&^tBZ}M6%!YfowbS`|4dTdwFM+jfq&sh~c-N*9 z+ki7qDElAdu53@Xnjw509Bz9Rf0Wl7Z0d5)6DdHD5H1tx*x~Z}tknI6yEV?3?3G-u;8E@AOId#nOQyhLYFNof6y-|?(uuVUDMRrwzEWe7w zUDQYiK}ZbP{$n?eS55wE&KMS!c^qGcs$URc$1!;U0(RrU96dknYz+5Tf5q=OZX$pU zW}G%Cmj$)?s!}2P^~>3Oe@M&)41P*pjbL3$7}I7(PM>DZzCtbAM87A|ghxoNT%Pvm zv{8Zy7O;2Mv(m1|1ss}c#2zP`8*Ziy2ZGNc5gUR1g=T2NfdK&s!ksxQI~PFdxjd0G z9fJ~9`;*8MS{mhqq<(csf7e+9Gd<3-De|AzWL66Iv5Z*?G-Tw^Mx`VS#EVqcsThqv zd2vNO6!BTEjyN{K&LpEDi^=#sHUWgMGOh&2uZWGBM0$tkQBG%7{|UD&TJ4B5mXxgV z<-e4e=X~H{nJ17x7Z5pm1&j03@I6eo8zxZrPzU`4#xfxC zqg#Ik+in%j2|u~`X^l{Lx@WA0z;g{ZQHuLk&&|RBi4O(x`h_2-s&+7pYRKi5xkkwF zH81h`uVp*^_I#=5DMzeMhvf@}XaN7n1#BaOO=or%F1>caNj;Zyih@73b$?@bvP>G< z?tP6+*NN|me?!1kH=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4mY`{T`)k}GK0e;A8zBpC#XLSdCdZ|ou0fW+#{j)M^>VA28` zOVx#TChe;5T(XnfGI_JOFIx^~$H+7bTtm?Bl_Z+f4N-U~BtRJCj9bau`O|-e{C}N)hTiR>#BjxQ3cE8 z`X+C=3}5&9tZ0O$qD1_er0tyn;%#re*J&Fpwaqr-S%B{gdV8G_Tq*R^Tuk2o82_07 xP)h*1;\n1[label=\"Node Type: EXPRESSION 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n}\n", "time_unit()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: EXPRESSION 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n2->3;\n3[label=\"Node Type: EXPRESSION 3\n\"];\n3->4;\n4[label=\"Node Type: EXPRESSION 4\n\"];\n4->5;\n5[label=\"Node Type: EXPRESSION 5\n\"];\n}\n", - "block_and_transactions()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: EXPRESSION 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n2->3;\n3[label=\"Node Type: EXPRESSION 3\n\"];\n3->4;\n4[label=\"Node Type: EXPRESSION 4\n\"];\n4->5;\n5[label=\"Node Type: EXPRESSION 5\n\"];\n5->6;\n6[label=\"Node Type: EXPRESSION 6\n\"];\n6->7;\n7[label=\"Node Type: EXPRESSION 7\n\"];\n7->8;\n8[label=\"Node Type: EXPRESSION 8\n\"];\n8->9;\n9[label=\"Node Type: EXPRESSION 9\n\"];\n9->10;\n10[label=\"Node Type: EXPRESSION 10\n\"];\n10->11;\n11[label=\"Node Type: EXPRESSION 11\n\"];\n11->12;\n12[label=\"Node Type: EXPRESSION 12\n\"];\n12->13;\n13[label=\"Node Type: EXPRESSION 13\n\"];\n13->14;\n14[label=\"Node Type: EXPRESSION 14\n\"];\n14->15;\n15[label=\"Node Type: EXPRESSION 15\n\"];\n15->16;\n16[label=\"Node Type: EXPRESSION 16\n\"];\n}\n", + "block_and_transactions()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: EXPRESSION 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n2->3;\n3[label=\"Node Type: EXPRESSION 3\n\"];\n3->4;\n4[label=\"Node Type: EXPRESSION 4\n\"];\n4->5;\n5[label=\"Node Type: EXPRESSION 5\n\"];\n5->6;\n6[label=\"Node Type: EXPRESSION 6\n\"];\n6->7;\n7[label=\"Node Type: EXPRESSION 7\n\"];\n7->8;\n8[label=\"Node Type: EXPRESSION 8\n\"];\n8->9;\n9[label=\"Node Type: EXPRESSION 9\n\"];\n9->10;\n10[label=\"Node Type: EXPRESSION 10\n\"];\n10->11;\n11[label=\"Node Type: EXPRESSION 11\n\"];\n11->12;\n12[label=\"Node Type: EXPRESSION 12\n\"];\n12->13;\n13[label=\"Node Type: EXPRESSION 13\n\"];\n13->14;\n14[label=\"Node Type: EXPRESSION 14\n\"];\n14->15;\n15[label=\"Node Type: EXPRESSION 15\n\"];\n}\n", "abi_encode()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n2->3;\n3[label=\"Node Type: EXPRESSION 3\n\"];\n3->4;\n4[label=\"Node Type: EXPRESSION 4\n\"];\n4->5;\n5[label=\"Node Type: NEW VARIABLE 5\n\"];\n5->6;\n6[label=\"Node Type: EXPRESSION 6\n\"];\n6->7;\n7[label=\"Node Type: NEW VARIABLE 7\n\"];\n7->8;\n8[label=\"Node Type: EXPRESSION 8\n\"];\n}\n", - "member()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n1->2;\n2[label=\"Node Type: NEW VARIABLE 2\n\"];\n2->3;\n3[label=\"Node Type: EXPRESSION 3\n\"];\n}\n", "error_handling()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: EXPRESSION 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n2->3;\n3[label=\"Node Type: EXPRESSION 3\n\"];\n3->4;\n4[label=\"Node Type: EXPRESSION 4\n\"];\n4->5;\n5[label=\"Node Type: EXPRESSION 5\n\"];\n}\n", "math_and_crypto()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: EXPRESSION 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n2->3;\n3[label=\"Node Type: EXPRESSION 3\n\"];\n3->4;\n4[label=\"Node Type: EXPRESSION 4\n\"];\n4->5;\n5[label=\"Node Type: EXPRESSION 5\n\"];\n5->6;\n6[label=\"Node Type: NEW VARIABLE 6\n\"];\n6->7;\n7[label=\"Node Type: NEW VARIABLE 7\n\"];\n7->8;\n8[label=\"Node Type: NEW VARIABLE 8\n\"];\n8->9;\n9[label=\"Node Type: NEW VARIABLE 9\n\"];\n9->10;\n10[label=\"Node Type: EXPRESSION 10\n\"];\n}\n", "address_related()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n2->3;\n3[label=\"Node Type: EXPRESSION 3\n\"];\n3->4;\n4[label=\"Node Type: EXPRESSION 4\n\"];\n4->5;\n5[label=\"Node Type: EXPRESSION 5\n\"];\n5->6;\n6[label=\"Node Type: EXPRESSION 6\n\"];\n6->7;\n7[label=\"Node Type: EXPRESSION 7\n\"];\n7->8;\n8[label=\"Node Type: EXPRESSION 8\n\"];\n8->9;\n9[label=\"Node Type: EXPRESSION 9\n\"];\n}\n", diff --git a/tests/ast-parsing/units_and_global_variables-0.8.12.sol b/tests/ast-parsing/units_and_global_variables-0.8.12.sol new file mode 100644 index 0000000000..11a467304e --- /dev/null +++ b/tests/ast-parsing/units_and_global_variables-0.8.12.sol @@ -0,0 +1,119 @@ +pragma experimental ABIEncoderV2; + +contract A{} + +interface I{} + +contract Test{ + + function ether_unit() public{ + 1 wei; + 1 ether; + } + + function time_unit() public{ + 1 seconds; + 1 minutes; + 1 hours; + 1 days; + 1 weeks; + } + + function block_and_transactions() payable public{ + blockhash(0); + block.basefee; + block.chainid; + block.coinbase; + block.difficulty; + block.gaslimit; + block.number; + block.timestamp; + gasleft(); + msg.data; + msg.sender; + msg.sig; + msg.value; + block.timestamp; + tx.gasprice; + tx.origin; + } + + function abi_encode() public{ + bytes memory m; + abi.decode(m, (uint, uint)); + abi.encode(10); + abi.encodePacked(uint(10)); + bytes4 selector; + abi.encodeWithSelector(selector, 10); + string memory signature; + abi.encodeWithSignature(signature, 10); + } + + function member() public{ + bytes1 b1; + bytes32 b32; + bytes.concat(b1, b32); + string.concat("", ""); + } + + function error_handling() public{ + assert(true); + require(true); + require(true, "something"); + revert(); + revert("something"); + } + + function math_and_crypto() public{ + addmod(0, 0, 1); + mulmod(0, 0, 1); + keccak256(""); + sha256(""); + ripemd160(""); + bytes32 hash; + uint8 v; + bytes32 r; + bytes32 s; + ecrecover(hash,v,r,s); + } + + function address_related() public{ + address payable a; + a.balance; + a.code; + a.codehash; + a.send(0); + a.transfer(0); + a.call(""); + a.delegatecall(""); + a.staticcall(""); + } + + + function return_addr() internal returns(address){} + function address_edge_case() public{ + // For now slithIR loss precision on this edge case + // And create a Ref variable instead of a Temporary one + return_addr().balance; + return_addr().code; + return_addr().codehash; + } + + + function contract_related() public{ + this; + address payable a; + selfdestruct(a); + } + + function type_related() public{ + type(A).name; + type(A).creationCode; + type(A).runtimeCode; + type(I).interfaceId; + type(uint256).min; + type(uint256).min; + } + + +}