Skip to main content

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 object
  • add_edge(edge): Add an Edge object
  • create_node(id, kinds, properties=None): Create and add a node
  • create_edge(start_value, end_value, kind, ...): Create and add an edge
  • to_json(indent=2): Export as JSON string
  • save_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bloodhound_opengraph-1.0.1.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bloodhound_opengraph-1.0.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

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

Hashes for bloodhound_opengraph-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ef6936707e92d18427ea002aa43fd7e239189fa56917b3efb084d6cd34cf8273
MD5 030221dcd5d3cc9be60fc074a4a89d9e
BLAKE2b-256 2f9907c2bde1b68ffcbbaa704385528a8d627469b838b1f1ebee47fe800f925e

See more details on using hashes here.

Provenance

The following attestation bundles were made for bloodhound_opengraph-1.0.1.tar.gz:

Publisher: python-publish.yml on rookuu/bloodhound-opengraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bloodhound_opengraph-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for bloodhound_opengraph-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c18c2e24624aa2f5e41d02a930443d253336e37b356f9169d087cc33c11743e7
MD5 09c6547121ac69ac1d5bee141c3b4547
BLAKE2b-256 3b8ae85e9eceefe1ea12330fd40645f558b097e943cf6bc7abf57ae901f92819

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page