-
Notifications
You must be signed in to change notification settings - Fork 979
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Data depencies: use fix point for function depenencies (fix #171)
Add data_depencies.get_dependencies function Add depencies printer
- Loading branch information
Showing
3 changed files
with
78 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
Module printing summary of the contract | ||
""" | ||
|
||
from prettytable import PrettyTable | ||
from slither.printers.abstract_printer import AbstractPrinter | ||
from slither.analyses.data_dependency.data_dependency import get_dependencies | ||
from slither.slithir.variables import TemporaryVariable, ReferenceVariable | ||
|
||
def _get(v, c): | ||
return [d.name for d in get_dependencies(v, c) if not isinstance(d, (TemporaryVariable, | ||
ReferenceVariable))] | ||
|
||
class DataDependency(AbstractPrinter): | ||
|
||
ARGUMENT = 'data-dependency' | ||
HELP = 'Print the data dependencies of the variables' | ||
|
||
WIKI = 'https://github.com/trailofbits/slither/wiki/Printer-documentation#data-dependencies' | ||
|
||
def output(self, _filename): | ||
""" | ||
_filename is not used | ||
Args: | ||
_filename(string) | ||
""" | ||
|
||
txt = '' | ||
for c in self.contracts: | ||
txt += "\nContract %s\n"%c.name | ||
table = PrettyTable(['Variable', 'Depenencies']) | ||
for v in c.state_variables: | ||
table.add_row([v.name, _get(v, c)]) | ||
|
||
txt += str(table) | ||
|
||
txt += "\n" | ||
for f in c.functions_and_modifiers_not_inherited: | ||
txt += "\nFunction %s\n"%f.full_name | ||
table = PrettyTable(['Variable', 'Depenencies']) | ||
for v in f.variables: | ||
table.add_row([v.name, _get(v, f)]) | ||
for v in c.state_variables: | ||
table.add_row([v.canonical_name, _get(v, f)]) | ||
txt += str(table) | ||
self.info(txt) |