PyGarde
pygarde🐍 PYGARDE (`pyw`) — Python Supply Chain Security Guardian. Scans, audits, and hardens your Python package ecosystem against supply-chain attacks before malicious code ever runs.
Installation
pipx install pygardepip install pygardeWhy it exists
Python's pip install is notoriously permissive: install scripts run with full user privileges, there's no built-in malware scanning, and typosquatting attacks (PyPI has had dozens of high-profile incidents) can silently install malicious packages. PyGarde was built to be the security gate that `pip` doesn't have — scan before you install, harden your pip.conf, and catch supply-chain attacks before they execute. It's the Python sibling of PkgWarden, built with the same philosophy but tailored to pip, Poetry, uv, and pipenv workflows.
Features
Replace `pip install` with `pyw install`. PyGarde downloads the package, scans it for threats, and only proceeds with installation if it passes. Configurable severity threshold — block on `medium` or only on `critical`.
Static-scan any PyPI package without touching your environment. Detects eval/exec patterns, subprocess with shell=True, base64-decoded payloads, hidden Unicode characters (Trojan Source CVE-2021-42574), and outbound HTTP to suspicious hosts.
Analyzes and patches your pip.conf, poetry.toml, or uv.toml. Enforces `require-hashes`, removes dangerous `trusted-host` entries, and pins the registry URL. Three hardening levels: minimal, recommended, strict.
Compare two versions of a package and scan only the code that changed. Catches injected malicious code that appears in a minor bump — a common supply-chain attack vector.
Audit all project dependencies against known CVEs via pip-audit. With `--deep`, downloads and static-scans every dependency's source for non-CVE threats.
The `pyw doctor` command gives your project a security posture score (0–100%) across lockfile presence, RC hardening, detection rules coverage, and allowlist hygiene.
Highlights
- Scans any PyPI package without installing it — download, analyze, discard
- Intercepts `pip install` with a security gate: `pyw install requests`
- Detects 7 threat categories: install scripts, network access, code execution, obfuscation, data exfiltration, hidden chars, typosquatting
- Hardens pip.conf, poetry.toml, and uv.toml to prevent MITM and registry substitution
- Supports pip, Poetry, uv, pipenv, pdm, and conda
- Health check command (`pyw doctor`) scores your project security posture 0–100