Repository: crytic/slither

Issue:
Slither misses some obvious dependency relations
```

pragma solidity ^0.4.24;

contract SlitherBug {
  uint256 rID_;
  bool public activated_ = false;

  modifier isHuman() {
    require(msg.sender == tx.origin, "sorry humans only");
    _;
  }
  
  // Function not vulnerable to re-entrancy attack

    function withdraw()
    isHuman()
    public {
        uint256 _rID = rID_;
  }
}

```


In the above contract slither outputs empty dependencies for the local varaible `_rID`. which is wrong. `_rID` is dependent on the state variable `_rID`.

My code to extract the dependency:

```
from slither.slither import Slither
import slither

slither_obj = Slither('slither_bug.sol')

for contract in slither_obj.contracts:
	if contract.name == 'SlitherBug':
		cont = contract

for function in cont.functions:
	if function.name == 'withdraw':
		func = function

node = func.nodes[1]

dep = slither.analyses.data_dependency.data_dependency.get_dependencies(node.irs[0].lvalue, func)

print(dep)
```

If I remove the line `require(msg.sender == tx.origin, "sorry humans only");` from the `modifier isHuman()` it outputs the state variable `_rID` as dependency; which is valid. 

Possibly a slither bug. Can you please look into this issue?

Slither misses some obvious dependency relations
```

pragma solidity ^0.4.24;

contract SlitherBug {
  uint256 rID_;
  bool public activated_ = false;

  modifier isHuman() {
    require(msg.sender == tx.origin, "sorry humans only");
    _;
  }
  
  // Function not vulnerable to re-entrancy attack

    function withdraw()
    isHuman()
    public {
        uint256 _rID = rID_;
  }
}

```


In the above contract slither outputs empty dependencies for the local varaible `_rID`. which is wrong. `_rID` is dependent on the state variable `_rID`.

My code to extract the dependency:

```
from slither.slither import Slither
import slither

slither_obj = Slither('slither_bug.sol')

for contract in slither_obj.contracts:
	if contract.name == 'SlitherBug':
		cont = contract

for function in cont.functions:
	if function.name == 'withdraw':
		func = function

node = func.nodes[1]

dep = slither.analyses.data_dependency.data_dependency.get_dependencies(node.irs[0].lvalue, func)

print(dep)
```

If I remove the line `require(msg.sender == tx.origin, "sorry humans only");` from the `modifier isHuman()` it outputs the state variable `_rID` as dependency; which is valid. 

Possibly a slither bug. Can you please look into this issue?



Discussion:
Hi @PriyankaBose, thank you for reporting the issue. 

I confirm that I can reproduce this behavior, I will look into it. 
Hi @PriyankaBose, thank you for reporting the issue. 

I confirm that I can reproduce this behavior, I will look into it. 

Resolving patch:
diff --git a/slither/analyses/data_dependency/data_dependency.py b/slither/analyses/data_dependency/data_dependency.py
--- a/slither/analyses/data_dependency/data_dependency.py
+++ b/slither/analyses/data_dependency/data_dependency.py
@@ -114,8 +114,8 @@ def get_dependencies(variable, context, only_unprotected=False):
     assert isinstance(context, (Contract, Function))
     assert isinstance(only_unprotected, bool)
     if only_unprotected:
-        return context.context[KEY_NON_SSA].get(variable, [])
-    return context.context[KEY_NON_SSA_UNPROTECTED].get(variable, [])
+        return context.context[KEY_NON_SSA_UNPROTECTED].get(variable, [])
+    return context.context[KEY_NON_SSA].get(variable, [])
 
 # endregion
 ###################################################################################


Test patch: