sapling/eden/scm/tests/test-invalid-windows-filepath.t
Saul Gutierrez 60a08f075d tests: add a test for the path traversal vulnerability on Windows
Summary: As previously mentioned in D41508860 (b3312b4492), cloning repos that contained backslashes (e.g. ..\test.txt) used to be a vulnerability. This diff adds an integration test for making sure that the vulnerability is patched.

Reviewed By: quark-zju

Differential Revision: D41755292

fbshipit-source-id: 672ede6960bacd5815ce458ae4268c263412bd9a
2022-12-07 19:54:24 -08:00

29 lines
973 B
Perl

#debugruntest-compatible
#require git
$ . $TESTDIR/git.sh
Make sure that Windows is unable to check out paths with `..\` in their path.
$ mkdir brokengitrepo
$ tar -xf $TESTDIR/brokengitrepo.tar.gz -C $TESTTMP/brokengitrepo
#if windows
$ hg clone --git "$TESTTMP/brokengitrepo" brokencopy 2>&1 | tail -8
error.RustError: Can't write 'RepoPath("..\\windowstroublemaker.txt")' after handling error "Can't write into ..\windowstroublemaker.txt
Caused by:
Invalid component .. in path ..\windowstroublemaker.txt"
Caused by:
0: Can't write into ..\windowstroublemaker.txt
1: Invalid component .. in path ..\windowstroublemaker.txt
#else
$ hg clone --git "$TESTTMP/brokengitrepo" brokencopy
From $TESTTMP/brokengitrepo
* [new ref] 9ff0e959c6d6dec6f16d7ba9fcaa9ed407bf77d6 -> remote/master
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ ls -a brokencopy
..\windowstroublemaker.txt
.hg
#endif