Skip to main content

Code Property Graph

Github Stars badge GitHub release (latest SemVer) badge Maintenance badge

Code Property Graph Logo

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.

Code Property Graph Demo

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

Metadata

Release files for codepropertygraph 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codepropertygraph 0.1.2
File Size Uploaded
codepropertygraph-0.1.2.tar.gz 2.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for codepropertygraph 0.1.2
File Interpreter ABI Platform
codepropertygraph-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 5.9 kB

Release files / codepropertygraph-0.1.2.tar.gz

Download URL codepropertygraph-0.1.2.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
319a008ec3b11dadc13b973afed3dbde622a2394f48bd50c8b910b2f71d5303a
BLAKE2b-256 checksum
How to use checksums
0586c0722e4490971792469effe32c71cd55b0e6d18d36daf3194541c8e04913
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.13

Release files / codepropertygraph-0.1.2-py3-none-any.whl

Download URL codepropertygraph-0.1.2-py3-none-any.whl
Size 3.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0717173d3c38334664ffaa53565d8c5b6390aaaeb8afab1b754b4cd19d8018d9
BLAKE2b-256 checksum
How to use checksums
8f8055a81a617fab6f3a828568de1b98aa8207e59ff6ec66905016cfc12f2a0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page