Properties
- bhopengraph.Properties.primitive_category(value)[source]
Classify a value into one of the OpenGraph primitive categories.
The BloodHound OpenGraph schema recognizes three primitive categories for property values: “string”, “number”, and “boolean”. This helper returns the matching category, or an empty string when the value is None or not a primitive (e.g. an object, list, or callable).
Note:
boolis checked beforeintbecause in Pythonboolis a subclass ofint; without this orderTrue/Falsewould be misclassified as numbers.Source: https://bloodhound.specterops.io/opengraph/developer/nodes
- Parameters:
value (-) – The value to classify
- Returns:
“string”, “number”, “boolean”, or “” if not a primitive
- Return type:
str
- class bhopengraph.Properties.Properties(**kwargs)[source]
Bases:
objectProperties class for storing arbitrary key-value pairs for nodes and edges. Follows BloodHound OpenGraph schema requirements where properties must be primitive types.
- __init__(**kwargs)[source]
Initialize Properties with optional key-value pairs.
- Parameters:
**kwargs (-) –
Key-value pairs to initialize properties
- set_property(key, value)[source]
Set a property value. Only primitive types are allowed.
- Parameters:
key (-) – Property name
value (-) – Property value (must be a primitive type: str, int, float, bool, or a homogeneous list of those). None is not a valid value.
- get_property(key, default=None)[source]
Get a property value.
- Parameters:
key (-) – Property name
default (-) – Default value if key doesn’t exist
- Returns:
Property value or default
- has_property(key)[source]
Check if a property exists.
- Parameters:
key (-) – Property name to check
- Returns:
True if property exists, False otherwise
- Return type:
bool
- get_all_properties()[source]
Get all properties as a dictionary.
- Returns:
Copy of all properties
- Return type:
dict
- validate()[source]
Validate all properties according to OpenGraph schema rules.
- Returns:
(is_valid, list_of_errors)
- Return type:
tuple[bool, list[str]]
- is_valid_property_value(value)[source]
Validate a single property value according to OpenGraph schema rules.
The BloodHound OpenGraph schema restricts a property value to a single primitive (string, number, or boolean) or a homogeneous array of primitives. None, nested objects, arrays of objects, and arrays mixing primitive categories are not valid.
Note:
booland the numeric types are treated as distinct categories, so a list such as[1, True]is rejected as non-homogeneous even thoughboolis a subclass ofintin Python.Source: https://bloodhound.specterops.io/opengraph/developer/nodes
- Parameters:
value (-) – The property value to validate
- Returns:
True if valid, False otherwise
- Return type:
bool
- to_dict()[source]
Convert properties to dictionary for JSON serialization.
- Returns:
Properties as dictionary
- Return type:
dict