CodeGuard
Fast, offline, zero-infrastructure static security analysis engineered to eliminate anti-patterns before code reaches production. Native support for Python, JavaScript, and TypeScript with single-configuration governance across your entire SDLC.
01 Executive Summary & Product Vision
CodeGuard is a fast, developer-friendly static application security testing (SAST) tool engineered to eliminate security anti-patterns before code reaches production.
Following its v2.0 makeover, CodeGuard bridges the gap between lightweight linters and heavy enterprise SAST suites. It requires no server infrastructure, no database, no Docker daemon, and zero cloud API keys. Everything runs 100% offline, executing deterministic AST and Tree-sitter semantic analysis in milliseconds.
┌────────────────────────────────────────────────────────────────────────┐
│ CodeGuard │
│ Fast • 100% Offline • Zero Noise • Unified Policy Across All Gates │
└───────────────────────────────────┬────────────────────────────────────┘
│
┌───────────────────┬─────────────┴───────┬────────────────────┐
▼ ▼ ▼ ▼
[Local Editor] [Pre-Commit] [PR / CI Gate] [Audit & Baseline]
Sub-second scan Block bad code Diff-aware PR Manage tech debt &
while coding before commit checks & SARIF track suppressions
02 Where CodeGuard Fits in Your Development Workflow
CodeGuard is designed around a multi-gated security model, ensuring that security validation happens continuously throughout the developer workflow rather than as a delayed gate at release time.
(Python, JS, TS)"] --> B["Instant CLI scan / editor
codeguard scan src/"] B -->|Findings detected| C["Inline remediation with
plain-English suggestions"] C --> A end subgraph S2["2. Git Hooks"] A -->|git commit| D["pre-commit hook
(staged files only)"] D -->|Fail| E["Commit rejected locally"] D -->|Pass| F["git push / pre-push hook
(full tree check)"] end subgraph S3["3. Pull Request & CI Gate"] F --> G["Open Pull Request"] G --> H["codeguard ci / GitHub Action
(Diff-aware scan against base branch)"] H --> I{"Are there new findings
above fail-on threshold?"} I -->|Yes| J["Post inline PR annotations
Fail CI status check"] I -->|No / Baselined| K["CI check passes
Upload SARIF to Security Tab"] end subgraph S4["4. Continuous Audit & Debt Management"] K --> L["Merge to main"] L --> M["Scheduled nightly/weekly audit"] M --> N["codeguard baseline prune
(Track & ratchets down debt)"] M --> O["codeguard suppressions list --expired
(Enforce temporary waiver expiry)"] end
The 5 Gates of CodeGuard
Security as continuous craft — five discrete validation thresholds eliminating risk at each phase of authoring, integration, and governance:
until=YYYY-MM-DD) cannot be silently forgotten.
| Gate | Stage | Trigger / Command | User Experience & Outcome |
|---|---|---|---|
| Gate 1: Inner Loop | Local Dev & IDE | codeguard scan <path> |
Sub-second feedback in terminal with code carets and direct remediation snippets. |
| Gate 2: Pre-Commit | Git Commit | pre-commit hook (id: codeguard) |
Catches mistakes before committing to git history; scans only modified files. |
| Gate 3: Pull Request | CI Pipeline | codeguard ci or GitHub Action |
Scans only changed files/lines. Baselined issues are ignored; only new vulnerabilities fail. |
| Gate 4: Platform Security | Code Scanning Dashboard | --format sarif |
Feeds directly into GitHub Code Scanning, GitLab Dashboard, Reviewdog, or JUnit. |
| Gate 5: Governance & Audit | Scheduled CI / Maintenance | codeguard baseline prunecodeguard suppressions list |
Ratchets down debt over time and ensures temporary waivers cannot expire unnoticed. |
03 How CodeGuard Creates Value
codeguard baseline create. CodeGuard fingerprints existing issues into .codeguard-baseline.json. CI will never break on existing legacy code—it only blocks new vulnerabilities in active PRs. Teams prune debt incrementally over time.
# noqa or # ignore comments without justification, creating permanent, untracked security blind spots.
- Every suppression requires an explicit reason:
(Omitting a reason raises rule
# codeguard: ignore[CG-SEC-001] reason: sanitized by custom validatorCG-META-001). - Suppressions can carry expiration dates:
until=2026-12-31. (Once expired, the finding reactivates and raisesCG-META-002). - Security leads can audit all waivers at any time with
codeguard suppressions list.
- Zero Data Ingestion: No source code or AST payload is ever sent over the internet or passed to an external LLM endpoint.
- Regulatory Ready: Engineered specifically for air-gapped environments, strict compliance regimes (HIPAA, SOC2, FedRAMP, ISO 27001), and IP-sensitive proprietary codebases.
- Zero Runtime Dependencies: No background daemons, external databases, or heavy container prerequisites required on worker nodes.
Built with strict, semantic exit codes for battle-tested automation scripting:
First-class native formatters: human, json (v1 schema envelope), sarif (OASIS 2.1.0), github (Actions workflow annotations), rdjson (Reviewdog), and junit (CI test runners).
04 Current Feature Catalog (v2.0)
4.1 Multi-Language Engine
CodeGuard features a unified, highly optimized analysis pipeline supporting:
Standard deterministic AST analysis across .py and .pyi files with deep expression tracking.
High-performance semantic tree analysis supporting .js, .jsx, .mjs, .cjs, .ts, .tsx, .mts, and .cts.
Automatically respects .gitignore, skips vendor trees (node_modules/, .venv/, dist/), and ignores minified code.
Worker process pool (--jobs / -j) for saturating multiple CPU cores across massive monorepos.
4.2 Security & Meta Rules
Every rule in CodeGuard has a permanent ID, standardized severity, CWE/OWASP classification, and actionable remediation guide:
| Rule ID | Description | Severity | CWE / Ref | Languages |
|---|---|---|---|---|
CG-SEC-001 |
SQL query constructed via f-strings, %, or .format() | HIGH | CWE-89 | Python |
CG-SEC-002 |
Hardcoded passwords, API keys, tokens, or credentials | HIGH | CWE-798 | Python |
CG-SEC-003 |
eval() or exec() execution on dynamic/non-literal input | HIGH | CWE-95 | Python |
CG-SEC-004 |
Unsafe deserialization (pickle.loads, yaml.load) | HIGH | CWE-502 | Python |
CG-SEC-005 |
subprocess() invoked with shell=True on dynamic args | HIGH | CWE-78 | Python |
CG-SEC-101 |
Dynamic evaluation: eval(), new Function, string timer | HIGH | CWE-95 | JS, TS |
CG-SEC-102 |
child_process.exec() invoked with a dynamic command | HIGH | CWE-78 | JS, TS |
CG-SEC-103 |
DOM XSS sink assignment (innerHTML, document.write) | HIGH | CWE-79 | JS, TS |
CG-SEC-104 |
React dangerouslySetInnerHTML with dynamic values | HIGH | CWE-79 | JS, TS |
CG-SEC-105 |
Hardcoded credentials, private keys, high-entropy API | HIGH | CWE-798 | JS, TS |
CG-SEC-106 |
Insecure randomness: Math.random() used for security | MEDIUM | CWE-338 | JS, TS |
CG-META-001 |
Governance: Suppression comment is missing reason: | LOW | Meta | All |
CG-META-002 |
Governance: Suppression comment until= date expired | MEDIUM | Meta | All |
4.3 CLI Commands & Tooling Capabilities
| Command | Purpose | Example Usage |
|---|---|---|
codeguard scan |
General scan of files, directories, or stdin | codeguard scan src/ --fail-on high |
codeguard ci |
Diff-aware PR scanning (auto-detects base branch) | codeguard ci --sarif codeguard.sarif |
codeguard baseline create |
Freeze all existing findings into a baseline JSON | codeguard baseline create |
codeguard baseline update |
Add newly found findings to existing baseline | codeguard baseline update |
codeguard baseline prune |
Clean out resolved findings to ratchet down debt | codeguard baseline prune |
codeguard suppressions list |
Audit and inspect suppression comments across repo | codeguard suppressions list --expired |
codeguard init |
Scaffold a fresh codeguard.toml configuration |
codeguard init |
codeguard validate |
Validate codeguard.toml or pyproject.toml syntax |
codeguard validate |
codeguard list-rules |
List available rules with language & category filters | codeguard list-rules --language python |
codeguard explain <ID> |
View full explanation, CWE references, and fix guides | codeguard explain CG-SEC-001 |
4.4 Centralized Configuration (codeguard.toml)
CodeGuard can be configured via codeguard.toml, .codeguard.toml, or [tool.codeguard] inside pyproject.toml:
[codeguard]
include = ["src/**", "lib/**"]
exclude = ["**/*.min.js", "tests/fixtures/**"]
languages = ["python", "javascript", "typescript"]
gitignore = true
fail_on = "high" # exit 1 on "high" or "critical" findings
output = "human" # default output format
jobs = 0 # 0 = auto-detect CPU cores
baseline = ".codeguard-baseline.json"
[codeguard.rules]
disable = [] # disable specific rule IDs
enable = [] # specify an allowlist of rule IDs
[codeguard.rules.CG-SEC-001]
severity = "critical" # remap rule severity
[[codeguard.overrides]]
path = "legacy_scripts/**" # monorepo path-specific override
disable = ["CG-SEC-002"]
4.5 Packaging & Distribution Formats
pipx install codeguard-cli or pip install codeguard-cli
Official reusable action: uses: mevichitra/codeguard/action@v2
Ready hooks in .pre-commit-hooks.yaml for commit and push
OCI image for GitLab CI, Tekton, CircleCI, and Jenkins
05 Quickstart: Rolling Out CodeGuard in 3 Steps
Install CodeGuard via pipx, generate the starter configuration, and snapshot any pre-existing issues so that CI remains green on Day 1.
# 1. Install CodeGuard globally
pipx install codeguard-cli
# 2. Generate configuration
codeguard init
# 3. Snapshot existing findings so CI doesn't block on day 1
codeguard baseline create
Block vulnerable code before it is committed to local git history by adding the hook to .pre-commit-config.yaml:
repos:
- repo: https://github.com/mevichitra/codeguard
rev: v2.0.0
hooks:
- id: codeguard
Create .github/workflows/codeguard.yml to run diff-aware scans on every PR against main:
name: Security Scan (CodeGuard)
on:
pull_request:
branches: [main]
permissions:
contents: read
security-events: write
jobs:
security-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for diff-aware scanning
- name: Run CodeGuard
uses: mevichitra/codeguard/action@v2
with:
fail-on: high
06 Why Developers & Security Teams Love CodeGuard
Sub-second feedback, zero cloud lag, no broken builds on untouched legacy code, and clear remediation suggestions directly in terminal.
Rapid onboarding without slowing down delivery velocity or drowning engineering sprints in false-alarm triage and alert fatigue.
Continuous enforcement across Python, JS, and TS, transparent suppression audits with mandatory reasons, and native SARIF 2.1.0 dashboards.