예제 #1
0
파일: node.py 프로젝트: w1r2p1/slither
    def analyze_expressions(self, caller_context):
        if self.type == NodeType.VARIABLE and not self._expression:
            self._expression = self.variable_declaration.expression
        if self._unparsed_expression:
            expression = parse_expression(self._unparsed_expression, caller_context)
            self._expression = expression
            self._unparsed_expression = None

        if self.expression:
            expression = self.expression
            pp = ReadVar(expression)
            self._expression_vars_read = pp.result()
            vars_read = [ExportValues(v).result() for v in self._expression_vars_read]
            self._vars_read = [item for sublist in vars_read for item in sublist]
            self._state_vars_read = [x for x in self.variables_read if\
                                     isinstance(x, (StateVariable))]
            self._solidity_vars_read = [x for x in self.variables_read if\
                                        isinstance(x, (SolidityVariable))]

            pp = WriteVar(expression)
            self._expression_vars_written = pp.result()
            vars_written = [ExportValues(v).result() for v in self._expression_vars_written]
            self._vars_written = [item for sublist in vars_written for item in sublist]
            self._state_vars_written = [x for x in self.variables_written if\
                                        isinstance(x, StateVariable)]

            pp = FindCalls(expression)
            self._expression_calls = pp.result()
            calls = [ExportValues(c).result() for c in self.calls_as_expression]
            calls = [item for sublist in calls for item in sublist]
            self._internal_calls = [c for c in calls if isinstance(c, (Function, SolidityFunction))]

            self._external_calls = [c for c in self.calls_as_expression if not isinstance(c.called, Identifier)]
예제 #2
0
    def analyze_expressions(self, caller_context):
        if self._node.type == NodeType.VARIABLE and not self._node.expression:
            self._node.add_expression(
                self._node.variable_declaration.expression)
        if self._unparsed_expression:
            expression = parse_expression(self._unparsed_expression,
                                          caller_context)
            self._node.add_expression(expression)
            # self._unparsed_expression = None

        if self._node.expression:

            if self._node.type == NodeType.VARIABLE:
                # Update the expression to be an assignement to the variable
                _expression = AssignmentOperation(
                    Identifier(self._node.variable_declaration),
                    self._node.expression,
                    AssignmentOperationType.ASSIGN,
                    self._node.variable_declaration.type,
                )
                _expression.set_offset(self._node.expression.source_mapping,
                                       self._node.slither)
                self._node.add_expression(_expression, bypass_verif_empty=True)

            expression = self._node.expression
            read_var = ReadVar(expression)
            self._node.variables_read_as_expression = read_var.result()

            write_var = WriteVar(expression)
            self._node.variables_written_as_expression = write_var.result()

            find_call = FindCalls(expression)
            self._node.calls_as_expression = find_call.result()
            self._node.external_calls_as_expressions = [
                c for c in self._node.calls_as_expression
                if not isinstance(c.called, Identifier)
            ]
            self._node.internal_calls_as_expressions = [
                c for c in self._node.calls_as_expression
                if isinstance(c.called, Identifier)
            ]
예제 #3
0
파일: node.py 프로젝트: wangke0809/slither
    def analyze_expressions(self, caller_context):
        if self.type == NodeType.VARIABLE and not self._expression:
            self._expression = self.variable_declaration.expression
        if self._unparsed_expression:
            expression = parse_expression(self._unparsed_expression,
                                          caller_context)
            self._expression = expression
            self._unparsed_expression = None

        if self.expression:

            if self.type == NodeType.VARIABLE:
                # Update the expression to be an assignement to the variable
                #print(self.variable_declaration)
                _expression = AssignmentOperation(
                    Identifier(self.variable_declaration), self.expression,
                    AssignmentOperationType.ASSIGN,
                    self.variable_declaration.type)
                _expression.set_offset(self.expression.source_mapping,
                                       self.slither)
                self._expression = _expression

            expression = self.expression
            pp = ReadVar(expression)
            self._expression_vars_read = pp.result()

            #            self._vars_read = [item for sublist in vars_read for item in sublist]
            #            self._state_vars_read = [x for x in self.variables_read if\
            #                                     isinstance(x, (StateVariable))]
            #            self._solidity_vars_read = [x for x in self.variables_read if\
            #                                        isinstance(x, (SolidityVariable))]

            pp = WriteVar(expression)
            self._expression_vars_written = pp.result()

            #            self._vars_written = [item for sublist in vars_written for item in sublist]
            #            self._state_vars_written = [x for x in self.variables_written if\
            #                                        isinstance(x, StateVariable)]

            pp = FindCalls(expression)
            self._expression_calls = pp.result()
            self._external_calls_as_expressions = [
                c for c in self.calls_as_expression
                if not isinstance(c.called, Identifier)
            ]
            self._internal_calls_as_expressions = [
                c for c in self.calls_as_expression
                if isinstance(c.called, Identifier)
            ]