コード例 #1
0
ファイル: injection_sql.py プロジェクト: Daviey/bandit
def _ast_build_string(data):
    # used to return a string representation of AST data

    if isinstance(data, ast.Str):
        # Already a string, just return the value
        return utils.safe_str(data.s)

    if isinstance(data, ast.BinOp):
        # need to build the string from a binary operation
        return _ast_binop_stringify(data)

    if isinstance(data, ast.Name):
        # a variable, stringify the variable name
        return "[[" + utils.safe_str(data.id) + "]]"

    return "XXX"  # placeholder for unaccounted for values
コード例 #2
0
ファイル: injection_sql.py プロジェクト: woodrow/bandit
def _ast_build_string(data):
    # used to return a string representation of AST data

    if isinstance(data, ast.Str):
        # Already a string, just return the value
        return utils.safe_str(data.s)

    if isinstance(data, ast.BinOp):
        # need to build the string from a binary operation
        return _ast_binop_stringify(data)

    if isinstance(data, ast.Name):
        # a variable, stringify the variable name
        return "[[" + utils.safe_str(data.id) + "]]"

    return "XXX"  # placeholder for unaccounted for values
コード例 #3
0
    def string_val(self):
        '''Get a string value of a standalone string

        :return: String value of a standalone string
        '''
        if 'str' in self._context:
            return utils.safe_str(self._context['str'])
        else:
            return None