Merge branch 'dev' into dev-ssa

pull/87/head
Josselin 6 years ago
commit 73a668945d
  1. 16
      slither/__main__.py
  2. 4
      slither/core/cfg/node.py
  3. 6
      slither/detectors/attributes/locked_ether.py
  4. 4
      slither/solc_parsing/declarations/function.py

@ -78,14 +78,15 @@ def process_truffle(dirname, args, detector_classes, printer_classes):
filenames = glob.glob(os.path.join(dirname, 'build', 'contracts', '*.json'))
return process_files(filenames, args, detector_classes, printer_classes)
def process_files(filenames, args, detector_classes, printer_classes):
all_contracts = []
all_filenames = []
for filename in filenames:
with open(filename) as f:
contract_loaded = json.load(f)
all_contracts.append(contract_loaded['ast'])
all_filenames.append(contract_loaded['sourcePath'])
slither = Slither(all_contracts, args.solc, args.disable_solc_warnings, args.solc_args)
return _process(slither, detector_classes, printer_classes)
@ -243,10 +244,13 @@ def main_impl(all_detector_classes, all_printer_classes):
elif os.path.isdir(filename) or len(globbed_filenames) > 0:
extension = "*.sol" if not args.solc_ast else "*.json"
filenames = glob.glob(os.path.join(filename, extension))
if len(filenames) == 0:
if not filenames:
filenames = globbed_filenames
number_contracts = 0
results = []
if args.splitted and args.solc_ast:
(results, number_contracts) = process_files(filenames, args, detector_classes, printer_classes)
else:
for filename in filenames:
(results_tmp, number_contracts_tmp) = process(filename, args, detector_classes, printer_classes)
number_contracts += number_contracts_tmp
@ -398,6 +402,12 @@ def parse_args(detector_classes, printer_classes):
action='store_true',
default=False)
# if the json is splitted in different files
parser.add_argument('--splitted',
help=argparse.SUPPRESS,
action='store_true',
default=False)
if len(sys.argv) == 1:
parser.print_help(sys.stderr)
sys.exit(1)

@ -236,6 +236,10 @@ class Node(SourceMapping, ChildFunction):
"""
return self._node_type
@type.setter
def type(self, t):
self._node_type = t
@property
def variables_read(self):
"""

@ -5,7 +5,7 @@
from slither.detectors.abstract_detector import (AbstractDetector,
DetectorClassification)
from slither.slithir.operations import (HighLevelCall, LowLevelCall, Send,
Transfer)
Transfer, NewContract)
class LockedEther(AbstractDetector):
@ -28,7 +28,7 @@ class LockedEther(AbstractDetector):
return False
for node in function.nodes:
for ir in node.irs:
if isinstance(ir, (Send, Transfer, HighLevelCall, LowLevelCall)):
if isinstance(ir, (Send, Transfer, HighLevelCall, LowLevelCall, NewContract)):
if ir.call_value and ir.call_value != 0:
return False
if isinstance(ir, (LowLevelCall)):
@ -50,7 +50,7 @@ class LockedEther(AbstractDetector):
txt += "\tContract {} has payable functions:\n".format(contract.name)
for function in funcs_payable:
txt += "\t - {} ({})\n".format(function.name, function.source_mapping_str)
txt += "\tBut has not function to withdraw the ether\n"
txt += "\tBut does not have a function to withdraw the ether\n"
info = txt.format(self.filename,
contract.name,
[f.name for f in funcs_payable])

@ -948,12 +948,16 @@ class FunctionSolc(Function):
if node.type == NodeType.VARIABLE:
assert isinstance(true_expr, AssignmentOperation)
#true_expr = true_expr.expression_right
elif node.type == NodeType.RETURN:
true_node.type = NodeType.RETURN
true_node.add_expression(true_expr)
true_node.analyze_expressions(self)
false_node = self._new_node(NodeType.EXPRESSION, node.source_mapping)
if node.type == NodeType.VARIABLE:
assert isinstance(false_expr, AssignmentOperation)
elif node.type == NodeType.RETURN:
false_node.type = NodeType.RETURN
#false_expr = false_expr.expression_right
false_node.add_expression(false_expr)
false_node.analyze_expressions(self)

Loading…
Cancel
Save