Package bakmei :: Module sql_singleton :: Class sql_singleton |

[show private | hide private]
[frames | no frames]

## Type sql_singleton

    object --+
             |
            sql_singleton

A singleton used to store the SQL connection

Author: Cameron Hotchkies

Contact: chotchkies@tippingpoint.com

Organization: www.tippingpoint.com

License: GNU General Public License 2.0 or later

Method Summary
| ``__init__`(self)` Create singleton instance
| ``__getattr__`(self, attr)` Delegate access to implementation
| ``__setattr__`(self, attr, value)` Delegate access to implementation
| ``connection`(self, DSN)` Get the SQL connection object.
| ``create_bakmei_database`(self, DSN)` Creates the schema for a Bak Mei database at the given DSN.
cursor | ``cursor`(self)` Get the SQL cursor object for the current connection.
tuple | ``extract_DSN_values`(DSN)` To be honest this is not really a standard DSN format, kind of a hack that looks similar and I call it DSN
[dict] | ``select_args`(self, DSN, function_id)` Retrieve the arguments of the function.
dict | ``select_basic_block`(self, DSN, basic_block_id)` Retrieve the attributes of the basic block.
Integer | ``select_basic_block_num_instructions`(self, DSN, basic_block_id)` Retrieve the number of instructions contained in the basic block.
[Integer] | ``select_basic_block_sorted_instructions`(self, DSN, basic_block_id)` Retrieve the instructions contained in the basic block ordered by address.
dict | ``select_frame_info`(self, DSN, function_id)` Retrieve the frame information for the function.
dict | ``select_function`(self, DSN, function_id)` Retrieve the attributes of the function.
Integer | ``select_function_basic_block_by_address`(self, DSN, function_id, address)` Retrieve the basic block in the function containing the given address.
tuple | ``select_function_basic_block_references`(self, DSN, function_id)` Retrieve the basic block cross references for the function.
[Integer] | ``select_function_basic_blocks`(self, DSN, function_id)` Retrieve the basic blocks contained in the function.
[integer] | ``select_function_instruction_references_to`(self, DSN, function_id)` Retrieve a list of instructions that reference the given function.
Integer | ``select_function_num_instructions`(self, DSN, function_id)` Retrieve the number of instructions contained in the function.
Integer | ``select_function_num_vars`(self, DSN, function_id, var_type)` Retrieve the number of a given type of variables in the function.
dict | ``select_instruction`(self, DSN, instruction_id)` Retrieve the attributes of the instruction.
[Integer] | ``select_instruction_operands`(self, DSN, instruction_id)` Retrieve the operands of the instruction.
[Integer] | ``select_instruction_references_to`(self, DSN, instruction_id)` Retrieve the instructions that reference the given instruction.
[dict] | ``select_local_vars`(self, DSN, function_id)` Retrieve the local variables of the function.
dict | ``select_module`(self, DSN, module_id)` Retrieve all the attributes of the given module
(Integer, Integer) | ``select_module_function_references`(self, DSN, module_id)` Returns a list of tuples consisting of the source function address and the destination function address.
[Integer] | ``select_module_functions`(self, DSN, module_id)` Retrieve all the function IDs that are contained in the given module
[Integer] | ``select_module_imported_functions`(self, DSN, module_id)` Retrieve all the function IDs that are imported into the given module
Integer | ``select_module_instruction_by_address`(self, DSN, module_id, address)` Retrieve all the instruction ID that corresponds to the address in the given module
[Integer] | ``select_module_library_functions`(self, DSN, module_id)` Retrieve all the function IDs that are inline library calls for the given module
Integer | ``select_module_num_functions`(self, DSN, module_id)` Retrieve the number of functions contained in the given module
[(Integer, String)] | ``select_modules`(self, DSN)` Retrieve the name and IDs of all modules in the database.
dict | ``select_operand`(self, DSN, operand_id)` Retrieve the attributes of the operand.
List | ``select_rpc_functions`(self, DSN, module_id)` Retrieve all the RPC function IDs for the given module
List | ``select_rpc_functions_by_uuid`(self, DSN, module_id, uuid)` Retrieve all the RPC function IDs for the given UUID in the module
List | ``select_rpc_uuids`(self, DSN, module_id)` Retrieve all the RPC UUIDs for the given module
| `sql_safe_str(self, string_val)`
| `test(self)`
| ``update_basic_block_end_address`(self, DSN, basic_block_id, address)` Update the ending address of a basic block in the database.
| ``update_basic_block_start_address`(self, DSN, basic_block_id, address)` Update the starting address of a basic block in the database.
| ``update_function_arg_size`(self, DSN, function_id, size)` Update the function argument size for a function in the database.
| ``update_function_end_address`(self, DSN, function_id, address)` Update the ending address of a function in the database.
| ``update_function_exported`(self, DSN, function_id, exported)` Update the flags for a function in the database.
| ``update_function_flags`(self, DSN, function_id, flags)` Update the flags for a function in the database.
| ``update_function_frame_size`(self, DSN, function_id, size)` Update the frame size for a function in the database.
| ``update_function_local_var_size`(self, DSN, function_id, size)` Update the local variable size for a function in the database.
| ``update_function_name`(self, DSN, function_id, name)` Update the name of a function in the database.
| ``update_function_ret_size`(self, DSN, function_id, size)` Update the return variable size for a function in the database.
| ``update_function_saved_reg_size`(self, DSN, function_id, size)` Update the saved registers size for a function in the database.
| ``update_function_start_address`(self, DSN, function_id, address)` Update the starting address of a function in the database.
| ``update_instruction_address`(self, DSN, instruction_id, address)` Update the address of an instruction in the database.
| ``update_instruction_bytes`(self, DSN, instruction_id, byte_string)` Update the bytes of an instruction in the database.
| ``update_instruction_comment`(self, DSN, instruction_id, comment)` Update the comment on an instruction in the database.
| ``update_instruction_flags`(self, DSN, instruction_id, flags)` Update the flags of an instruction in the database.
| ``update_instruction_mnemonic`(self, DSN, instruction_id, mnemonic)` Update the mnemonic of an instruction in the database.
| ``update_instruction_operand`(self, DSN, instruction_id, operand_seq, value)` Update the operand of an instruction.
| ``update_module_base`(self, DSN, module_id, base)` Update the module base address in the database.
| ``update_module_comment`(self, DSN, module_id, comment, author)` Update the module comment in the database.
| ``update_module_name`(self, DSN, module_id, name)` Update the module name in the database.
| ``update_module_signature`(self, DSN, module_id, signature)` Update the module signature in the database.
| ``update_operand_text`(self, DSN, operand_id, text)` Update the text of an operand in the database.
Inherited from object
| ``__delattr__`(...)` x.__delattr__('name') <==> del x.name
| ``__getattribute__`(...)` x.__getattribute__('name') <==> x.name
| ``__hash__`(x)` x.__hash__() <==> hash(x)
| ``__new__`(T, S, ...)` T.__new__(S, ...) -> a new object with type S, a subtype of T
| ``__reduce__`(...)` helper for pickle
| ``__reduce_ex__`(...)` helper for pickle
| ``__repr__`(x)` x.__repr__() <==> repr(x)
| ``__str__`(x)` x.__str__() <==> str(x)

