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
from codepropertygraph import CPG
code = """a = 1; b = 2; print(a + b)"""
graph = CPG(code)
print(graph)
> Graph(Nodes(a, b), Edges([a, b]))
Installation
To install the repository, you need to clone it and run it inside a virtual environment. Running main.py
generates a Code Property Graph of the simple addition script inside examples/
and saves it to output/
.
git clone https://github.com/markgacoka/codepropertygraph.git
cd codepropertygraph
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Running the Application
python main.py
Testing
Run all tests
pytest tests
Updating Library
- Change the version number
--> VERSION="0.0.9"
DESCRIPTION="A Python implementation of a Code Property Graph."
LONG_DESCRIPTION="A tool for ..."
setup(
name='codepropertygraph',
version=VERSION,
- Upload to Pypi
python setup.py sdist bdist_wheel
pip install twine
twine upload dist/*
For first time contributors, read the CONTRIBUTING page.
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
Hashes for codepropertygraph-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 539a8ff8c0bb4f6dfa2799b111e0ba53d39b0e4fba854fc950b94676e41881a7 |
|
MD5 | a46530f5c3a13d383b4cb2c8186fb3ec |
|
BLAKE2b-256 | ab8004f6f8718ea319b7079d3aa48e531c8abb01bb1d44b9c29d8d646a7f8205 |