A Python implementation of a Code Property Graph.
Project description
Code Property Graph
This library is an implementation of a Code Property Graph as seen in the paper published by Fabian Yamaguchi on Modeling and Discovering Vulnerabilities with Code Property Graphs
A code property graph is a highly efficient data structure designed to mine large codebases for similar programming patterns. The data structure can be loaded into a graph database where properties of code can be queried. Code property graphs are intended to be code-agnostic and highly scalable making it one of the best choices for code representation.
Running as a Library
Installation
Requires:
Python 3
pip3
pip install codepropertygraph
Using the code as a library
import os
from dotenv import load_dotenv
from codepropertygraph import get_neo4j_connection
load_dotenv()
USERNAME = os.environ["NEO4J_USERNAME"]
PASSWORD = os.environ["NEO4J_PASSWORD"]
URI = "neo4j+s://cb8ae961.databases.neo4j.io"
# Attempt to get a connection
driver = get_neo4j_connection(URI, (USERNAME, PASSWORD))
# If the connection is successful, you can use the driver
if driver:
with driver.session(database="neo4j") as session:
result = session.run("MATCH (n) RETURN count(n) AS node_count")
node_count = result.single()["node_count"]
print(f"Number of nodes in the database: {node_count}")
driver.close()
> Number of nodes in the database: 0
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
Close
Hashes for codepropertygraph-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7bda4318c5696a1b8033b0811418e3f4de0441244aaae96d154fff18eb41459 |
|
MD5 | 4116b4842bcbc5060bd7ce68a7090604 |
|
BLAKE2b-256 | 2e64a5870cbb17f62ee29e1c450e5d4cd614c6ae06e43fb57ee6045552f2e57f |