mirror of https://github.com/crytic/slither
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.5 KiB
56 lines
1.5 KiB
6 years ago
|
// This tests against false-positives. This test should output no recommendations from the external-function detector.
|
||
|
|
||
|
|
||
4 years ago
|
abstract contract ContractWithBaseFunctionCalled {
|
||
|
function getsCalledByBase() public virtual;
|
||
6 years ago
|
function callsOverrideMe() external {
|
||
|
getsCalledByBase();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
contract DerivingContractWithBaseCalled is ContractWithBaseFunctionCalled {
|
||
4 years ago
|
function getsCalledByBase() public override {
|
||
6 years ago
|
// This should not be recommended to be marked external because it is called by the base class.
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
// All the contracts below should not recommend changing to external since inherited contracts have dynamic calls.
|
||
|
contract ContractWithDynamicCall {
|
||
|
function() returns(uint) ptr;
|
||
|
|
||
|
function test1() public returns(uint){
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
function test2() public returns(uint){
|
||
|
return 2;
|
||
|
}
|
||
|
|
||
6 years ago
|
function setTest1() external{
|
||
6 years ago
|
ptr = test1;
|
||
|
}
|
||
|
|
||
6 years ago
|
function setTest2() external{
|
||
6 years ago
|
ptr = test2;
|
||
|
}
|
||
|
|
||
|
function exec() external returns(uint){
|
||
|
return ptr();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
contract DerivesFromDynamicCall is ContractWithDynamicCall{
|
||
|
function getsCalledDynamically() public returns (uint){
|
||
|
// This should not be recommended because it is called dynamically.
|
||
|
return 3;
|
||
|
}
|
||
6 years ago
|
function setTest3() public {
|
||
6 years ago
|
// This should not be recommended because we inherit from a contract that calls dynamically, and we cannot be
|
||
|
// sure it did not somehow call this function.
|
||
|
|
||
|
ptr = getsCalledDynamically;
|
||
|
}
|
||
6 years ago
|
}
|