-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: skip free functions on func-visibility
- Loading branch information
1 parent
a2b8ea3
commit 1292516
Showing
5 changed files
with
230 additions
and
10 deletions.
There are no files selected for viewing
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
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
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
176 changes: 176 additions & 0 deletions
176
test/fixtures/security/contracts-with-free-functions.js
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,176 @@ | ||
// all contracts are made with two func-visibility errors | ||
|
||
module.exports = [ | ||
` | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.4.4; | ||
import "hardhat/console.sol"; | ||
interface fufu { | ||
function intFunction() returns(bool); | ||
function intFunction() returns(uint256); | ||
} | ||
function freeAa() returns(bool) { | ||
return true; | ||
} | ||
contract A { | ||
uint256 public a; | ||
constructor() { | ||
a = 2; | ||
} | ||
function functionPublicViewA() returns (uint256) { | ||
if (freeAa()) return a; | ||
else return a+1; | ||
} | ||
function functionPublicPureA() public pure returns (bool) { | ||
return freeAa(); | ||
} | ||
} | ||
function freeBb() returns(bool) { | ||
return true; | ||
} | ||
contract B { | ||
uint256 public a; | ||
constructor() { | ||
a = 2; | ||
} | ||
function functionPublicViewB() returns (uint256) { | ||
if (freeBb()) return a; | ||
else return a+1; | ||
} | ||
function functionPublicPureB() public pure returns (bool) { | ||
return freeCc(); | ||
} | ||
} | ||
function freeCc() returns(bool) { | ||
return true; | ||
} | ||
`, | ||
` | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.4; | ||
import "hardhat/console.sol"; | ||
function freeAa() returns(bool) { | ||
return true; | ||
} | ||
function freeBb() returns(bool) { | ||
return true; | ||
} | ||
interface fufu { | ||
function intFunction() returns(bool); | ||
function intFunction() returns(uint256); | ||
} | ||
contract A { | ||
uint256 public a; | ||
constructor() { | ||
a = 2; | ||
} | ||
function functionPublicViewA() returns (uint256) { | ||
if (freeAa()) return a; | ||
else return a+1; | ||
} | ||
function functionPublicPureA() public pure returns (bool) { | ||
return freeBb(); | ||
} | ||
} | ||
function freeCc() returns(bool) { | ||
return true; | ||
} | ||
contract B { | ||
uint256 public a; | ||
constructor() { | ||
a = 2; | ||
} | ||
function functionPublicViewB() returns (uint256) { | ||
if (freeAa()) return a; | ||
else return a+1; | ||
} | ||
function functionPublicPureB() public pure returns (bool) { | ||
return freeCc(); | ||
} | ||
} | ||
`, | ||
` | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.4; | ||
function freeCc() returns(bool) { | ||
return true; | ||
} | ||
contract A { | ||
uint256 public a; | ||
constructor() { | ||
a = 2; | ||
} | ||
function functionExternal() returns (uint256) { | ||
if (freeCc()) return a; | ||
else return a+1; | ||
} | ||
function functionPublicViewA() returns (uint256) { | ||
if (freeCc()) return a; | ||
else return a+1; | ||
} | ||
function functionPublicPureA() public pure returns (bool) { | ||
return freeCc(); | ||
} | ||
} | ||
`, | ||
` | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.4; | ||
contract A { | ||
uint256 public a; | ||
constructor() { | ||
a = 2; | ||
} | ||
function functionExternal() returns (uint256) { | ||
if (freeCc()) return a; | ||
else return a+1; | ||
} | ||
function functionPublicViewA() returns (uint256) { | ||
if (freeCc()) return a; | ||
else return a+1; | ||
} | ||
function functionPublicPureA() public pure returns (bool) { | ||
return freeCc(); | ||
} | ||
} | ||
function freeCc() returns(bool) { | ||
return true; | ||
} | ||
`, | ||
] |
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