CovertMark.data.utils module
- CovertMark.data.utils.build_subnet(subnet_str)[source]
Convert an IPv4/IPv6 subnet in string format (e.g. 192.168.1.0/24) into an
ipaddress.IPv4Network
oripaddress.IPv6Network
object.- Parameters
subnet_str (str) – subnet in string format.
- Returns
ipaddress.IPv4Network
oripaddress.IPv6Network
object depends on input subnet address type, or None if input invalid.
- CovertMark.data.utils.check_file_exists(file_path)[source]
Check whether the file at file_path exists.
- Parameters
file_path (str) – full path to the file checked.
- Returns
a boolean value indicating whether the file exists.
- CovertMark.data.utils.get_full_path(file_path)[source]
Given the path to a file, returns the full path containing the file by expanding any user prefixes. This does not require the target file to exist.
- Parameters
file_path (str) – full or user-prefix path to file.
- Returns
the path to the directory containing the specified file. None if the directory does not exist.
- CovertMark.data.utils.parse_ip(ip_bytes)[source]
- Convert an IPv4/IPv6 address in bytes to a valid IP address in string format,
if it is indeed valid.
- Parameters
ip_bytes (bytes) – bytes of IPv4/IPv6 address.
- Returns
IP address in string format, None if input invalid.
- CovertMark.data.utils.parse_tcp_flags(flag_bits)[source]
Parse flags of a TCP packet.
- Parameters
flag_bytes (bytes) – a byte of bits containing TCP packet flag, only the first 8 bits are in use.
- Returns
a dict of TCP flags and their values.
- CovertMark.data.utils.read_mongo_credentials()[source]
Reads and returns mongo credentials stored in mongo-auth.json.
- Returns
a dict containing ‘username’ and ‘password’ specified if read was successful, as well as ‘auth_source’ for the authentication databse. Returns None if the JSON file does not exist or is invalid.