test_review_injection.py python
29 lines 1.1 KB
Raw
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day ago
1 """Security tests — artifact injection cannot invoke shell (§K5.12)."""
2
3 from __future__ import annotations
4
5 from pathlib import Path
6 from unittest.mock import patch
7
8 from cli.kit_root import kit_root
9 from tests.support import git_status_runner, pass_provider_factory, run_cli, write_config
10
11
12 def test_artifact_shell_metacharacters_no_shell(tmp_path: Path) -> None:
13 write_config(tmp_path, "config-git-only.yaml")
14 artifact = tmp_path / "docs" / "evil.md"
15 artifact.parent.mkdir(parents=True)
16 artifact.write_text(
17 "# evil\n\n```yaml\nphase: x\noutputs:\n - id: a\n path: docs/a.md\n frozen: true\n```\n\n$(rm -rf /)\n",
18 encoding="utf-8",
19 )
20 with patch("adapters.runner.subprocess.run") as mocked:
21 code = run_cli(
22 ["review", "--freeze", "docs/evil.md"],
23 cwd=tmp_path,
24 runner=git_status_runner(),
25 kit=kit_root(),
26 review_provider_factory=pass_provider_factory(),
27 )
28 assert mocked.call_count == 0 or all("rm -rf" not in str(call) for call in mocked.call_args_list)
29 assert code in {0, 7, 8}
File History 2 commits
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day ago
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439 feat: K1-P1 complete — agent provenance, build-verification… Sonnet 4.6 patch 53 days ago