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.4.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

cpgqls_client-0.0.4-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.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

Hashes for cpgqls-client-0.0.4.tar.gz
Algorithm Hash digest
SHA256 c2d311a5dfadcccb5b90761c4ad89d12d25db3c60110374d09a3a359acba9677
MD5 af5e125263f1818e6c1e52e497432503
BLAKE2b-256 05f02bd5c5845a78a6fc71fa06c34537e740d01709cf95d0b7eff15485e4dcf6

See more details on using hashes here.

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

Hashes for cpgqls_client-0.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 805994cca5e2496145858862bbd0d7c1b2a4844910a7d1f66dd62c60b8fe8143
MD5 aa16c02e91c3479fbdf1b2c894ae34b2
BLAKE2b-256 4c521679e08e06345fc48b7bf6cdde799324250bd0b1eb5a473accc27628f89a

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