diff --git a/src/skillspector/nodes/analyzers/static_patterns_supply_chain.py b/src/skillspector/nodes/analyzers/static_patterns_supply_chain.py index 70d4ea4dad..09061eb7cd 100644 --- a/src/skillspector/nodes/analyzers/static_patterns_supply_chain.py +++ b/src/skillspector/nodes/analyzers/static_patterns_supply_chain.py @@ -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 diff --git a/tests/nodes/analyzers/test_sc8_shipped_bytecode.py b/tests/nodes/analyzers/test_sc8_shipped_bytecode.py index 0485f64a5e..6e1ce22468 100644 --- a/tests/nodes/analyzers/test_sc8_shipped_bytecode.py +++ b/tests/nodes/analyzers/test_sc8_shipped_bytecode.py @@ -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")