Merge branch 'dev' into dev-usability

pull/172/head
Josselin 6 years ago
commit e128adabbc
  1. 21
      README.md
  2. 15
      examples/printers/data_dependencies.sol
  3. 8
      slither/printers/summary/data_depenency.py
  4. 2
      tests/expected_json/old_solc.sol.json.solc-version.json
  5. 2
      tests/expected_json/pragma.0.4.24.pragma.json
  6. 2
      tests/expected_json/solc_version_incorrect.solc-version.json

@ -95,17 +95,16 @@ Num | Printer | Description
1 | `call-graph` | [Export the call-graph of the contracts to a dot file](https://github.com/trailofbits/slither/wiki/Printer-documentation#call-graph) 1 | `call-graph` | [Export the call-graph of the contracts to a dot file](https://github.com/trailofbits/slither/wiki/Printer-documentation#call-graph)
2 | `cfg` | [Export the CFG of each functions](https://github.com/trailofbits/slither/wiki/Printer-documentation#cfg) 2 | `cfg` | [Export the CFG of each functions](https://github.com/trailofbits/slither/wiki/Printer-documentation#cfg)
3 | `contract-summary` | [Print a summary of the contracts](https://github.com/trailofbits/slither/wiki/Printer-documentation#contract-summary) 3 | `contract-summary` | [Print a summary of the contracts](https://github.com/trailofbits/slither/wiki/Printer-documentation#contract-summary)
4 | `function-id` | [Print the keccack256 signature of the functions](https://github.com/trailofbits/slither/wiki/Printer-documentation#function-id) 4 | `data-dependency` | [Print the data dependencies of the variables](https://github.com/trailofbits/slither/wiki/Printer-documentation#data-dependencies)
5 | `function-summary` | [Print a summary of the functions](https://github.com/trailofbits/slither/wiki/Printer-documentation#function-summary) 5 | `function-id` | [Print the keccack256 signature of the functions](https://github.com/trailofbits/slither/wiki/Printer-documentation#function-id)
6 | `human-summary` | [Print a human-readable summary of the contracts](https://github.com/trailofbits/slither/wiki/Printer-documentation#human-summary) 6 | `function-summary` | [Print a summary of the functions](https://github.com/trailofbits/slither/wiki/Printer-documentation#function-summary)
7 | `inheritance` | [Print the inheritance relations between contracts](https://github.com/trailofbits/slither/wiki/Printer-documentation#inheritance) 7 | `human-summary` | [Print a human-readable summary of the contracts](https://github.com/trailofbits/slither/wiki/Printer-documentation#human-summary)
8 | `inheritance-graph` | [Export the inheritance graph of each contract to a dot file](https://github.com/trailofbits/slither/wiki/Printer-documentation#inheritance-graph) 8 | `inheritance` | [Print the inheritance relations between contracts](https://github.com/trailofbits/slither/wiki/Printer-documentation#inheritance)
9 | `slithir` | [Print the slithIR representation of the functions](https://github.com/trailofbits/slither/wiki/Printer-documentation#slithir) 9 | `inheritance-graph` | [Export the inheritance graph of each contract to a dot file](https://github.com/trailofbits/slither/wiki/Printer-documentation#inheritance-graph)
10 | `slithir-ssa` | [Print the slithIR representation of the functions](https://github.com/trailofbits/slither/wiki/Printer-documentation#slithir-ssa) 10 | `slithir` | [Print the slithIR representation of the functions](https://github.com/trailofbits/slither/wiki/Printer-documentation#slithir)
11 | `variables-order` | [Print the storage order of the state variables](https://github.com/trailofbits/slither/wiki/Printer-documentation#variables-written-and-authorization) 11 | `slithir-ssa` | [Print the slithIR representation of the functions](https://github.com/trailofbits/slither/wiki/Printer-documentation#slithir-ssa)
12 | `vars-and-auth` | [Print the state variables written and the authorization of the functions](https://github.com/trailofbits/slither/wiki/Printer-documentation#variables-written-and-authorization) 12 | `variables-order` | [Print the storage order of the state variables](https://github.com/trailofbits/slither/wiki/Printer-documentation#variables-written-and-authorization)
13 | `vars-and-auth` | [Print the state variables written and the authorization of the functions](https://github.com/trailofbits/slither/wiki/Printer-documentation#variables-written-and-authorization)## How to install
## How to install
Slither requires Python 3.6+ and [solc](https://github.com/ethereum/solidity/), the Solidity compiler. Slither requires Python 3.6+ and [solc](https://github.com/ethereum/solidity/), the Solidity compiler.

@ -0,0 +1,15 @@
contract MyContract{
uint a = 0;
uint b = 0;
uint c = 0;
function setA(uint input_a, uint input_b) public{
setB(input_b);
a = input_a;
}
function setB(uint input) internal{
b = input;
}
}

@ -8,8 +8,8 @@ from slither.analyses.data_dependency.data_dependency import get_dependencies
from slither.slithir.variables import TemporaryVariable, ReferenceVariable from slither.slithir.variables import TemporaryVariable, ReferenceVariable
def _get(v, c): def _get(v, c):
return [d.name for d in get_dependencies(v, c) if not isinstance(d, (TemporaryVariable, return list(set([d.name for d in get_dependencies(v, c) if not isinstance(d, (TemporaryVariable,
ReferenceVariable))] ReferenceVariable))]))
class DataDependency(AbstractPrinter): class DataDependency(AbstractPrinter):
@ -28,7 +28,7 @@ class DataDependency(AbstractPrinter):
txt = '' txt = ''
for c in self.contracts: for c in self.contracts:
txt += "\nContract %s\n"%c.name txt += "\nContract %s\n"%c.name
table = PrettyTable(['Variable', 'Depenencies']) table = PrettyTable(['Variable', 'Dependencies'])
for v in c.state_variables: for v in c.state_variables:
table.add_row([v.name, _get(v, c)]) table.add_row([v.name, _get(v, c)])
@ -37,7 +37,7 @@ class DataDependency(AbstractPrinter):
txt += "\n" txt += "\n"
for f in c.functions_and_modifiers_not_inherited: for f in c.functions_and_modifiers_not_inherited:
txt += "\nFunction %s\n"%f.full_name txt += "\nFunction %s\n"%f.full_name
table = PrettyTable(['Variable', 'Depenencies']) table = PrettyTable(['Variable', 'Dependencies'])
for v in f.variables: for v in f.variables:
table.add_row([v.name, _get(v, f)]) table.add_row([v.name, _get(v, f)])
for v in c.state_variables: for v in c.state_variables:

@ -1 +1 @@
[{"check": "solc-version", "impact": "Informational", "confidence": "High", "description": "Old version (<0.4.23) of Solidity used in tests/old_solc.sol.json:\n\t- old_solc.sol declares pragma solidity0.4.21\n", "elements": [], "expressions": [{"expression": "0.4.21", "source_mapping": {"start": 0, "length": 23, "filename": "old_solc.sol", "lines": []}}]}] [{"check": "solc-version", "impact": "Informational", "confidence": "High", "description": "Detected issues with version pragma in tests/old_solc.sol.json:\n\t- pragma solidity0.4.21 (old_solc.sol): it allows old versions\n", "elements": [{"type": "expression", "expression": "0.4.21", "source_mapping": {"start": 0, "length": 23, "filename": "old_solc.sol", "lines": []}}]}]

@ -1 +1 @@
[{"check": "pragma", "impact": "Informational", "confidence": "High", "description": "Different versions of Solidity is used in tests/pragma.0.4.24.sol:\n\t- Version used: ['^0.4.23', '^0.4.24']\n\t- tests/pragma.0.4.23.sol#1 declares pragma solidity^0.4.23\n\t- tests/pragma.0.4.24.sol#1 declares pragma solidity^0.4.24\n", "elements": [], "expressions": [{"expression": "^0.4.23", "source_mapping": {"start": 0, "length": 24, "filename": "tests/pragma.0.4.23.sol", "lines": [1]}}, {"expression": "^0.4.24", "source_mapping": {"start": 0, "length": 24, "filename": "tests/pragma.0.4.24.sol", "lines": [1]}}]}] [{"check": "pragma", "impact": "Informational", "confidence": "High", "description": "Different versions of Solidity is used in tests/pragma.0.4.24.sol:\n\t- Version used: ['^0.4.23', '^0.4.24']\n\t- tests/pragma.0.4.23.sol#1 declares pragma solidity^0.4.23\n\t- tests/pragma.0.4.24.sol#1 declares pragma solidity^0.4.24\n", "elements": [{"type": "expression", "expression": "^0.4.23", "source_mapping": {"start": 0, "length": 24, "filename": "tests/pragma.0.4.23.sol", "lines": [1]}}, {"type": "expression", "expression": "^0.4.24", "source_mapping": {"start": 0, "length": 24, "filename": "tests/pragma.0.4.24.sol", "lines": [1]}}]}]

@ -1 +1 @@
[{"check": "solc-version", "impact": "Informational", "confidence": "High", "description": "Detected issues with version pragma in tests/solc_version_incorrect.sol:\n\t- pragma solidity^0.4.23 (tests/solc_version_incorrect.sol#2): it allows old versions\n\t- pragma solidity>=0.4.0<0.6.0 (tests/solc_version_incorrect.sol#3): it allows old versions\n", "elements": [], "expressions": [{"expression": "^0.4.23", "source_mapping": {"start": 63, "length": 24, "filename": "tests/solc_version_incorrect.sol", "lines": [2]}}, {"expression": ">=0.4.0<0.6.0", "source_mapping": {"start": 89, "length": 31, "filename": "tests/solc_version_incorrect.sol", "lines": [3]}}]}] [{"check": "solc-version", "impact": "Informational", "confidence": "High", "description": "Detected issues with version pragma in tests/solc_version_incorrect.sol:\n\t- pragma solidity^0.4.23 (tests/solc_version_incorrect.sol#2): it allows old versions\n\t- pragma solidity>=0.4.0<0.6.0 (tests/solc_version_incorrect.sol#3): it allows old versions\n", "elements": [{"type": "expression", "expression": "^0.4.23", "source_mapping": {"start": 63, "length": 24, "filename": "tests/solc_version_incorrect.sol", "lines": [2]}}, {"type": "expression", "expression": ">=0.4.0<0.6.0", "source_mapping": {"start": 89, "length": 31, "filename": "tests/solc_version_incorrect.sol", "lines": [3]}}]}]
Loading…
Cancel
Save