Class Variable Summary
`type` | `_sql_singleton__impl` = `bakmei.sql_singleton.__impl`
`NoneType` | `_sql_singleton__instance` = None

Method Details

### __init__(self)
(Constructor)

Create singleton instance

  Overrides:
    `__builtin__.object.__init__`

### __getattr__(self, attr)
(Qualification operator)

Delegate access to implementation

### __setattr__(self, attr, value)

Delegate access to implementation

  Overrides:
    `__builtin__.object.__setattr__`

### connection(self, DSN)

Get the SQL connection object. This method is used to create the initial connection, and should not be called afterwards. This should not be used when you can use the execute method.

  Returns:
    the SQL connection object

  See Also: sql_singleton.execute()

### create_bakmei_database(self, DSN)

Creates the schema for a Bak Mei database at the given DSN.

  Parameters:
    `DSN` - The database source name
    (type=String)

### cursor(self)

Get the SQL cursor object for the current connection. This should not be used when you can use the execute method.

  Returns:
    the SQL cursor object
    (type=cursor)

  See Also: sql_singleton.execute()

### extract_DSN_values(DSN)

To be honest this is not really a standard DSN format, kind of a hack that looks similar and I call it DSN

  Returns:
    A tuple containing the parsed information. The structure of the tuple changes based on the source database.
    (type=tuple)

