sca-pip-audit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

SCA Scan with pip-audit (Python)

利用pip-audit进行SCA扫描(Python)

You are a security engineer running Software Composition Analysis (SCA) on a Python project using pip-audit.
你是一名安全工程师,正在使用pip-audit对Python项目执行软件成分分析(SCA)。

When to use

使用场景

Use this skill when asked to check Python dependencies for vulnerabilities.
当需要检查Python依赖项是否存在漏洞时,使用本技能。

Prerequisites

前置条件

  • pip-audit installed (
    pip install pip-audit
    )
  • Verify:
    pip-audit --version
  • 已安装pip-audit(执行
    pip install pip-audit
  • 验证安装:
    pip-audit --version

Instructions

操作步骤

  1. Identify the target — Determine the Python project or requirements file.
  2. Run the scan:
    bash
    pip-audit --format=json --output=pip-audit-results.json
    • From requirements file:
      pip-audit -r requirements.txt --format=json --output=results.json
    • Strict mode (fail on any vuln):
      pip-audit --strict --format=json
    • Fix automatically:
      pip-audit --fix
    • With descriptions:
      pip-audit --desc --format=json
  3. Parse the results — Read JSON output and present findings:
| # | Package | Installed | Fixed Versions | Vulnerability ID | Description |
|---|---------|-----------|---------------|-----------------|-------------|
  1. Summarize — Provide:
    • Total packages audited vs vulnerabilities found
    • Packages with available fixes
    • Upgrade commands:
      pip install --upgrade <package>==<fixed-version>
    • Packages with no fix available (may need alternatives)
  1. 确定目标 — 明确要扫描的Python项目或requirements文件。
  2. 运行扫描
    bash
    pip-audit --format=json --output=pip-audit-results.json
    • 扫描requirements文件:
      pip-audit -r requirements.txt --format=json --output=results.json
    • 严格模式(发现任何漏洞即终止):
      pip-audit --strict --format=json
    • 自动修复:
      pip-audit --fix
    • 包含漏洞描述:
      pip-audit --desc --format=json
  3. 解析结果 — 读取JSON输出并呈现检查结果:
| # | 包名 | 已安装版本 | 修复版本 | 漏洞ID | 描述 |
|---|---------|-----------|---------------|-----------------|-------------|
  1. 总结报告 — 提供以下内容:
    • 已审计的包总数与发现的漏洞数量
    • 有可用修复方案的包
    • 升级命令:
      pip install --upgrade <package>==<fixed-version>
    • 无可用修复方案的包(可能需要替代方案)