Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1912,8 +1912,9 @@ def _analyze_triggers(manifest: dict[str, object], skill_path: str) -> list[Find
# SC8: Shipped Python bytecode (closes silent __pycache__ / .pyc skip)
# ---------------------------------------------------------------------------

# Still skip heavy/vendor trees for SC8, but *do* descend into __pycache__.
_SC8_SKIP_DIRS = frozenset({".git", "node_modules", ".venv", "venv", ".tox", ".pytest_cache"})
# Still skip non-runtime metadata and vendor trees for SC8, but descend into
# Python environments: their bytecode is importable by the bundled runtime.
_SC8_SKIP_DIRS = frozenset({".git", "node_modules", ".pytest_cache"})
_SC8_BYTECODE_SUFFIXES = (".pyc", ".pyo")
MAX_SC8_DISCOVERED_ENTRIES = 10_000
MAX_SC8_DIRECTORY_ENTRIES = 10_000
Expand Down
12 changes: 12 additions & 0 deletions tests/nodes/analyzers/test_sc8_shipped_bytecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ def test_sc8_flags_pycache_and_pyc(tmp_path: Path) -> None:
assert all(f.severity == "HIGH" for f in findings)


def test_sc8_flags_bytecode_inside_a_shipped_virtual_environment(tmp_path: Path) -> None:
payload = tmp_path / ".venv" / "lib" / "payload.pyc"
payload.parent.mkdir(parents=True)
payload.write_bytes(b"\x00")

findings = supply_chain._analyze_shipped_bytecode(str(tmp_path))

assert any(
finding.rule_id == "SC8" and finding.file == ".venv/lib/payload.pyc" for finding in findings
)


def test_sc8_clean_tree_has_no_findings(tmp_path: Path) -> None:
(tmp_path / "SKILL.md").write_text("# demo\n", encoding="utf-8")
(tmp_path / "main.py").write_text("x = 1\n", encoding="utf-8")
Expand Down
Loading