Python library to interact with Joern server
Project description
Introduction
High level python library to use Joern server.
pip install joern-lib
Usage
Run joern server locally.
docker compose up -d
Common steps
Execute single query
from joern_lib import client, workspace
from joern_lib.detectors import common as cpg
connection = await client.get("http://localhost:7000", "admin", "admin")
# connection = await client.get("http://localhost:7000")
res = await client.query(connection, "val a=1");
# {'response': 'a: Int = 1\n'}
Execute bulk query
res = await client.bulk_query(connection, ["val a=1", "val b=2", "val c=a+b"]);
# [{'response': 'a: Int = 1\n'}, {'response': 'b: Int = 2\n'}, {'response': 'c: Int = 3\n'}]
Workspace
List workspaces
res = await workspace.list(connection)
Get workspace path
res = await workspace.get_path(connection)
# /workspace (Response would be parsed)
Check if cpg exists
await workspace.cpg_exists(connection, "NodeGoat")
Import code for analysis
res = await workspace.import_code(connection, "/app", "NodeGoat")
CPG core
List files
res = await cpg.list_files(connection)
JavaScript specific
from joern_lib.detectors import js
List http routes
await js.list_http_routes(connection)
Name of the variable containing express()
await js.get_express_appvar(connection)
List of require statements
await js.list_requires(connection)
List of import statements
await js.list_imports(connection)
List of NoSQL DB collection names
await js.list_nosql_collections(connection)
Get HTTP sources
await js.get_http_sources(connection)
await js.get_http_sinks(connection)
AWS
Requires TypeScript project
await js.list_aws_modules(connection)
Troubleshooting
No response from server
If Joern server stops responding after a while restart docker.
docker compose down
docker compose up -d
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
joern_lib-0.1.0.tar.gz
(9.7 kB
view hashes)
Built Distribution
joern_lib-0.1.0-py3-none-any.whl
(10.3 kB
view hashes)
Close
Hashes for joern_lib-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93550856c96ff5e4de00972cce678f85c110d262d85ab4b1d5718405eed58749 |
|
MD5 | 12400e9d50d2c86b21983dd0cb3d3c1d |
|
BLAKE2b-256 | 45e0832e74ae0f0c3c5f88fc25ff04bb9f0070c5a6519a21f0cf8fd48e7eb17e |