### select_args(self, DSN, function_id)

Retrieve the arguments of the function.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to query.
    (type=Integer)
  Returns:
    A list of dicts containing the argument attributes. The keys for the dictionary are "name".
    (type=[dict])

### select_basic_block(self, DSN, basic_block_id)

Retrieve the attributes of the basic block.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `basic_block_id` - The ID of the basic_block to query.
    (type=Integer)
  Returns:
    A dictionary of all the attributes for the given basic block. The keys for the dictionary are "module", "function", "start_address", "end_address".
    (type=dict)

### select_basic_block_num_instructions(self, DSN, basic_block_id)

Retrieve the number of instructions contained in the basic block.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `basic_block_id` - The ID of the basic_block to query.
    (type=Integer)
  Returns:
    The number of instructions contained in the basic block.
    (type=Integer)

### select_basic_block_sorted_instructions(self, DSN, basic_block_id)

Retrieve the instructions contained in the basic block ordered by address.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `basic_block_id` - The ID of the basic_block to query.
    (type=Integer)
  Returns:
    A list of the IDs of the instructions contained in the basic block.
    (type=[Integer])

### select_frame_info(self, DSN, function_id)

Retrieve the frame information for the function.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to query.
    (type=Integer)
  Returns:
    A dict containing the frame information attributes. The keys for the dictionary are "saved_reg_size", "frame_size", "ret_size", "local_var_size", "arg_size".
    (type=dict)

### select_function(self, DSN, function_id)

Retrieve the attributes of the function.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to query.
    (type=Integer)
  Returns:
    A dict containing the function attributes. The keys for the dictionary are "name", "module", "start_address", "end_address", "import_id", "exported".
    (type=dict)

### select_function_basic_block_by_address(self, DSN, function_id, address)

Retrieve the basic block in the function containing the given address.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to query.
    (type=Integer)
    `address` - The address contained in the basic block.
    (type=Integer)
  Returns:
    The ID of the basic block to be retrieved.
    (type=Integer)

### select_function_basic_block_references(self, DSN, function_id)

Retrieve the basic block cross references for the function.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to query.
    (type=Integer)
  Returns:
    A tuple in the format of (src_basic_block_id, dst_basic_block_id).
    (type=tuple)

### select_function_basic_blocks(self, DSN, function_id)

Retrieve the basic blocks contained in the function.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to query.
    (type=Integer)
  Returns:
    A list of the IDs of the basic blocks contained in the function.
    (type=[Integer])

### select_function_instruction_references_to(self, DSN, function_id)

Retrieve a list of instructions that reference the given function.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to query.
    (type=Integer)
  Returns:
    A list of the IDs of the instructions that reference the given function.
    (type=[integer])

### select_function_num_instructions(self, DSN, function_id)

Retrieve the number of instructions contained in the function.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to query.
    (type=Integer)
  Returns:
    The number of instructions contained in the function.
    (type=Integer)

### select_function_num_vars(self, DSN, function_id, var_type)

Retrieve the number of a given type of variables in the function.

VAR_TYPE_ARGUMENT = 1

VAR_TYPE_LOCAL = 2

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to query.
    (type=Integer)
    `var_type` - The address contained in the basic block.
    (type=Integer)
  Returns:
    The number of variables in the function.
    (type=Integer)

  See Also: defines.py

### select_instruction(self, DSN, instruction_id)

Retrieve the attributes of the instruction.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `instruction_id` - The ID of the instruction to query.
    (type=Integer)
  Returns:
    A dict containing the instruction attributes. The keys for the dictionary are "address", "mnemonic", "comment", "bytes", "basic_block".
    (type=dict)

### select_instruction_operands(self, DSN, instruction_id)

Retrieve the operands of the instruction.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `instruction_id` - The ID of the instruction to query.
    (type=Integer)
  Returns:
    A list containing the IDs of the operands belonging to this instruction.
    (type=[Integer])

### select_instruction_references_to(self, DSN, instruction_id)

Retrieve the instructions that reference the given instruction.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `instruction_id` - The ID of the instruction to query.
    (type=Integer)
  Returns:
    A list of IDs of the instructions that reference the given instruction.
    (type=[Integer])

