Replace the data dependency by a context sensitive analysis
- Dominant language
- Python
- Stars
- 6.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Right now the data dependency is context insensitive, which creates a large over approximation.
For example in
```solidity
contract A{
uint a;
uint b;
function f(uint x) internal returns(uint){
return x;
}
function test1(uint paramA) public{
a = f(paramA);
}
function test2(uint paramB) public{
b = f(paramB);
}
}
```
Slither will merge all the deps related to the call to `f(x)` when looking at the contract context. As a result, a dependency between `a` and `paramB`(or `b` and `paramA`) will be created, because the the analysis will merge all the callers of `f` :
```
$ slither test.sol --print data-dependency
Contract A
+----------+---------------------------+
| Variable | Dependencies |
+----------+---------------------------+
| a | ['paramA', 'paramB', 'x'] |
| b | ['paramA', 'paramB', 'x'] |
+----------+---------------------------+
```
Having a context-sensitive analysis will lead to bette results. This is also a recurring issues with top-level functions - which tend to be called from a lot of different contexts.
Moving toward a context sensitive analysis will have an impact on the performance. We could propose the two options (sensitive/insensitive), and allow the user to enable one or the other.
Additionally we should take the opportunity to refactor the data dependency to better support the switch between the context and the different source type:
https://github.com/crytic/slither/blob/26659c4e0555c20eca037945aaec76b7639b00a7/slither/analyses/data_dependency/data_dependency.py#L47-L50
https://github.com/crytic/slither/blob/26659c4e0555c20eca037945aaec76b7639b00a7/slither/analyses/data_dependency/data_dependency.py#L62-L63
Contributor guide
Assessment
This issue has not been assessed yet.