slither-disable-next-line does not always work on lines
- Dominant language
- Python
- Stars
- 6.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
I'm excited about the addition of `slither-disable-next-line`, and have been testing it from master.
It took me a little while to get it working, because the "line" that the detectors work off might be the function as a whole.
For example, suppose I wanted to disable the warning, in the following contract. This doesn't work, but is the intuitive way:
```
contract Foo {
function bar(address payable z) external returns(uint256) {
// slither-disable-next-line suicidal
selfdestruct(address(z)); // error here
return 1;
}
}
```
This works:
```
contract Foo {
// slither-disable-next-line suicidal
function bar(address payable z) external returns(uint256) {
selfdestruct(address(z));
return 1;
}
}
```
It looks like this is because the detector for `suicidal` works on functions, not lines.
(https://github.com/crytic/slither/blob/081a0717efbf983c567602d982a09780f7d74920/slither/detectors/functions/suicidal.py)
Perhaps the name `slither-disable-next-line` should be changed to something that matches the actual behavior?
Contributor guide
Assessment
This issue has not been assessed yet.