Files
agent-radar 1a3a4ccde1
Creator App Tests / PR Spam Gate (push) Skipped
Frontend Tests / PR Spam Gate (push) Skipped
NPM Format (website & console) / PR Spam Gate (push) Skipped
Pre-commit Checks / PR Spam Gate (push) Skipped
QwenPaw Creator Plugin Release / check-version (push) Canceled after 0s
QwenPaw Creator Plugin Release / upload-oss (push) Canceled after 0s
Tests / PR Spam Gate (push) Skipped
CodeQL / CodeQL (python) (push) Canceled after 0s
CodeQL / CodeQL (typescript) (push) Canceled after 0s
Creator App Tests / Creator Backend Tests (push) Canceled after 0s
Creator App Tests / Creator UI Build & Tests (push) Canceled after 0s
E2E Smoke Tests / Playwright UI Smoke (push) Canceled after 0s
Frontend Tests / Detect console changes (push) Canceled after 0s
NPM Format (website & console) / website format check (push) Canceled after 0s
NPM Format (website & console) / console format check (push) Canceled after 0s
Pre-commit Checks / Pre-commit (push) Canceled after 0s
QwenPaw Data Plugin Release / check-version (push) Canceled after 0s
Tests / Detect code changes (push) Canceled after 0s
Frontend Tests / Vitest Unit Tests (push) Canceled after 0s
Frontend Tests / Frontend Summary (push) Canceled after 0s
QwenPaw Data Plugin Release / upload-oss (push) Canceled after 0s
Tests / Maintainer Approval (push) Canceled after 0s
Tests / Unit Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - fallback (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p2 (push) Canceled after 0s
Tests / Coverage Report (push) Canceled after 0s
Tests / Test Summary (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:01:50 +08:00

82 lines
2.1 KiB
Python

# -*- coding: utf-8 -*-
"""Shared fixtures for skill_scanner tests."""
# pylint: disable=redefined-outer-name,unused-argument,protected-access
from unittest.mock import MagicMock
import pytest
from qwenpaw.security.skill_scanner.models import (
Finding,
ScanResult,
Severity,
ThreatCategory,
)
from qwenpaw.security.skill_scanner.scan_policy import ScanPolicy
@pytest.fixture
def default_policy():
"""Return a default ScanPolicy (no file I/O if default YAML missing)."""
return ScanPolicy()
@pytest.fixture
def sample_finding():
"""Create a sample Finding for reuse."""
return Finding(
id="test-rule:file.py:1",
rule_id="test-rule",
category=ThreatCategory.COMMAND_INJECTION,
severity=Severity.HIGH,
title="Test finding",
description="A test finding for unit tests",
file_path="file.py",
line_number=1,
snippet="rm -rf /",
remediation="Do not use dangerous commands",
analyzer="pattern",
)
@pytest.fixture
def sample_scan_result(sample_finding):
"""Create a sample ScanResult with one finding."""
return ScanResult(
skill_name="test-skill",
skill_directory="/tmp/test-skill",
findings=[sample_finding],
scan_duration_seconds=0.1,
analyzers_used=["pattern"],
)
@pytest.fixture
def safe_scan_result():
"""Create a ScanResult with no findings (safe)."""
return ScanResult(
skill_name="safe-skill",
skill_directory="/tmp/safe-skill",
findings=[],
scan_duration_seconds=0.05,
analyzers_used=["pattern"],
)
@pytest.fixture
def skill_dir(tmp_path):
"""Create a minimal skill directory with sample files."""
skill = tmp_path / "test-skill"
skill.mkdir()
(skill / "SKILL.md").write_text("# Test Skill\nA test skill.")
(skill / "hello.py").write_text('print("hello")\n')
return skill
@pytest.fixture
def mock_analyzer():
"""Create a mock BaseAnalyzer."""
analyzer = MagicMock()
analyzer.get_name.return_value = "mock_analyzer"
analyzer.analyze.return_value = []
return analyzer