panaetius.db panaetius.db

class panaetius.db.Mask(config_path: str, config_contents: dict, config_var: str)[source]

Bases: object

Class to handle masking sensitive values in a config file

Variables:
  • config_contents (dict) – A dict containing the contents of the config file.
  • config_path (str) – The path to the config file.
  • config_var (str) – The key corresponding to the config entry.
  • database (Pylite) – A Pylite instance for the datbase.
  • entry (str) – The result from the config file. Could either be a hash or the raw value.
  • header (str) – The __header__ which denotes where the config file is stored.
  • name (str) – The key of the entry in the config file.
  • result (str) – The value of the entry in the config file.
  • table_name (str) – The sqlite table name. Defaults to the __header__ value.
hash

Property to determine the hash of a config entry.

Returns:The hash as a bytes object.
Return type:bytes
salt

Property to detemine a random salt to use in creation of the hash.

Returns:The salt as a bytes object.
Return type:bytes
static as_string(obj: bytes) → str[source]

Static method to return a string from a bytes object.

Parameters:obj (bytes) – Bytes object to be converted to a string.
Returns:The bytes object as a string.
Return type:str
static fromhex(obj: str) → bytes[source]

Static method to create a bytes object from a string.

Parameters:obj (str) – String object to be converted to bytes.
Returns:The string object as bytes.
Return type:bytes
__init__(config_path: str, config_contents: dict, config_var: str)[source]

Summary See Mask for parameters.

get_value()[source]

Get the true value from the database if it exists, create if it’ ‘ doesn’t exist or update if the hash has changed.

Returns:The result from the database.
Return type:str