Merge pull request #1303 from pcaversaccio/patch-1

Test for unification of path filtering across POSIX and Windows
pull/1395/head
Feist Josselin 2 years ago committed by GitHub
commit 7313806b7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .github/workflows/ci.yml
  2. 15
      scripts/ci_test_path_filtering.sh
  3. 14
      tests/test_path_filtering/libs/ReentrancyMock1.sol
  4. 14
      tests/test_path_filtering/libs/ReentrancyMock2.sol
  5. 14
      tests/test_path_filtering/libs/ReentrancyMock3.sol
  6. 7
      tests/test_path_filtering/slither.config.json
  7. 14
      tests/test_path_filtering/src/ReentrancyMock.sol
  8. 9
      tests/test_path_filtering/test_path_filtering.sol

@ -25,6 +25,7 @@ jobs:
type: ["cli",
"dapp",
"data_dependency",
"path_filtering",
# "embark",
"erc",
# "etherlime",

@ -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…
Cancel
Save