-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
74 changed files
with
6,082 additions
and
2 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity 0.8.19; | ||
|
||
abstract contract AbstractContract { | ||
address public admin; | ||
function transferAdmin(address newAdmin) public virtual { | ||
if (admin != msg.sender) { | ||
revert("CallerNotAdmin"); | ||
} | ||
require(newAdmin != address(0), "InvalidAdmin"); | ||
admin = newAdmin; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.19; | ||
|
||
contract AderynCustomIgnore { | ||
|
||
// This will be reported by empty-block and useless-public-function | ||
function f1() public { | ||
|
||
} | ||
|
||
|
||
// This will be not reported by either of the detectors | ||
// aderyn-ignore-next-line(useless-public-function , empty-block) | ||
function f2() public { | ||
|
||
} | ||
|
||
// This will never be reported | ||
// aderyn-ignore-next-line | ||
function f3() public { | ||
|
||
} | ||
|
||
// This will be reported only by useless-public-function | ||
// aderyn-ignore-next-line (empty-block) | ||
function f4() public { | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.20; | ||
|
||
// COPIED from Slither | ||
contract AssertUsage { | ||
uint s_a; | ||
|
||
function bad() public { | ||
assert((s_a += 1) > 10); | ||
} | ||
|
||
function good() public { | ||
s_a += 1; | ||
assert(s_a > 10); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
pragma solidity 0.4.22; | ||
|
||
contract BooleanEquality { | ||
function badCheck(bool isEven) external pure returns (uint256) { | ||
if (isEven == true) { | ||
return 100; | ||
} | ||
return 0; | ||
} | ||
|
||
function badCheck2(bool isEven) external pure returns (uint256) { | ||
if (isEven == !true) { | ||
return 200; | ||
} | ||
return 130; | ||
} | ||
|
||
function badCheck3(bool isEven) external pure returns (uint256) { | ||
if (isEven == false) { | ||
return 100; | ||
} | ||
return 0; | ||
} | ||
|
||
function badCheck4(bool isEven) external pure returns (uint256) { | ||
if (isEven == !false) { | ||
return 200; | ||
} | ||
return 130; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.4.0; | ||
|
||
contract BuiltinSymbolShadow { | ||
uint now; // BAD | ||
|
||
// BAD | ||
function assert(bool condition) public {} | ||
|
||
function get_next_expiration( | ||
uint earlier_time | ||
) private blockhash returns (uint) { | ||
return now + 259200; // References overshadowed timestamp. | ||
} | ||
|
||
// BAD | ||
modifier blockhash() { | ||
_; | ||
} | ||
|
||
// BAD | ||
event sha256(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.20; | ||
|
||
contract CacheArrayLength { | ||
uint[] array; | ||
uint[] anotherArray; | ||
|
||
function c1() external view { | ||
uint total = 0; | ||
|
||
// BAD (length is not cached) | ||
for (uint i = 0; i < array.length; i++) { | ||
total += array[i]; | ||
} | ||
} | ||
|
||
function c2() external view { | ||
uint array_length = array.length; | ||
// GOOD (length is cached) | ||
for (uint i = 0; i < array_length; i++) {} | ||
} | ||
|
||
function c3() external { | ||
// GOOD | ||
for (uint i = 0; i < array.length; i++) { | ||
array[i] = 100; | ||
array.push(100); | ||
array.pop(); | ||
} | ||
} | ||
|
||
function c4() external { | ||
// GOOD (even though anotherArray.length doesn't change, static analysis should assume that the condition as | ||
// a whole can change even if just one of the involved state variable changes) | ||
for (uint i = 0; i < array.length + anotherArray.length; i++) { | ||
array[i] = 100; | ||
array.push(100); | ||
array.pop(); | ||
} | ||
} | ||
|
||
function c5() external view { | ||
// BAD (can cache) | ||
for (uint i = 0; i < array.length + anotherArray.length; i++) {} | ||
} | ||
|
||
function c6() external view { | ||
uint total = 0; | ||
// BAD (can cache) | ||
for (uint i = 0; i < array.length + anotherArray.length; i++) { | ||
// Only reading from storage (not changing them) | ||
total += array[i] * anotherArray[i]; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.19; | ||
|
||
contract Tower1 { | ||
|
||
function visitEighthFloor1() internal { | ||
require(msg.sender == address(0x11)); | ||
} | ||
|
||
modifier passThroughNinthFloor1() { | ||
visitEighthFloor1(); | ||
_; | ||
} | ||
|
||
// Start Here | ||
function enterTenthFloor1() external passThroughNinthFloor1() { | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
contract Tower2 { | ||
|
||
function visitEighthFloor2(address x) internal { | ||
(bool success,) = x.call{value: 10}("calldata"); | ||
if (!success) { | ||
revert(); | ||
} | ||
} | ||
|
||
modifier passThroughNinthFloor2(address x) { | ||
visitEighthFloor2(x); | ||
_; | ||
} | ||
|
||
// Start Here | ||
function enterTenthFloor2(address x) external passThroughNinthFloor2(x) { | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
contract Tower3 { | ||
|
||
function visitEighthFloor3(address x) internal { | ||
(bool success,) = x.call{value: 10}("calldata"); | ||
if (!success) { | ||
revert(); | ||
} | ||
} | ||
|
||
modifier passThroughNinthFloor3(address x) { | ||
visitEighthFloor3(x); | ||
_; | ||
} | ||
|
||
// Start Here | ||
function enterTenthFloor3(address x) external passThroughNinthFloor3(x) { | ||
visitSeventhFloor3(); | ||
} | ||
|
||
function visitSeventhFloor3() internal { | ||
require(msg.sender == address(0x11)); | ||
} | ||
|
||
} | ||
|
||
contract Tower4 { | ||
// A recursive function should have itself as upstream and downstream | ||
function recurse(string memory something) private { | ||
recurse(something); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.4.0; | ||
|
||
contract CompilerBugStorageSignedIntegerArray { | ||
int256[3] affectedArray; | ||
int256[4] unaffectedArray; | ||
|
||
function assignBadValue() private { | ||
affectedArray = [-1, 5, 2]; | ||
} | ||
|
||
function assignGoodValue() private { | ||
unaffectedArray[0] = -1; | ||
unaffectedArray[1] = 5; | ||
unaffectedArray[2] = 2; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.4.0; | ||
|
||
contract ConstantFunctionChangeState { | ||
uint counter; | ||
|
||
// BAD (it is declared as view but changes state) | ||
function changeState() public view returns (uint) { | ||
counter = counter + 1; | ||
return counter; | ||
} | ||
|
||
// GOOD (because it's not declared as view) | ||
function changeState2() public returns (uint) { | ||
counter = counter + 1; | ||
return counter; | ||
} | ||
|
||
// GOOD (it's declared as view and it doesn't change state) | ||
function dontChangeState() public view returns (uint) { | ||
return counter + 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.4.0; | ||
|
||
contract AssemblyExample { | ||
// State variable | ||
uint256 public value; | ||
|
||
// BAD (view function contains assembly) | ||
function setValue(uint256 _value) external view { | ||
assembly { | ||
// Load the location of the 'value' storage slot | ||
sstore(0, _value) | ||
} | ||
} | ||
|
||
// BAD (pure function contains assembly) | ||
function getConstantValue() external pure returns (uint256) { | ||
uint256 result; | ||
assembly { | ||
// Inline assembly to set the result to a constant value | ||
result := 42 | ||
} | ||
return result; | ||
} | ||
|
||
function useAssembly() internal pure returns (uint256) { | ||
uint256 result; | ||
assembly { | ||
// Inline assembly to set the result to a constant value | ||
result := 42 | ||
} | ||
return result; | ||
} | ||
|
||
// BAD (pure function contains assembly) | ||
function getConstantValue2() external pure returns (uint256) { | ||
return useAssembly(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.