mirror of https://github.com/crytic/slither
Merge pull request #1303 from pcaversaccio/patch-1
Test for unification of path filtering across POSIX and Windowspull/1395/head
commit
7313806b7c
@ -0,0 +1,15 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
### Test path filtering across POSIX and Windows |
||||
|
||||
solc-select use 0.8.0 |
||||
slither "tests/test_path_filtering/test_path_filtering.sol" --config "tests/test_path_filtering/slither.config.json" > "output.txt" 2>&1 |
||||
|
||||
if ! grep -q "0 result(s) found" "output.txt" |
||||
then |
||||
echo "Path filtering across POSIX and Windows failed" |
||||
rm output.txt |
||||
exit 5 |
||||
else |
||||
rm output.txt |
||||
fi |
@ -0,0 +1,14 @@ |
||||
// SPDX-License-Identifier: UNLICENSED |
||||
pragma solidity ^0.8.0; |
||||
|
||||
contract ReentrancyMock1 { |
||||
mapping(address => uint256) public userBalances1; |
||||
|
||||
function withdraw1() external { |
||||
uint256 userBalance = userBalances1[msg.sender]; |
||||
require(userBalance > 0); |
||||
(bool success, ) = msg.sender.call{value: userBalance}(""); |
||||
require(success); |
||||
userBalances1[msg.sender] = 0; |
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
// SPDX-License-Identifier: UNLICENSED |
||||
pragma solidity ^0.8.0; |
||||
|
||||
contract ReentrancyMock2 { |
||||
mapping(address => uint256) public userBalances2; |
||||
|
||||
function withdraw2() external { |
||||
uint256 userBalance = userBalances2[msg.sender]; |
||||
require(userBalance > 0); |
||||
(bool success, ) = msg.sender.call{value: userBalance}(""); |
||||
require(success); |
||||
userBalances2[msg.sender] = 0; |
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
// SPDX-License-Identifier: UNLICENSED |
||||
pragma solidity ^0.8.0; |
||||
|
||||
contract ReentrancyMock3 { |
||||
mapping(address => uint256) public userBalances3; |
||||
|
||||
function withdraw3() external { |
||||
uint256 userBalance = userBalances3[msg.sender]; |
||||
require(userBalance > 0); |
||||
(bool success, ) = msg.sender.call{value: userBalance}(""); |
||||
require(success); |
||||
userBalances3[msg.sender] = 0; |
||||
} |
||||
} |
@ -0,0 +1,7 @@ |
||||
{ |
||||
"detectors_to_run": "all", |
||||
"exclude_informational": true, |
||||
"exclude_low": true, |
||||
"fail_pedantic": false, |
||||
"filter_paths": "libs|src/ReentrancyMock.sol" |
||||
} |
@ -0,0 +1,14 @@ |
||||
// SPDX-License-Identifier: UNLICENSED |
||||
pragma solidity ^0.8.0; |
||||
|
||||
contract ReentrancyMock { |
||||
mapping(address => uint256) public userBalances; |
||||
|
||||
function withdraw() external { |
||||
uint256 userBalance = userBalances[msg.sender]; |
||||
require(userBalance > 0); |
||||
(bool success, ) = msg.sender.call{value: userBalance}(""); |
||||
require(success); |
||||
userBalances[msg.sender] = 0; |
||||
} |
||||
} |
@ -0,0 +1,9 @@ |
||||
// SPDX-License-Identifier: UNLICENSED |
||||
pragma solidity ^0.8.0; |
||||
|
||||
import "./src/ReentrancyMock.sol"; |
||||
import "./libs/ReentrancyMock1.sol"; |
||||
import "./libs/ReentrancyMock2.sol"; |
||||
import "./libs/ReentrancyMock3.sol"; |
||||
|
||||
contract TestPathFiltering is ReentrancyMock, ReentrancyMock1, ReentrancyMock2, ReentrancyMock3 {} |
Loading…
Reference in new issue