Safety
$ safety Official Low RiskSafety (safety) audits Python virtual environments, requirements.txt, pyproject.toml, and lockfiles against PyUp's vulnerability database. Modern v3 safety scan provides --output json and --filter top-level selection, though non-interactive runs require SAFETY_API_KEY or prior safety auth.
pip install safety Scanning local Python environments and requirements.txt via safety scan --output json runs directly in the target virtualenv without MCP bridging.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Provides --output json, --detailed-output, and --filter key selection, though unauthenticated safety scan prompts for login.
- Native
--output jsonand--filtertop-level JSON filtering - Requires
SAFETY_API_KEYorsafety authto avoid interactive auth prompts
Read-only package metadata inspection by default, though safety scan transmits package names/versions to Safety's API and supports telemetry unless disabled.
- Sends local dependency metadata to Safety cloud API during
scan - Supports
--disable-optional-telemetry
Easy installation via pip install safety or uvx safety across macOS, Linux, and Windows.
- Standard PyPI package with
uvxsupport
Well-tailored to Python environments and requirements files, though commercial DB gating and auth friction reduce edge over pip-audit.
- Detects Python vulnerabilities and remediation versions
Maintained by Safety Cybersecurity (PyUp) with active v3 CLI releases.
- Official vendor repo at
pyupio/safety
Official documentation at docs.safetycli.com covers v3 scan and legacy check migration.
- Vendor CLI docs at docs.safetycli.com
Security, Auth & Guardrails
Stores OAuth/API credentials in ~/.safety/ via safety auth, or reads SAFETY_API_KEY from the environment for CI/headless use.
CLI is MIT open-source; Safety v3 account/API key required, with free tier limits and paid commercial vulnerability DB plans.
# Safety Agent Rules - Set `SAFETY_API_KEY` (or run `safety auth` beforehand) so `safety scan` does not block waiting for interactive login. - Prefer `--output json --filter cve_details` or `--save-as json out.json` to keep output bounded. - Never run `safety fix` or package upgrades without explicit user approval.
Agent-Ready Command Recipes
Safe Read-Only Queries
safety scan --output json
Audits installed packages and dependency files in the workspace and prints a structured JSON report.
safety scan --detailed-output --output json --filter cve_details
Uses --filter cve_details to isolate CVE metadata and avoid dumping the full scanned_packages payload.
Strengths for Agents
- + Clean
--output jsonwith--filter(meta,scan_results,cve_details) reduces context noise. - + Supports scanning both active virtualenvs and static
requirements.txt/ Poetry / Pipenv lockfiles.
Caveats & Pitfalls
- ! Safety v3 requires registration/API key (
SAFETY_API_KEY) for headless runs, unlike zero-authpip-audit. - ! Sends package inventory to Safety's API unless using paid offline database bundles.