Skip to main content

A Python implementation of a Code Property Graph.

Project description

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

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

codepropertygraph-0.1.2.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

codepropertygraph-0.1.2-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file codepropertygraph-0.1.2.tar.gz.

File metadata

  • Download URL: codepropertygraph-0.1.2.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.13

File hashes

Hashes for codepropertygraph-0.1.2.tar.gz
Algorithm Hash digest
SHA256 319a008ec3b11dadc13b973afed3dbde622a2394f48bd50c8b910b2f71d5303a
MD5 1bff71c7ab4e71695744e00e580b52e5
BLAKE2b-256 0586c0722e4490971792469effe32c71cd55b0e6d18d36daf3194541c8e04913

See more details on using hashes here.

File details

Details for the file codepropertygraph-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for codepropertygraph-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0717173d3c38334664ffaa53565d8c5b6390aaaeb8afab1b754b4cd19d8018d9
MD5 677b7270c25d64cb758474b86cf931ae
BLAKE2b-256 8f8055a81a617fab6f3a828568de1b98aa8207e59ff6ec66905016cfc12f2a0f

See more details on using hashes here.

Supported by

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