Offline-first static analyser for Python files and notebooks.
Project description
Codexray
Replace this with a real GIF at
assets/demo.gifwhen ready.
codexray "C:\path\to\database.py" --summary --findings-only --min-severity high
Codexray is an offline-first Python static analyser for .py and .ipynb files.
It helps teams inspect security risks, code quality problems, and dependency patterns
without sending source code outside the local machine.
Why Codexray?
You are about to send a notebook or script to a client and want confidence that nothing risky is hidden inside. Run Codexray first. It checks for risky patterns such as shell execution and dangerous builtins, highlights dependency concerns, and gives you a graph of call and import relationships while keeping all source analysis local to your machine.
What Codexray does
- Scans Python files and notebooks.
- Supports project-level scans, full file scans, and targeted line-range checks.
- Produces a structured JSON report.
- Builds a dependency graph view with nodes and edges.
- Flags common security risks such as shell execution and dangerous builtins.
Privacy and security behavior
- No telemetry.
- No source upload.
- Network features are disabled by default.
- Strict input limits for file size, notebook size, snippet length, and AST depth.
This tool is designed for local analysis workflows where proprietary code must stay on the client system.
Installation
pip install codexray-analyser
Quick start with CLI
Analyse a folder:
codexray ./my_project
Analyse a single file:
codexray ./my_project/app.py
Analyse a code snippet:
codexray --snippet "import os; os.system('whoami')"
Analyse only specific lines from one file:
codexray ./my_project/app.py --start-line 40 --end-line 80
Save output to JSON:
codexray ./my_project --output codexray-report.json
Print only a compact summary:
codexray ./my_project --summary
Print findings only (no graph payload):
codexray ./my_project --findings-only
Show only high and critical findings:
codexray ./my_project --findings-only --min-severity high
Export graph for Graphviz:
codexray ./my_project --graph-dot codexray-graph.dot
Export graph to an offline HTML visual:
codexray ./my_project --graph-html codexray-graph.html
Dependency graph preview
Sample graph JSON snippet:
{
"nodes": [
{ "node_id": "file:database.py", "kind": "file", "label": "database.py" },
{ "node_id": "function:database.py:get_conn", "kind": "function", "label": "get_conn" },
{ "node_id": "import:psycopg2.connect", "kind": "import", "label": "psycopg2.connect" }
],
"edges": [
{ "source": "file:database.py", "target": "function:database.py:get_conn", "relation": "contains" },
{ "source": "function:database.py:get_conn", "target": "import:psycopg2.connect", "relation": "calls" }
]
}
Python API usage
from codexray import analyse_file_snippet, analyse_path, analyse_snippet
project_result = analyse_path("./my_project")
snippet_result = analyse_snippet("import os\nos.system('whoami')")
range_result = analyse_file_snippet("./my_project/app.py", 20, 50)
Understanding the report
Each result returns:
findings: list of detected issues.graph: nodes and edges representing imports, files, and function relationships.metadata: run information such as analysed path and offline mode state.
Example finding shape:
{
"rule_id": "SEC002",
"title": "Dangerous builtin eval",
"severity": "critical",
"message": "Avoid eval on untrusted content.",
"file_path": "src/app.py",
"line": 18,
"column": 4
}
Reading graph output
Graph output contains:
nodes: entities such as files, imports, and functionsedges: relationships such asimports,contains, andcalls- DOT export for Graphviz via
--graph-dot - offline HTML graph visual via
--graph-html
Typical use:
- Run Codexray and save JSON output.
- Load
graph.nodesandgraph.edgesinto your graph viewer. - Track dependency hotspots and risky call paths.
How to use findings to make code changes
Recommended workflow:
- Sort findings by
severity. - Fix
criticalandhighfindings first. - Re-run Codexray after each fix batch.
- Keep evidence by committing report diffs in your internal workflow.
Examples:
SEC001shell execution:- Replace dynamic shell calls with safe Python APIs.
- Avoid passing untrusted input to command execution.
SEC002dangerous builtin:- Replace
evalorexecwith safe parsing and strict allow-lists.
- Replace
DEP001unpinned dependency:- Pin versions in requirements files with
==where practical.
- Pin versions in requirements files with
Troubleshooting
File parsing failed:- Check syntax errors or unsupported file encoding.
exceeds ... bytes/chars:- Increase limits in config for controlled internal usage.
- Empty findings:
- Confirm the target path includes
.pyor.ipynbsources.
- Confirm the target path includes
How to create the demo GIF
Record a short terminal run (10 to 20 seconds) that shows:
codexray --summarycodexray --graph-html- opening the generated graph HTML
Then convert to GIF with ffmpeg and save as assets/demo.gif:
ffmpeg -i demo.mp4 -vf "fps=10,scale=1200:-1:flags=lanczos" -loop 0 assets/demo.gif
Keep file size lightweight so README loads quickly.
Launch checklist
- Share a short product post on LinkedIn with the demo GIF.
- Post in Python and data engineering communities with one practical use case.
- Add one issue template for feature requests and invite feedback.
- Ask first users to share real files where summary mode helped.
Local development
python -m pip install -e .
python -m pip install pytest ruff bandit pip-audit build twine
python -m ruff check .
python -m pytest
python -m bandit -q -r src
python -m pip-audit
python -m build
python -m twine check dist/*
Contributing
Read CONTRIBUTING.md before opening a pull request.
Security reports should follow SECURITY.md.
License
MIT. See LICENSE.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codexray_analyser-0.1.1.tar.gz.
File metadata
- Download URL: codexray_analyser-0.1.1.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eea1c286bf9e8af2db5aa0306468a73d45a316c171537f2544f0d6a1fbde088e
|
|
| MD5 |
9068513d842e86a3723f605c0e1d05ba
|
|
| BLAKE2b-256 |
acea65ecbf290246d118aa4ddba047111936cd279bfabae82753bb75b1891673
|
Provenance
The following attestation bundles were made for codexray_analyser-0.1.1.tar.gz:
Publisher:
publish.yml on Merlins-Sanctum/codexray-analyser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codexray_analyser-0.1.1.tar.gz -
Subject digest:
eea1c286bf9e8af2db5aa0306468a73d45a316c171537f2544f0d6a1fbde088e - Sigstore transparency entry: 1191928431
- Sigstore integration time:
-
Permalink:
Merlins-Sanctum/codexray-analyser@9d751177de10b88ac4570929171da427970b265b -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Merlins-Sanctum
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9d751177de10b88ac4570929171da427970b265b -
Trigger Event:
push
-
Statement type:
File details
Details for the file codexray_analyser-0.1.1-py3-none-any.whl.
File metadata
- Download URL: codexray_analyser-0.1.1-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b78974b608e167ed6d569bf6e7bf21b06fa2673b22e73f9e48bfd0efd3209d3b
|
|
| MD5 |
c74939e0d0f2a9285f6a3c423476cf48
|
|
| BLAKE2b-256 |
bfba66b3c61f4d304ab8b9fdf6faa22af15acf5e0a200324811fbbdfe4ce910a
|
Provenance
The following attestation bundles were made for codexray_analyser-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on Merlins-Sanctum/codexray-analyser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codexray_analyser-0.1.1-py3-none-any.whl -
Subject digest:
b78974b608e167ed6d569bf6e7bf21b06fa2673b22e73f9e48bfd0efd3209d3b - Sigstore transparency entry: 1191928436
- Sigstore integration time:
-
Permalink:
Merlins-Sanctum/codexray-analyser@9d751177de10b88ac4570929171da427970b265b -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Merlins-Sanctum
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9d751177de10b88ac4570929171da427970b265b -
Trigger Event:
push
-
Statement type: