跳转到正文
报告库
用途分类 / 内容写作

Python Testing Patterns Skill 安全审计

作者说它能做什么(原文)

Implement comprehensive testing strategies with pytest, fixtures, mocking, and test-driven development. Use when writing Python tests, setting up test suites, or implementing testing best practices.

第三方安全检查结论

发现安全风险

已检查文件
3
发现的风险
3
会不会运行危险命令?检查是否下载程序后直接运行、让他人远程控制电脑,或藏起要运行的命令。发现 1 项风险
中风险

示例会安装未锁定的 Python 依赖并使用可变版本的 CI Action

原文依据:3 处
发现了什么

快速开始直接从包索引安装未指定版本的 pytest-cov;CI 示例还安装项目的 dev 依赖,并通过 v3/v4 标签运行第三方 GitHub Actions。这些引用可能随时间指向不同代码,依赖安装和 Action 均可执行代码。

为什么需要注意

如果用户照搬命令或工作流,当前解析到的包、项目构建后端或后来被替换的 Action 代码会在本机或 CI runner 权限下运行。

这些内容是供用户采用的示例,不会因读取 Skill 而自行运行。若用户照搬,CI 会安装当前解析到的项目 dev 依赖、pytest 和 pytest-cov,并执行以可变主版本标签引用的 GitHub Actions;这些安装步骤和 Actions 都能在 CI 运行器中执行代码。可要求作者提供锁文件/哈希并将 Actions 固定到审核过的提交 SHA。

SKILL.md:261来自说明文档打开原文件
```bash# Install coveragepip install pytest-cov# Run tests with coverage
查看另外 2 个位置
references/advanced-patterns.md:344来自说明文档打开原文件
    steps:      - uses: actions/checkout@v3      - name: Set up Python        uses: actions/setup-python@v4        with:          python-version: ${{ matrix.python-version }}      - name: Install dependencies        run: |          pip install -e ".[dev]"          pip install pytest pytest-cov
references/advanced-patterns.md:361来自说明文档打开原文件
      - name: Upload coverage        uses: codecov/codecov-action@v3        with:          file: ./coverage.xml```
会不会泄露文件和密钥?检查是否发送含密码或密钥的文件,以及代码里是否直接写了密钥。发现 1 项风险
中风险

CI 示例会把覆盖率报告上传给 Codecov

原文依据:1 处
发现了什么

工作流先生成 coverage.xml,随后通过 Codecov Action 将该文件交给外部服务。覆盖率 XML 通常包含项目文件路径和逐文件/逐行覆盖信息。

为什么需要注意

采用该配置后,代码结构和测试覆盖状况会离开 GitHub runner。对于私有或敏感仓库,这可能向未经批准的第三方披露内部工程元数据。

该示例明确先生成 coverage.xml,再把它交给 Codecov Action。仅当用户把此工作流加入仓库并触发 CI 时才会发生上传。源码没有展示报告的实际内容、Codecov 配置或仓库可见性,因此无法确认具体泄露了哪些路径或覆盖数据;但向第三方传送报告本身成立。用户可要求作者说明发送字段、凭据权限和保留策略,或禁用上传步骤。

references/advanced-patterns.md:357来自说明文档打开原文件
      - name: Run tests        run: |          pytest --cov=myapp --cov-report=xml      - name: Upload coverage        uses: codecov/codecov-action@v3        with:          file: ./coverage.xml```
会不会删除文件或一直在后台运行?检查是否大范围删除文件、改写磁盘,或设置自动启动。未发现风险
会不会绕过安全保护?检查是否跳过网站安全验证、开放过多文件权限,或取消操作前的确认。发现 1 项风险
低风险

安装命令没有固定依赖版本

原文依据:2 处
发现了什么

安装命令没有指定依赖版本。同样的命令以后可能下载不同代码,你实际安装的内容可能与这次检查时不同。

为什么需要注意

即使命令和报告没变,以后安装时也可能下载到另一份代码。

这是覆盖率报告示例中的安装命令,并非 Skill 自动执行的安装步骤。只有用户复制并运行它时,pip 才会从所配置的软件源解析当时可用的 pytest-cov 版本;因未固定版本,不同时间可能取得不同代码。用户可要求作者给出锁定版本或哈希,并先在隔离环境中审查依赖。

SKILL.md:263来自说明文档打开原文件
# Install coveragepip install pytest-cov
查看另外 1 个位置
SKILL.md:261来自说明文档打开原文件
```bash# Install coveragepip install pytest-cov# Run tests with coverage
会不会误导 AI 或隐藏内容?检查工作说明是否要求 AI 忽略你的指令、干扰检查结果,或夹带看不见的文字。未发现风险
会不会偷偷改推广链接或收款方?检查是否强制替换推广链接或收款对象,同时要求隐瞒更改。未发现风险

Skill 逻辑拆解

5 个说明模块

