Skip to main content

CodeGuard

Fast, offline static analysis for Python, JavaScript, and TypeScript. It finds security vulnerabilities (with source-to-sink taint tracking), performance problems, and code-quality risks, fixes the safe ones for you, and works at every gate of your workflow: editor, pre-commit, PR/CI, and scheduled audit, all from one config file.

Status: 2.2.0 (beta). Rule IDs, the Finding / JSON schema, config keys, and exit codes have been a stable contract since 2.0. Upgrading never changes a pipeline's exit code: scan and ci run security rules unless you opt into more. See the migration notes if you used the 0.1 alpha.

License Python CI PyPI


What it does

app.py:11:5  [CG-SEC-011] CRITICAL  Untrusted input reaches a shell command
    11 |     os.system(cmd)
             ^
  ↳ line 9: Untrusted input: flask request.form
  ↳ line 9: Flows through: host = request.form["host"]
  ↳ line 10: Flows through: cmd = "ping -c 1 " + host
  → Run the program with an argument list and shell=False ...

Every finding has a stable rule ID, a severity, a CWE / OWASP mapping for security rules, a precise location, and a fix suggestion. Many also carry a safe autofix.

Category Rules Highlights
Security 25 Taint-tracked SQL / shell / eval / path traversal / open redirect (Python). Pattern rules for injection, XSS, unsafe deserialization, hardcoded secrets, weak hashes, disabled TLS verification, insecure randomness, Express open redirect / path traversal, prototype pollution.
Performance 10 List-literal membership in loops, quadratic string building, regexes compiled in loops, await in loops, spread in reduce, JSON deep clones.
Quality 9 Mutable defaults, swallowed exceptions, cyclomatic complexity, nesting depth, parameter count, loose equality, empty catch, var.

Full list: docs/rules, or codeguard list-rules.


Install

pipx install codeguard-cli      # or: uv tool install codeguard-cli
pip install codeguard-cli       # into the current environment

The PyPI project is codeguard-cli; the command is codeguard. It needs Python 3.10+. No database, no network, and no code leaves the machine.

From source:

git clone https://github.com/mevichitra/codeguard && cd codeguard
pip install -e ".[dev]"

Usage

codeguard scan src/                                  # security rules (default)
codeguard scan src/ --category performance           # or quality, or several
codeguard scan src/ --fix-dry-run                    # preview safe autofixes as a diff
codeguard scan src/ --fix                            # apply them
codeguard scan src/ --format sarif -o results.sarif  # json, sarif, github, rdjson, junit
codeguard scan src/ --fail-on high                   # exit 1 only for high or critical
codeguard explain CG-SEC-011                         # what a rule catches and how to fix it

Exit codes: 0 clean, 1 findings at or above --fail-on, 2 usage error, 3 config error, 4 internal error.

Suppressions

query = f"SELECT * FROM t WHERE id = {uid}"  # codeguard: ignore[CG-SEC-001] reason: uid is an int until=2026-12-31

A suppression without a reason, or past its until= date, is itself reported (CG-META-001 / 002). Audit them with codeguard suppressions list.

Configuration

codeguard.toml (or [tool.codeguard] in pyproject.toml). Run codeguard init for a starter file.

[codeguard]
exclude    = ["tests/fixtures/**", "**/*.min.js"]
categories = ["security", "performance", "quality"]   # default: ["security"]
fail_on    = "high"
baseline   = ".codeguard-baseline.json"

[codeguard.rules]
disable = ["CG-QUAL-104"]

[codeguard.rules.CG-QUAL-003]
max_complexity = 20          # rule options: see `codeguard explain <ID>`

See configuration, baselines, autofix, and taint tracking.


CI integration

- uses: mevichitra/codeguard/action@v2    # diff-aware scan + SARIF upload to code scanning

codeguard ci scans only the files changed since the base branch and applies the baseline. Pre-commit hooks and a Docker image are also available. See docs/ci.md.


Editor integrations

The language server (codeguard lsp) and the extensions put every finding in the editor with severity-coloured diagnostics, hovers that show the taint path, quick fixes, one-click suppressions, and fix-all on save. Editors show security, performance, and quality findings by default; CI keeps the project's categories.

  • VS Code (editors/vscode): a Findings sidebar grouped by severity, category, or file; live status-bar counts; a Security Overview panel; fix all in the workspace; SARIF export; and a getting-started walkthrough.
  • Zed (editors/zed): native diagnostics and Project Diagnostics, lsp.codeguard settings passthrough, code_actions_on_format fix-all, and a local Markdown dashboard.
  • Neovim, Helix, and other LSP clients: run codeguard lsp. See docs/editors.md for configuration and the custom codeguard/summary protocol.

Contributing

See CONTRIBUTING.md. A new rule is one module, a vulnerable and a safe fixture (plus a fixed fixture if it has an autofix), a test, and a docs page.

Roadmap

Phase 1 (2.2, this release) added taint tracking, the performance and quality packs, autofix, and the editor UX. Next come JavaScript / TypeScript taint tracking, same-file function summaries, Semgrep-compatible custom rules, more security rules (SSRF, XXE, ReDoS, JWT, insecure cookies), Marketplace / Open VSX publishing, and standalone binaries. Details in docs/roadmap.md.


License

Apache-2.0. See LICENSE.

Contributions are accepted under the Developer Certificate of Origin (DCO). Sign your commits with git commit -s.

Metadata

Release files for codeguard-cli 2.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codeguard-cli 2.2.0
File Size Uploaded Provenance Actions
codeguard_cli-2.2.0.tar.gz 315.0 kB With provenance Details for codeguard_cli-2.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for codeguard-cli 2.2.0
File Interpreter ABI Platform Actions
codeguard_cli-2.2.0-py3-none-any.whl Python 3 none any Details for codeguard_cli-2.2.0-py3-none-any.whl

Total release size: 472.9 kB

Release files / codeguard_cli-2.2.0.tar.gz

Download URL codeguard_cli-2.2.0.tar.gz
Size 315.0 kB
Tags Source
SHA-256 checksum
How to use checksums
91ec56edd5b713ddaa0b85cb01085bceca3acd66caf85d5eef36c7a95816ed18
BLAKE2b-256 checksum
How to use checksums
fcc2370242144e87640033a0d5d13c058118ac245b874cd974716ba1cae142ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release files / codeguard_cli-2.2.0-py3-none-any.whl

Download URL codeguard_cli-2.2.0-py3-none-any.whl
Size 157.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23dada66d482ef2688d2becb00ec40bb1847bad871a73dbca2016c40a61e294e
BLAKE2b-256 checksum
How to use checksums
2a7c600be3d66f7262268f6865e8706a48bb8f70fc66faa4f0d36f21bb8acb70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Security for codeguard-cli 2.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for codeguard_cli-2.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page