test_cli_injection.py
python
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
1 day ago
| 1 | """Security tests for CLI path traversal and injection.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from pathlib import Path |
| 6 | |
| 7 | import pytest |
| 8 | |
| 9 | from adapters.errors import ConfigError |
| 10 | from adapters.templating import substitute_tokens |
| 11 | from cli.paths import PathEscapeError, confine_path |
| 12 | from tests.support import run_cli |
| 13 | |
| 14 | |
| 15 | def test_confine_path_rejects_escape(tmp_path: Path) -> None: |
| 16 | with pytest.raises(PathEscapeError): |
| 17 | confine_path(tmp_path, "../outside") |
| 18 | |
| 19 | |
| 20 | def test_unknown_template_token_fails_closed() -> None: |
| 21 | with pytest.raises(ConfigError): |
| 22 | substitute_tokens("{{evil.token}}", {"repo.name": "x"}, fail_on_unknown=True) |
| 23 | |
| 24 | |
| 25 | def test_init_outside_repo_config_refused(tmp_path: Path) -> None: |
| 26 | repo = tmp_path / "repo" |
| 27 | repo.mkdir() |
| 28 | code = run_cli( |
| 29 | [ |
| 30 | "init", |
| 31 | "--regime", |
| 32 | "git-only", |
| 33 | "--non-interactive", |
| 34 | "--config", |
| 35 | "../outside/config.yaml", |
| 36 | ], |
| 37 | cwd=repo, |
| 38 | ) |
| 39 | assert code == 4 |
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