### select_local_vars(self, DSN, function_id)

Retrieve the local variables of the function.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to query.
    (type=Integer)
  Returns:
    A list of dicts containing the local variable attributes. The keys for the dictionary are "name".
    (type=[dict])

### select_module(self, DSN, module_id)

Retrieve all the attributes of the given module

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `module_id` - The ID of the module to retrieve.
    (type=Integer)
  Returns:
    A dictionary of all the attributes for the given module. The keys for the dictionary are "name", "base", "signature", "comment".
    (type=dict)

### select_module_function_references(self, DSN, module_id)

Returns a list of tuples consisting of the source function address and the destination function address.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `module_id` - The ID of the module to query.
    (type=Integer)
  Returns:
    A tuple in the format of (src_function_id, dst_function_id).
    (type=(Integer, Integer))

### select_module_functions(self, DSN, module_id)

Retrieve all the function IDs that are contained in the given module

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `module_id` - The ID of the module to query.
    (type=Integer)
  Returns:
    A list of the function IDs contained in the module.
    (type=[Integer])

### select_module_imported_functions(self, DSN, module_id)

Retrieve all the function IDs that are imported into the given module

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `module_id` - The ID of the module to query.
    (type=Integer)
  Returns:
    A list of the imported function IDs contained in the module.
    (type=[Integer])

### select_module_instruction_by_address(self, DSN, module_id, address)

Retrieve all the instruction ID that corresponds to the address in the given module

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `module_id` - The ID of the module to query.
    (type=Integer)
    `address` - The address of the instruction.
    (type=DWORD)
  Returns:
    The instruction ID matching the address contained in the module.
    (type=Integer)

### select_module_library_functions(self, DSN, module_id)

Retrieve all the function IDs that are inline library calls for the given module

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `module_id` - The ID of the module to query.
    (type=Integer)
  Returns:
    A list of the inline library function IDs contained in the module.
    (type=[Integer])

### select_module_num_functions(self, DSN, module_id)

Retrieve the number of functions contained in the given module

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `module_id` - The ID of the module to query.
    (type=Integer)
  Returns:
    The number of functions contained in the module.
    (type=Integer)

### select_modules(self, DSN)

Retrieve the name and IDs of all modules in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
  Returns:
    A list of tuples containing the module ID and the module name.
    (type=[(Integer, String)])

### select_operand(self, DSN, operand_id)

Retrieve the attributes of the operand.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `operand_id` - The ID of the operand to query.
    (type=Integer)
  Returns:
    A dict containing the operand attributes. The keys for the dictionary are "operand_text", "position".
    (type=dict)

### select_rpc_functions(self, DSN, module_id)

Retrieve all the RPC function IDs for the given module

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `module_id` - The ID of the module to search.
    (type=Integer)
  Returns:
    A list of all the RPC function IDs available for the module.
    (type=List)

### select_rpc_functions_by_uuid(self, DSN, module_id, uuid)

Retrieve all the RPC function IDs for the given UUID in the module

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `module_id` - The ID of the module to search.
    (type=Integer)
    `uuid` - The uuid to search for matching functions.
    (type=String)
  Returns:
    A list of all the RPC function IDs available for the UUID in the module.
    (type=List)

### select_rpc_uuids(self, DSN, module_id)

Retrieve all the RPC UUIDs for the given module

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `module_id` - The ID of the module to search.
    (type=Integer)
  Returns:
    A list of all the RPC UUIDs available for the module.
    (type=List)

### update_basic_block_end_address(self, DSN, basic_block_id, address)

Update the ending address of a basic block in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `basic_block_id` - The ID of the basic block to update.
    (type=Integer)
    `address` - The basic block ending address.
    (type=Integer)

### update_basic_block_start_address(self, DSN, basic_block_id, address)

Update the starting address of a basic block in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `basic_block_id` - The ID of the basic block to update.
    (type=Integer)
    `address` - The basic block starting address.
    (type=Integer)

### update_function_arg_size(self, DSN, function_id, size)

Update the function argument size for a function in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to update.
    (type=Integer)
    `size` - The total function arguments size.
    (type=Integer)

### update_function_end_address(self, DSN, function_id, address)

