A Python library for creating BloodHound OpenGraph JSON data
Project description
BloodHound OpenGraph Helper Library
A Python library for creating BloodHound OpenGraph JSON data that conforms to the BloodHound OpenGraph schema specification.
Features
- Type-safe: Uses Python dataclasses and type hints for better code quality
- Schema compliant: Validates data against BloodHound OpenGraph requirements
Installation
pip install bloodhound-opengraph
Quick Start
from opengraph import OpenGraphBuilder
# Create a builder
builder = OpenGraphBuilder(source_kind="MySystem")
# Add nodes
user = builder.create_node(
id="alice@company.com",
kinds=["User", "Person"],
properties={
"email": "alice@company.com",
"displayname": "Alice Johnson",
"active": True
}
)
server = builder.create_node(
id="web-server-01",
kinds=["Computer", "Server"],
properties={
"hostname": "web-server-01.company.com",
"ip_address": "10.0.1.100"
}
)
# Add relationships
builder.create_edge(
start_value="alice@company.com",
end_value="web-server-01",
kind="has_admin_access",
properties={"granted_date": "2025-01-15"}
)
# Export as JSON
json_output = builder.to_json()
print(json_output)
# Or save to file
builder.save_to_file("opengraph_data.json")
Core Classes
OpenGraphBuilder
The main class for building OpenGraph structures:
add_node(node): Add a Node objectadd_edge(edge): Add an Edge objectcreate_node(id, kinds, properties=None): Create and add a nodecreate_edge(start_value, end_value, kind, ...): Create and add an edgeto_json(indent=2): Export as JSON stringsave_to_file(filepath): Save to JSON file
Node
Represents a graph node:
id: Unique identifier (required)kinds: List of 0-3 kind labels (required, 0 only acceptable if source kind is set)properties: Optional dictionary of attributes
Edge
Represents a relationship between nodes:
start: NodeReference to start node (required)end: NodeReference to end node (required)kind: Relationship type string (required)properties: Optional dictionary of attributes
NodeReference
References a node in an edge:
value: ID or name to match (required)match_by: MatchBy.ID or MatchBy.NAME (default: ID)kind: Optional kind filter
Property Rules
Properties must follow BloodHound schema rules:
- Only primitive types: string, number, boolean
- Arrays of primitive types (must be homogeneous)
- No nested objects or arrays of objects
- Empty arrays are allowed
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- SpecterOps for BloodHound development and documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bloodhound_opengraph-1.0.1.tar.gz.
File metadata
- Download URL: bloodhound_opengraph-1.0.1.tar.gz
- Upload date:
- Size: 21.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef6936707e92d18427ea002aa43fd7e239189fa56917b3efb084d6cd34cf8273
|
|
| MD5 |
030221dcd5d3cc9be60fc074a4a89d9e
|
|
| BLAKE2b-256 |
2f9907c2bde1b68ffcbbaa704385528a8d627469b838b1f1ebee47fe800f925e
|
Provenance
The following attestation bundles were made for bloodhound_opengraph-1.0.1.tar.gz:
Publisher:
python-publish.yml on rookuu/bloodhound-opengraph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bloodhound_opengraph-1.0.1.tar.gz -
Subject digest:
ef6936707e92d18427ea002aa43fd7e239189fa56917b3efb084d6cd34cf8273 - Sigstore transparency entry: 422265968
- Sigstore integration time:
-
Permalink:
rookuu/bloodhound-opengraph@2c1350a57985d11d84c64e6263d658d643db14d2 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/rookuu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@2c1350a57985d11d84c64e6263d658d643db14d2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file bloodhound_opengraph-1.0.1-py3-none-any.whl.
File metadata
- Download URL: bloodhound_opengraph-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c18c2e24624aa2f5e41d02a930443d253336e37b356f9169d087cc33c11743e7
|
|
| MD5 |
09c6547121ac69ac1d5bee141c3b4547
|
|
| BLAKE2b-256 |
3b8ae85e9eceefe1ea12330fd40645f558b097e943cf6bc7abf57ae901f92819
|
Provenance
The following attestation bundles were made for bloodhound_opengraph-1.0.1-py3-none-any.whl:
Publisher:
python-publish.yml on rookuu/bloodhound-opengraph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bloodhound_opengraph-1.0.1-py3-none-any.whl -
Subject digest:
c18c2e24624aa2f5e41d02a930443d253336e37b356f9169d087cc33c11743e7 - Sigstore transparency entry: 422265996
- Sigstore integration time:
-
Permalink:
rookuu/bloodhound-opengraph@2c1350a57985d11d84c64e6263d658d643db14d2 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/rookuu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@2c1350a57985d11d84c64e6263d658d643db14d2 -
Trigger Event:
release
-
Statement type: