Skip to main content

Deterministic linter for AI-generated Python code

Project description

wraith

Catches what your AI forgot to check.

Deterministic linter for AI-generated Python code. Detects hallucinated APIs, phantom packages, hardcoded secrets, AI artifacts, and supply chain risks.

Install

pip install wraith

Usage

wraith check .                          # scan current directory
wraith check . --fix --diff             # preview fixes
wraith check . --fix                    # apply fixes
wraith check . --select AG,VC001       # specific rules only
wraith check . --min-confidence 0.8    # high-confidence only
wraith check . --format sarif          # CI/CD output
wraith rules                           # list all 20 rules

What it catches

API Guard — hallucinated API detection

Rule What Example
AG001 Non-existent attribute os.path.joinn() → did you mean join?
AG002 Non-existent kwarg makedirs(exst_ok=True)exist_ok
AG003 Deprecated API PEP 702 + source analysis, zero false positives
AG004 Bare call without module read_csv()pd.read_csv()
AG005 Missing import np.array() without import numpy
AG006 Contextual mismatch pd.read_excel("data.csv") → wrong extension

Phantom — package validation

Rule What
PH001 Package not found on PyPI (slopsquatting risk)
PH002 Package not installed in current environment
PH003 Suspicious package (typosquat, new, low downloads)

Vibe Check — AI artifact hygiene

Rule What
VC001 Hardcoded secrets (entropy + prefix + bigram analysis)
VC002 AI comments (# Generated by Claude, # Copilot)
VC003 Debug code — print/breakpoint (pedantic, off by default)
VC004 Debug imports (pdb, ipdb)
VC005 Source map exposure
VC006 Unauthed debug/admin endpoints
VC007 Dangerous files in project (.env, .pem, credentials)
VC008 Unpinned dependencies
VC009 Missing lockfile
VC010 Source map with full source disclosure
VC011 Secret leaked to print/logging (taint analysis)

Inline suppression

print("debug")           # noqa: VC003
API_KEY = "sk-secret"    # noqa: VC001
import pdb               # noqa

Python API

import wraith

results = wraith.check_source('API_KEY = "sk-secret"')
fixed = wraith.fix('import pdb\nbreakpoint()')

How it works

  • Tree-sitter AST parsing — no regex on source, proper syntax analysis
  • Symbol table with scope tracking (PEP 227 LEGB) — distinguishes imports from local variables
  • Python introspection — validates API calls against real installed modules
  • Layered secret detection — known prefixes, Shannon entropy, bigram name classification, character class analysis
  • Taint analysis — tracks data flow from secret sources to unsafe sinks
  • TYPE_CHECKING awareness (PEP 484) — skips type-only imports

Research

Based on:

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

wraith-0.1.0.tar.gz (64.3 kB view details)

Uploaded Source

Built Distribution

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

wraith-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (923.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: wraith-0.1.0.tar.gz
  • Upload date:
  • Size: 64.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for wraith-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c1812c7f002e8490a52f9584790d041ebe526e582356cdc70dc90cf42a4ee378
MD5 09c5557e3a18355a8fb7346fd1c71edb
BLAKE2b-256 1b387f204030f045592b65d6812c23d809c52ef043b561b946af058152a5eda0

See more details on using hashes here.

File details

Details for the file wraith-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for wraith-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 065253429b0c04ef820b779a5b5a0c464a987d58a6b9e2d17803e6643e7cea30
MD5 7c49b0e180ba5d80b976879c1eac2a2a
BLAKE2b-256 26bce331b2921fc5a9eca85c561033111d69787c6131f3adf89c0b8bdf9026b7

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