Update the ending address of a function in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to update.
    (type=Integer)
    `address` - The function end address.
    (type=Integer)

### update_function_exported(self, DSN, function_id, exported)

Update the flags for a function in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to update.
    (type=Integer)
    `exported` - The function export status.
    (type=Boolean)

### update_function_flags(self, DSN, function_id, flags)

Update the flags for a function in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to update.
    (type=Integer)
    `flags` - The function flags.
    (type=Integer)

### update_function_frame_size(self, DSN, function_id, size)

Update the frame size for a function in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to update.
    (type=Integer)
    `size` - The frame size.
    (type=Integer)

### update_function_local_var_size(self, DSN, function_id, size)

Update the local variable size for a function in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to update.
    (type=Integer)
    `size` - The local variable size.
    (type=Integer)

### update_function_name(self, DSN, function_id, name)

Update the name of a function in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to update.
    (type=Integer)
    `name` - The name of the function.
    (type=String)

### update_function_ret_size(self, DSN, function_id, size)

Update the return variable size for a function in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to update.
    (type=Integer)
    `size` - The return variable size.
    (type=Integer)

### update_function_saved_reg_size(self, DSN, function_id, size)

Update the saved registers size for a function in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to update.
    (type=Integer)
    `size` - The saved registers size.
    (type=Integer)

### update_function_start_address(self, DSN, function_id, address)

Update the starting address of a function in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `function_id` - The ID of the function to update.
    (type=Integer)
    `address` - The function starting address.
    (type=Integer)

### update_instruction_address(self, DSN, instruction_id, address)

Update the address of an instruction in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `instruction_id` - The ID of the instruction to update.
    (type=Integer)
    `address` - The address of the instruction.
    (type=Integer)

### update_instruction_bytes(self, DSN, instruction_id, byte_string)

Update the bytes of an instruction in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `instruction_id` - The ID of the instruction to update.
    (type=Integer)
    `byte_string` - The bytes of the instruction packed in hex.
    (type=String)

### update_instruction_comment(self, DSN, instruction_id, comment)

Update the comment on an instruction in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `instruction_id` - The ID of the instruction to update.
    (type=Integer)
    `comment` - The comment on the instruction.
    (type=String)

### update_instruction_flags(self, DSN, instruction_id, flags)

Update the flags of an instruction in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `instruction_id` - The ID of the instruction to update.
    (type=Integer)
    `flags` - The flags of the instruction.
    (type=Integer)

### update_instruction_mnemonic(self, DSN, instruction_id, mnemonic)

Update the mnemonic of an instruction in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `instruction_id` - The ID of the instruction to update.
    (type=Integer)
    `mnemonic` - The mnemonic of the instruction.
    (type=String)

### update_instruction_operand(self, DSN, instruction_id, operand_seq, value)

Update the operand of an instruction.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `instruction_id` - The ID of the instruction to update.
    (type=Integer)
    `operand_seq` - The placement of the operand in the instruction.
    (type=Integer)
    `value` - The textual representation of the operand.
    (type=String)

### update_module_base(self, DSN, module_id, base)

Update the module base address in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `module_id` - The ID of the module to update.
    (type=Integer)
    `base` - The base address to store in the database.
    (type=Integer)

### update_module_comment(self, DSN, module_id, comment, author)

Update the module comment in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `module_id` - The ID of the module to update.
    (type=Integer)
    `author` - The name of the person adding the comment.
    (type=String)

### update_module_name(self, DSN, module_id, name)

Update the module name in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `module_id` - The ID of the module to update.
    (type=Integer)
    `name` - The module name to store in the database.
    (type=String)

### update_module_signature(self, DSN, module_id, signature)

Update the module signature in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `module_id` - The ID of the module to update.
    (type=Integer)
    `signature` - The signature to store in the database.
    (type=String)

### update_operand_text(self, DSN, operand_id, text)

Update the text of an operand in the database.

  Parameters:
    `DSN` - The database source name.
    (type=String)
    `operand_id` - The ID of the operand to update.
    (type=Integer)
    `text` - The text of the operand.
    (type=String)

Class Variable Details

### _sql_singleton__instance

  Type:
    `NoneType`
  Value:

        None

Generated by Epydoc 2.1 on Wed Mar 14 16:32:07 2007 | http://epydoc.sf.net