A client library for CPGQL servers
Project description
cpgqls-client
cpgqls-client
is a simple Python library for communicating with an instance of
a Code Property Graph server.
Requirements
Python 3.7+
Installation
pip install clpgqls-client
Example usage
Assuming that an instance of a Code Property Graph server is running locally
(e.g. with joern --server
), the following snipped shows a basic use of the
library:
from cpgqls_client import CPGQLSClient, import_code_query, workspace_query
# the client connects on the first call of `execute`
server_endpoint = "localhost:8080"
client = CPGQLSClient(server_endpoint)
# 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['out'])
# execute an `importCode` CPGQuery
query = import_code_query("/home/user/code/x42/c", "my-c-project")
result = client.execute(query)
print(result['out'])
query = import_code_query("/home/user/code/x42/java/X42.jar", "my-java-project")
result = client.execute(query)
print(result['out'])
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.4.tar.gz
(7.0 kB
view details)
Built Distribution
File details
Details for the file cpgqls-client-0.0.4.tar.gz
.
File metadata
- Download URL: cpgqls-client-0.0.4.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2d311a5dfadcccb5b90761c4ad89d12d25db3c60110374d09a3a359acba9677 |
|
MD5 | af5e125263f1818e6c1e52e497432503 |
|
BLAKE2b-256 | 05f02bd5c5845a78a6fc71fa06c34537e740d01709cf95d0b7eff15485e4dcf6 |
File details
Details for the file cpgqls_client-0.0.4-py2.py3-none-any.whl
.
File metadata
- Download URL: cpgqls_client-0.0.4-py2.py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 805994cca5e2496145858862bbd0d7c1b2a4844910a7d1f66dd62c60b8fe8143 |
|
MD5 | aa16c02e91c3479fbdf1b2c894ae34b2 |
|
BLAKE2b-256 | 4c521679e08e06345fc48b7bf6cdde799324250bd0b1eb5a473accc27628f89a |