Code Property Graphs — Joern/Semgrep extraction, AI vulnerability enrichment, risk scoring
Project description
Code Property Graph
Code Property Graphs — Joern/Semgrep extraction, AI vulnerability enrichment, risk scoring.
This package depends on AWS GraphRAG Toolkit (graphrag-toolkit-lexical-graph) for graph storage, vector indexing, and retrieval.
Installation
pip install graphrag-codeproperty-graph
Dependencies
graphrag-document-graph>=3.0.8— Document graph infrastructure (typed nodes, Cypher builders, multi-tenancy)
This package does not depend on bona.
Dependency Chain
graphrag-codeproperty-graph
└── graphrag-document-graph>=3.0.8
└── graphrag-toolkit-lexical-graph>=3.18.0 (AWS foundation)
├── Neptune graph storage
├── OpenSearch Serverless vector indexing
└── Entity resolution & retrieval
Quick Start
Python API Example
from codeproperty_graph import DeltaIngestor, CPGNode, CPGEdge, GraphDiff
# Delta ingestion — only writes to Neptune when code actually changed
ingestor = DeltaIngestor(bucket="graphrag-artifacts-705909755305")
result = await ingestor.ingest(
repo="my-service",
job_id="build-456",
tenant_id="tenant_abc123",
nodes_data=joern_nodes,
edges_data=joern_edges,
nodes_path="s3://bucket/cpg-exports/my-service/build-456/nodes.json",
edges_path="s3://bucket/cpg-exports/my-service/build-456/edges.json",
graph_store=neptune_store,
write_fn=batch_write_function,
)
# result: {"status": "SKIPPED"} or {"status": "INGESTED", "delta": "+5 -2 ~3 =150"}
Graph Diff — Compare CPG States
from codeproperty_graph import GraphDiff, CPGNode
# Compare current vs previous code analysis
diff = GraphDiff.compare(
current_nodes=current_cpg_nodes,
previous_nodes=previous_cpg_nodes,
)
print(f"Added: {len(diff.added)}")
print(f"Removed: {len(diff.removed)}")
print(f"Modified: {len(diff.modified)}")
print(f"Unchanged: {len(diff.unchanged)}")
Manifest Management
from codeproperty_graph import ManifestManager
# Track CPG state per repository in S3
manager = ManifestManager(bucket="graphrag-artifacts-705909755305")
# Save manifest after successful ingestion
await manager.save(repo="my-service", job_id="build-456", signatures=method_signatures)
# Load previous manifest for diff comparison
previous = await manager.load(repo="my-service")
Package Structure
src/codeproperty_graph/
├── __init__.py # Public API: CPGNode, CPGEdge, DeltaIngestor, etc.
├── models.py # CPGNode, CPGEdge, Manifest — Joern-specific types
├── graph_diff.py # Compare two CPG states by method signature
├── manifest_manager.py # S3-backed state tracking per repository
├── delta_ingestor.py # Skip-or-replace orchestration with tenant purge
└── tenant_ops.py # Clean lifecycle management (delete_tenant)
Integration
Architecture Stack
┌─────────────────────────────────────────────────────┐
│ codeproperty-graph (this package) │
│ Joern/Semgrep CPG, delta ingestion, risk scoring │
├─────────────────────────────────────────────────────┤
│ document-graph │
│ Node, Edge, CypherBuilder, PipelineExecutor │
│ Multi-tenancy, batch operations │
├─────────────────────────────────────────────────────┤
│ graphrag-toolkit-lexical-graph (foundation) │
│ GraphStore, Neptune writer, AOSS writer │
│ Lexical indexing, entity resolution, retrieval │
└─────────────────────────────────────────────────────┘
Delta Logic
- Joern exports CPG →
nodes.json+edges.json - Extract METHOD node signatures:
{full_name: hash} - Compare against previous manifest in S3
- If identical → SKIP (no Neptune writes, saves cost)
- If changed → INGEST full graph under new tenant, purge old tenant, update manifest
With Document Graph
Code Property Graph uses document-graph for typed property graph primitives:
# document-graph provides the graph write infrastructure
from graphrag_toolkit.document_graph.graph_build.cypher_builder import CypherBuilder
from graphrag_toolkit.document_graph import Node, Edge
# codeproperty-graph adds CPG-specific semantics on top
from codeproperty_graph import CPGNode, CPGEdge
Contributing
See CONTRIBUTING.md for development setup, testing, and PR guidelines.
License
MIT — see LICENSE for details.
See NOTICE for third-party acknowledgments.
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
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 graphrag_codeproperty_graph-0.4.4.tar.gz.
File metadata
- Download URL: graphrag_codeproperty_graph-0.4.4.tar.gz
- Upload date:
- Size: 46.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b2d3c71cd0e44999bef361401492a91d971f7cf2f21a0a4ec17c5cfde4b4365
|
|
| MD5 |
c92b67015a619ebc68572f8e089386b9
|
|
| BLAKE2b-256 |
0cf5fa525ac8f8d151d5b8c2b85fbbe7ff002a59f1aec010e0e4bffd2de915ec
|
File details
Details for the file graphrag_codeproperty_graph-0.4.4-py3-none-any.whl.
File metadata
- Download URL: graphrag_codeproperty_graph-0.4.4-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a44c9aa9edf46b1e54b9254ae54407993334fd691d85817abe9b1aad0a1a65f
|
|
| MD5 |
a173370f365091ebfdb771d7f69e4b99
|
|
| BLAKE2b-256 |
b77d587159fb264b139aeeff4f415f30908509dfcb5c74ebfe4fc743e542f077
|