该 Skill 是一组 Python 测试指导和示例;其声明用途涵盖 pytest、fixture、mock、TDD、数据库及 CI/CD 测试。提供的内容本身没有自动执行入口。

查看原文
SKILL.md:2来自说明文档打开原文件
---name: python-testing-patternsdescription: Implement comprehensive testing strategies with pytest, fixtures, mocking, and test-driven development. Use when writing Python tests, setting up test suites, or implementing testing best practices.---
SKILL.md:12来自说明文档打开原文件
- Writing unit tests for Python code- Setting up test suites and test infrastructure- Implementing test-driven development (TDD)- Creating integration tests for APIs and services- Mocking external dependencies and services- Testing async code and concurrent operations- Setting up continuous testing in CI/CD- Implementing property-based testing- Testing database operations- Debugging failing tests

主文档要求在需要更详细模式时读取两个随附参考文件;提供的来源中这些引用均有对应内容。

查看原文
SKILL.md:69来自说明文档打开原文件
## Detailed patterns and worked examplesDetailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.
SKILL.md:278来自说明文档打开原文件
For advanced patterns (async testing, monkeypatching, property-based testing, database testing, CI/CD integration, and configuration), see [references/advanced-patterns.md](references/advanced-patterns.md)

文件与网络相关代码主要位于代码块示例中:文件写入限定到 pytest 的 tmp_path;API 测试用 patch 替换了 requests 调用。它们不代表安装 Skill 后会自动访问文件或网络。

查看原文
references/advanced-patterns.md:116来自说明文档打开原文件
def test_file_operations(tmp_path):    """Test file operations with temporary directory."""    # tmp_path is a pathlib.Path object    test_file = tmp_path / "test_data.txt"    # Save data    save_data(test_file, "Hello, World!")
references/details.md:217来自说明文档打开原文件
def test_get_user_success():    """Test successful API call with mock."""    client = APIClient("https://api.example.com")    mock_response = Mock()    mock_response.json.return_value = {"id": 1, "name": "John Doe"}    mock_response.raise_for_status.return_value = None    with patch("requests.get", return_value=mock_response) as mock_get:        user = client.get_user(1)
从这里开始 · 工作说明SKILL.md
python-testing-patterns
连线表示工作说明包含的模块,不是实际运行顺序。点击模块可查看原文。

文件引用关系图

3 处引用
哪些文件发起引用引用了什么
连线表示真实的文件引用,不是运行顺序。点击节点可高亮相关连线,并查看具体文件和原文位置。虚线表示还有文件需要定位。
文件与检查记录3 个文件

检查范围与遗漏

逐文件查看涉及的内容

下方列出本次涉及的原文范围;纳入检查不代表已查清所有问题。

  • SKILL.md已纳入全文
  • references/advanced-patterns.md已纳入全文
  • references/details.md已纳入全文

这份报告只针对上方版本。我们看了拿到的代码和说明文件,没有实际运行 Skill,也没有检查它另外安装的软件包。因此,这不是“保证安全”的承诺;换了版本或使用环境,结果也可能不同。

  • SKILL.md工作说明
  • references/advanced-patterns.md配套文件
  • references/details.md配套文件

代码和说明中提到的操作

读取文件
SKILL.md:71来自说明文档打开原文件
Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.
references/advanced-patterns.md:113来自说明文档打开原文件
    """Load data from file."""    return filepath.read_text()
连接外部网站
SKILL.md:148来自说明文档打开原文件
    service = ServiceWithRetry(client, max_retries=3)    result = service.fetch()
SKILL.md:161来自说明文档打开原文件
    with pytest.raises(ConnectionError):        service.fetch()
SKILL.md:173来自说明文档打开原文件
    with pytest.raises(ValueError):        service.fetch()
运行命令
SKILL.md:261来自说明文档打开原文件
```bash# Install coverage
安装其他软件包
SKILL.md:263来自说明文档打开原文件
# Install coveragepip install pytest-cov
references/advanced-patterns.md:354来自说明文档打开原文件
        run: |          pip install -e ".[dev]"          pip install pytest pytest-cov
references/advanced-patterns.md:355来自说明文档打开原文件
          pip install -e ".[dev]"          pip install pytest pytest-cov
读取密钥或账号配置
references/advanced-patterns.md:60来自说明文档打开原文件
    """Get database URL from environment."""    return os.environ.get("DATABASE_URL", "sqlite:///:memory:")
references/advanced-patterns.md:86来自说明文档打开原文件
    def __init__(self):        self.api_key = "production-key"
references/advanced-patterns.md:88来自说明文档打开原文件
    def get_api_key(self):        return self.api_key
修改文件
references/advanced-patterns.md:108来自说明文档打开原文件
    """Save data to file."""    filepath.write_text(data)
读取了多少行
1,041
文件校验值(用于核对版本)
ab4fed5ed147b9fd9a9b52baf09dd0173f5b6d14b7ed8daf432735f5d774b27c