duaraghav8 / Ethlint

(Formerly Solium) Code quality & Security Linter for Solidity
https://ethlint.readthedocs.io/en/latest/
MIT License
927 stars 128 forks source link

Rules Wishlist #44

Open federicobond opened 7 years ago

federicobond commented 7 years ago

This is my wishlist for additional rules. Let me know if you are against any of them getting implemented in the core. I will work on some of them but anything else is up for grabs.

maraoz commented 7 years ago

Ensure fallback function has payable modifier

Not always desirable. See for example: https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/Rejector.sol

federicobond commented 7 years ago

Updated. Thanks @maraoz!

duaraghav8 commented 7 years ago

Agreed with @maroz and no issues with the rest.

My plan was to separate the linter into 2 layers - the base would only ensure compliance with the Solidity Style Guide.

The 2nd layer contains all the additional rules (like you've stated above) coming from the community. But this layer is optional and therefore can be enabled / disabled by the user at any time.

Until now, I've only been working with the Base. I think we should follow the 2-layer approach. What do you think

federicobond commented 7 years ago

Eslint has some notion of rulesets. See here. Perhaps we can do something similar with Solium rules, where you can choose to enable the base or core ruleset or something more complete.

I must confess I am not a big fan of the current --sync implementation. I believe that most users will forget to do that and lose out on newly developed rules. It's better to allow users to define a base ruleset and add/remove rules as overrides to the base ruleset(s).

duaraghav8 commented 7 years ago

You're right, we should deprecate --sync and have a configuration file system instead. Something similar to ESLint's.

I'll blog the final plan before I start implementing it but let me know if you have ideas of your own.

duaraghav8 commented 7 years ago

Also Rule proposal:

federicobond commented 7 years ago

Rule:

See: https://ethereum.karalabe.com/talks/2016-hackethon.html#10

P.S. Is there a secure case for this construct? Or are all its uses insecure?

federicobond commented 7 years ago
federicobond commented 7 years ago
federicobond commented 7 years ago

As a general rule, a linter for smart contracts should be very strict with spacing around all keywords, operators, etc. to avoid these problems.

federicobond commented 7 years ago
Sjors commented 7 years ago

See ConsenSys best practices. Or is there any situation where this is not possible?

Sjors commented 7 years ago
duaraghav8 commented 6 years ago

All security-related rules finalized in this thread are being implemented at https://github.com/duaraghav8/solium-plugin-security

mushketyk commented 6 years ago

Ensure send return value is checked

I was thinking about implementing this rule, and it seems that to avoid false positives we should keep track of all variables of type address and then check if method send is called on any of them. But if we are processing a contract that inherits from other contracts we would first have to get all variables of type address in all parent contracts. To do this, we need to ensure that a rule is processing parent contracts first, collect a set of addresses in parent contracts, and then check if send is called on any of addresses.

Do you think Solium should support something like this? Am I overthinking this?

duaraghav8 commented 6 years ago

@mushketyk you're not overthinking. There are several rules which are on pause because of this problem of Solium only being file-aware instead of project-aware, ie, at any given time, a rule only has context of 1 file whereas it should have context of the entire project so any external elements can also be considered. This problem is well documented in #83

Let's keep this rule on hold for now, because making solium project-aware is a major design change so it will take time. I'll work on it in near future.