Skip to content

Commit e24eaec

Browse files
committed
test(test_hg): Alias command injection recreation
1 parent 96d2ada commit e24eaec

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tests/test_hg.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import pytest
77

8-
from libvcs.shortcuts import create_repo_from_pip_url
8+
from libvcs.shortcuts import create_repo, create_repo_from_pip_url
99
from libvcs.util import run, which
1010

1111
if not which("hg"):
@@ -72,3 +72,21 @@ def test_repo_mercurial(tmp_path: pathlib.Path, repos_path, hg_remote):
7272
)
7373

7474
assert mercurial_repo.get_revision() == test_repo_revision
75+
76+
77+
def test_cmd_injection_vuln(
78+
monkeypatch: pytest.MonkeyPatch,
79+
user_path: pathlib.Path,
80+
tmp_path: pathlib.Path,
81+
hg_remote,
82+
):
83+
random_dir = tmp_path / "random"
84+
random_dir.mkdir()
85+
monkeypatch.chdir(str(random_dir))
86+
mercurial_repo = create_repo(
87+
url="--config=alias.clone=!touch ./HELLO", vcs="hg", repo_dir="./"
88+
)
89+
with pytest.raises(Exception):
90+
mercurial_repo.update_repo()
91+
92+
assert pathlib.Path(random_dir / "HELLO").exists()

0 commit comments

Comments
 (0)