Skip to main content

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

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

cpgqls-client-0.0.3.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

cpgqls_client-0.0.3-py2.py3-none-any.whl (7.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file cpgqls-client-0.0.3.tar.gz.

File metadata

  • Download URL: cpgqls-client-0.0.3.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

Hashes for cpgqls-client-0.0.3.tar.gz
Algorithm Hash digest
SHA256 78178c39e184f16c75e70015131117d63a21e1f96ae8c1f428683de503f36126
MD5 e1c6b19031fb375749e5c92e5ce23a84
BLAKE2b-256 e1005643142e7818679844bc304b8c6ae678d486745cc79b5d75b4b10aa89164

See more details on using hashes here.

File details

Details for the file cpgqls_client-0.0.3-py2.py3-none-any.whl.

File metadata

  • Download URL: cpgqls_client-0.0.3-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

Hashes for cpgqls_client-0.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3ad6efc651bd23193a123e02a51dca62158a4be62659e87082de93693278cdd0
MD5 9a781ca4ded28c59c3cad0ca1bad954a
BLAKE2b-256 84d8a319f940361242c7a05437f4599f872cfdcfd9464eccb5f60ca3b36ae453

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