slither icon indicating copy to clipboard operation
slither copied to clipboard

Constants detector: Also detect Contract types

Open JorgeAtPaladin opened this issue 3 years ago • 1 comments

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)

JorgeAtPaladin avatar Sep 16 '22 20:09 JorgeAtPaladin

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Sep 16 '22 20:09 CLAassistant

@0xalpharush merged the two PRs, thanks for giving it a test run :+1:

JorgeAtPaladin avatar Sep 29 '22 19:09 JorgeAtPaladin

@0xalpharush blindly merged your fix (yet again), sorry for not properly reviewing these.

JorgeAtPaladin avatar Oct 03 '22 11:10 JorgeAtPaladin

Can you run pylint and black https://github.com/crytic/slither/blob/master/CONTRIBUTING.md#linters please?

0xalpharush avatar Oct 03 '22 13:10 0xalpharush

Yep, will take care of this somewhere next week!

JorgeAtPaladin avatar Oct 05 '22 20:10 JorgeAtPaladin

Thanks @JorgeAtPaladin for the contribution. I made minor improvements and merged the PR with #1443

montyly avatar Oct 26 '22 12:10 montyly