msticpy.common.utility.format module

Formatting and checking functions.

msticpy.common.utility.format.defang_ioc(ioc: str, ioc_type: str | None = None) str

Return de-fanged observable.

Parameters:
  • ioc (str) – The observable.

  • ioc_type (str) – The type of IoC. If URL or Email it will do extra processing to neuter the URL protocol and email @ symbol

Returns:

The de-fanged observable.

Return type:

str

msticpy.common.utility.format.escape_windows_path(str_path: str) str

Escape backslash characters in a string.

msticpy.common.utility.format.is_not_empty(test_object: Any) bool

Return True if the test_object is not None or empty.

msticpy.common.utility.format.is_valid_uuid(uuid_str: str) bool

Return true if uuid_str is a value GUID/UUID.

Parameters:

uuid_str (str) – String to test

Returns:

True if valid GUID/UUID.

Return type:

bool

msticpy.common.utility.format.refang_ioc(ioc: str, ioc_type: str | None = None) str

Return observable with removed de-fanging elements.

Parameters:
  • ioc (str) – The observable to re-fang.

  • ioc_type (str) – The type of IoC. If URL or Email it will do extra processing to restore protocol and @ symbol

Returns:

The re-fanged observable.

Return type:

str

msticpy.common.utility.format.string_empty(string: str) bool

Return True if the input string is None or whitespace.

msticpy.common.utility.format.unescape_windows_path(str_path: str) str

Remove escaping from backslash characters in a string.

msticpy.common.utility.format.valid_pyname(identifier: str) str

Return legal Python identifier, which doesn’t collide with builtins.

Parameters:

identifier (str) – The input identifier

Returns:

The cleaned identifier

Return type:

str