Skip to main content

Linter detecting AI-generated code vulnerabilities, hallucinated packages, and truncated code.

Project description

??? guard-ai

Automated linter that catches AI-generated vulnerabilities, hallucinated dependencies, and code truncations before they hit production.

License: MIT Python 3.9+ CI Status


?? The Problem: AI Slopsquatting & Code Hallucinations

Large Language Models (LLMs) write great code, but they also introduce distinct security risks:

  1. Slopsquatting (Hallucinated Packages): LLMs frequently invent non-existent PyPI and NPM dependencies (e.g., fake_llm_helper_12345). Attackers register these hallucinated names to execute supply-chain attacks.
  2. Hardcoded Secret Placeholders: LLMs fill missing keys with patterns like openai_key = "your_openai_key_here", which developers often accidentally commit.
  3. Truncated Code Comments: AI models often output incomplete snippets containing # ... rest of code here or // ... existing code, breaking logic in production.

guard-ai runs directly in your CLI and CI/CD pipelines to block these issues instantly.


? Features

  • ?? Multi-Language Support: Scans Python (.py), JavaScript/TypeScript (.js, .ts, .jsx, .tsx), and package.json.
  • ?? High Performance Caching: SQLite-backed local registry lookup engine (24-hr TTL) to query PyPI & NPM without hitting rate limits.
  • ?? Zero False-Positives: Smart filtering for Python standard libraries, Node built-ins, and local module structures.
  • ?? CI/CD Ready: Custom exit thresholds (--fail-on HIGH) and structured --json output for automated pipelines.
  • ?? Ignore Rule Engine: Seamless support for default ignores (.venv, node_modules), .gitignore, and .guardignore.

? Quick Start

Installation

Install locally using pip:

pip install .

---

## ?? Pre-Commit Hook Integration

Want to catch AI risks *before* you even commit? Add `guard-ai` to your project's `.pre-commit-config.yaml`:

```yaml
repos:
  - repo: [https://github.com/Karthikvk1899/guard-ai](https://github.com/Karthikvk1899/guard-ai)
    rev: v1.0.0
    hooks:
      - id: guard-ai
        args: ["--fail-on", "HIGH"]


## ?? Pre-Commit Hook Integration

Want to catch AI risks *before* you even commit? Add guard-ai to your project's .pre-commit-config.yaml:

`yaml
repos:
  - repo: [https://github.com/Karthikvk1899/guard-ai](https://github.com/Karthikvk1899/guard-ai)
    rev: v1.0.0
    hooks:
      - id: guard-ai
        args: ["--fail-on", "HIGH"]

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

guard_ai_cli-0.1.0.tar.gz (7.5 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: guard_ai_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for guard_ai_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c0ea59c33c81224a0359e9a04240f39adc4bd36a3deb56d71581e938f7393e0b
MD5 a2a2f40b9f9df503efd822f50fcaf1c3
BLAKE2b-256 8d00de8e6814a8cccd06e10514e2fc895b93b52df21854627d71c961e8ec84ca

See more details on using hashes here.

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