bhopengraph: A python library to create BloodHound OpenGraphs
A python library to create BloodHound OpenGraphs easily
This library also exists in: Go | Python
Features
This module provides Python classes for creating and managing graph structures that are compatible with BloodHound OpenGraph. The classes follow the BloodHound OpenGraph schema and best practices.
If you don't know about BloodHound OpenGraph yet, a great introduction can be found here: https://bloodhound.specterops.io/opengraph/best-practices
The complete documentation of this library can be found here: https://bhopengraph.readthedocs.io/en/latest/
Examples
Here is an example of a Python program using the bhopengraph python library to model the Minimal Working JSON from the OpenGraph Schema documentation:
from bhopengraph.OpenGraph import OpenGraph
from bhopengraph.Node import Node
from bhopengraph.Edge import Edge
from bhopengraph.Properties import Properties
# Create an OpenGraph instance
graph = OpenGraph(source_kind="Base")
# Create nodes
bob_node = Node(
id="123",
kinds=["Person", "Base"],
properties=Properties(
displayname="bob",
property="a",
objectid="123",
name="BOB"
)
)
alice_node = Node(
id="234",
kinds=["Person", "Base"],
properties=Properties(
displayname="alice",
property="b",
objectid="234",
name="ALICE"
)
)
# Add nodes to graph
graph.add_node(bob_node)
graph.add_node(alice_node)
# Create edge: Bob knows Alice
knows_edge = Edge(
start_node=alice_node.id,
end_node=bob_node.id,
kind="Knows"
)
# Add edge to graph
graph.add_edge(knows_edge)
# Export to file
graph.export_to_file("minimal_example.json")
This gives us the following Minimal Working JSON as per the documentation:
{
"graph": {
"nodes": [
{
"id": "123",
"kinds": [
"Person",
"Base"
],
"properties": {
"displayname": "bob",
"property": "a",
"objectid": "123",
"name": "BOB"
}
},
{
"id": "234",
"kinds": [
"Person",
"Base"
],
"properties": {
"displayname": "alice",
"property": "b",
"objectid": "234",
"name": "ALICE"
}
}
],
"edges": [
{
"kind": "Knows",
"start": {
"value": "123",
"match_by": "id"
},
"end": {
"value": "234",
"match_by": "id"
}
}
]
},
"metadata": {
"source_kind": "Base"
}
}
Contributing
Pull requests are welcome. Feel free to open an issue if you want to add other features.
References
Metadata
Release files for bhopengraph 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bhopengraph-1.3.1-py3-none-any.whl | Python 3 | none | any | Details for bhopengraph-1.3.1-py3-none-any.whl |
Release files / bhopengraph-1.3.1-py3-none-any.whl
| Download URL | bhopengraph-1.3.1-py3-none-any.whl |
|---|---|
| Size | 32.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d9074a0c431baf4874350ff67098135c5b8daea1526f7514abef7e24ab3b813a
|
|
BLAKE2b-256 checksum How to use checksums |
76dc6885dcc0bad19a09271fb51f0956ab568deb2f3440617a5d30bfb896a0c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Security for bhopengraph 1.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.