slither
slither copied to clipboard
Constants detector: Also detect Contract types
Presently the constants detector does not detect Contract types.
Eg.
IERC20 public token = IERC20(0x0000000000000000000000000000000000000000);
This is not a big deal as hardcoding addresses like that is generally an anti-pattern. However, if someone ever forks the detector for immutable flagging, than this will definitely come in handy!
Please do test before merging: we use the slither python API and not the detector framework ourselves.
This pull request specifically checks that if the candidate type is not Elementary, it must be a user defined Contract.
Let us know if it makes sense to invert the check and perhaps focus on ignoring dynamic types instead (because this PR still doesn't catch const enums I think for example, or re-typed int's, though that's also easily extendable)
@0xalpharush merged the two PRs, thanks for giving it a test run :+1:
@0xalpharush blindly merged your fix (yet again), sorry for not properly reviewing these.
Can you run pylint and black https://github.com/crytic/slither/blob/master/CONTRIBUTING.md#linters please?
Yep, will take care of this somewhere next week!
Thanks @JorgeAtPaladin for the contribution. I made minor improvements and merged the PR with #1443