Skip to main content

Offline-first static analyser for Python files and notebooks.

Project description

Codexray

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.

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

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 functions
  • edges: relationships such as imports, contains, and calls

Typical use:

  1. Run Codexray and save JSON output.
  2. Load graph.nodes and graph.edges into your graph viewer.
  3. Track dependency hotspots and risky call paths.

How to use findings to make code changes

Recommended workflow:

  1. Sort findings by severity.
  2. Fix critical and high findings first.
  3. Re-run Codexray after each fix batch.
  4. Keep evidence by committing report diffs in your internal workflow.

Examples:

  • SEC001 shell execution:
    • Replace dynamic shell calls with safe Python APIs.
    • Avoid passing untrusted input to command execution.
  • SEC002 dangerous builtin:
    • Replace eval or exec with safe parsing and strict allow-lists.
  • DEP001 unpinned dependency:
    • Pin versions in requirements files with == where practical.

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 .py or .ipynb sources.

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

codexray_analyser-0.1.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codexray_analyser-0.1.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file codexray_analyser-0.1.0.tar.gz.

File metadata

  • Download URL: codexray_analyser-0.1.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for codexray_analyser-0.1.0.tar.gz
Algorithm Hash digest
SHA256 caf39ee8fc8ebeb3395f0e95be18d0da705826e248724e73a714803c7370e370
MD5 af00bf697147cf1fc5e4aed02928d9a9
BLAKE2b-256 e803addb3b5ac275e933fe4e8fc3316a965ec3ae9ffcc88d227ce4d21b27d9a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for codexray_analyser-0.1.0.tar.gz:

Publisher: publish.yml on Merlins-Sanctum/codexray-analyser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codexray_analyser-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for codexray_analyser-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 60b9777c03c90cc1a429cce2fb6f82e87d84489143a9265c2d4dff8c3e7e9d8c
MD5 939014284c1f4a74f8e57f8ac42f3363
BLAKE2b-256 f99b8e1a23d08d5abad43fbc4e3a2d94f359ecb255c76ed4d62db036a4921f32

See more details on using hashes here.

Provenance

The following attestation bundles were made for codexray_analyser-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Merlins-Sanctum/codexray-analyser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page