A client library for CPGQL servers
Project description
cpgqls-client-python
cpgqls-client-python
is a simple Python library for communicating with an instance of
a Code Property Graph Query Language server.
Requirements
Python 3.7+
Installation
pip install cpgqls-client
Example usage
A prerequisite for the following example is access to a running instance of a Code Property Graph server. An easy way to set one up is by using the open source code analyzer joern:
$ ./joern --server
from cpgqls_client import CPGQLSClient, import_code_query, workspace_query
server_endpoint = "localhost:8080"
basic_auth_credentials = ("username", "password")
client = CPGQLSClient(server_endpoint, auth_credentials=basic_auth_credentials)
# execute a simple CPGQuery
query = "val a = 1"
result = client.execute(query)
print(result)
# execute a `workspace` CPGQuery
query = workspace_query()
result = client.execute(query)
print(result['stdout'])
# execute an `importCode` CPGQuery
query = import_code_query("/home/user/code/x42/c", "my-c-project")
result = client.execute(query)
print(result['stdout'])
query = import_code_query("/home/user/code/x42/java/X42.jar", "my-java-project")
result = client.execute(query)
print(result['stdout'])
Running the test suite
# set up the virtual environment
$ python -m venv .venv
$ . .venv/bin/activate
# install the dependencies
$ pip install -r requirements.txt
$ pip install -r requirements-tests.txt
# run the tests
$ python -m pytest
References
- Code Property Graph specification and tools https://github.com/ShiftLeftSecurity/codepropertygraph/
- The open source code analyzer joern: https://joern.io
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
cpgqls-client-0.0.9.tar.gz
(7.1 kB
view details)
Built Distribution
File details
Details for the file cpgqls-client-0.0.9.tar.gz
.
File metadata
- Download URL: cpgqls-client-0.0.9.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16e1009b1774cf88a3dbfb6e3a2ff48376717a218c6004c622fb1489fb7ed1b4 |
|
MD5 | 09e5f7afacbc452b57842964613aea9a |
|
BLAKE2b-256 | d3d1c5092e4e9a7120b6504c7d71633e7044fcce4acb8432b794dfb64f4c4cbe |
File details
Details for the file cpgqls_client-0.0.9-py2.py3-none-any.whl
.
File metadata
- Download URL: cpgqls_client-0.0.9-py2.py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4e3f62dc70efd89356c8036782a54ccf591ddd47ed1c053d3f3c17f2ebc656e |
|
MD5 | 04f567e37395e5bdbfd51550fddbeeaf |
|
BLAKE2b-256 | 42a06a0670675b448aa0d52a04f9e9c77d5138f6392102d8b5b2705e97bdf9fd |