[Bug-Candidate]: dangerous-strict-equalities does not consider "or" or "else"
- Dominant language
- Python
- Stars
- 6.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the issue:
`dangerous-strict-equalities`
Does not consider "else" statements or "or" statements:
### Code example to reproduce the issue:
```solidity
function _safeTransfer(address token, address to, uint256 value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'SomaSwap: TRANSFER_FAILED');
}
```
```solidity
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
// Here we mint to the factory instead of self, because the burn requires burning all of tokens on self
_mint(factory, MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
```
### Version:
0.8.3
### Relevant log output:
```shell
SomaSwapPair._safeTransfer(address,address,uint256) (contracts/soma/SomaSwap/core/SomaSwapPair.sol#110-113) uses a dangerous strict equality:
- require(bool,string)(success && (data.length == 0 || abi.decode(data,(bool))),SomaSwap: TRANSFER_FAILED) (contracts/soma/SomaSwap/core/SomaSwapPair.sol#112)
SomaSwapPair.mint(address) (contracts/soma/SomaSwap/core/SomaSwapPair.sol#154-176) uses a dangerous strict equality:
- _totalSupply == 0 (contracts/soma/SomaSwap/core/SomaSwapPair.sol#163)
```
Contributor guide
Research direction
Start with the dangerous-strict-equalities rule and reproduce the report using the Solidity examples in SomaSwapPair._safeTransfer and SomaSwapPair.mint. Check how equality expressions inside the require condition and the if/else branch are analyzed; done means the rule consistently handles the reported "or" and "else" cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, solidity
- Domain
- security, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100