comparison tests/test-subrepo-git.t @ 29295:9b4f0ad02f51 stable

tests-subrepo-git: use "f" to dump pwned.txt, for portability Rather than sometimes using a complicated shell construct to dump pwned.txt (if it wasn't expected to exist, but might, if something were broken) or just cat (if it was expected to exist), just use the "f" utility, which will be consistent in its behavior across different platforms. Also make sure that *something* gets put into pwned.txt, even if we ended up typoing the message variable.
author Danek Duvall <danek.duvall@oracle.com>
date Thu, 02 Jun 2016 16:18:44 -0700
parents a9764ab80e11
children 60621cecc8c5
comparison
equal deleted inserted replaced
29294:077d0535f51f 29295:9b4f0ad02f51
1133 ? s/snake.python.orig 1133 ? s/snake.python.orig
1134 1134
1135 test for Git CVE-2016-3068 1135 test for Git CVE-2016-3068
1136 $ hg init malicious-subrepository 1136 $ hg init malicious-subrepository
1137 $ cd malicious-subrepository 1137 $ cd malicious-subrepository
1138 $ echo "s = [git]ext::sh -c echo% \$PWNED_MSG% >pwned.txt" > .hgsub 1138 $ echo "s = [git]ext::sh -c echo% pwned:% \$PWNED_MSG% >pwned.txt" > .hgsub
1139 $ git init s 1139 $ git init s
1140 Initialized empty Git repository in $TESTTMP/tc/malicious-subrepository/s/.git/ 1140 Initialized empty Git repository in $TESTTMP/tc/malicious-subrepository/s/.git/
1141 $ cd s 1141 $ cd s
1142 $ git commit --allow-empty -m 'empty' 1142 $ git commit --allow-empty -m 'empty'
1143 [master (root-commit) 153f934] empty 1143 [master (root-commit) 153f934] empty
1150 > PWNED_MSG="your git is too old or mercurial has regressed" hg clone \ 1150 > PWNED_MSG="your git is too old or mercurial has regressed" hg clone \
1151 > malicious-subrepository malicious-subrepository-protected 1151 > malicious-subrepository malicious-subrepository-protected
1152 Cloning into '$TESTTMP/tc/malicious-subrepository-protected/s'... (glob) 1152 Cloning into '$TESTTMP/tc/malicious-subrepository-protected/s'... (glob)
1153 fatal: transport 'ext' not allowed 1153 fatal: transport 'ext' not allowed
1154 updating to branch default 1154 updating to branch default
1155 cloning subrepo s from ext::sh -c echo% $PWNED_MSG% >pwned.txt 1155 cloning subrepo s from ext::sh -c echo% pwned:% $PWNED_MSG% >pwned.txt
1156 abort: git clone error 128 in s (in subrepo s) 1156 abort: git clone error 128 in s (in subrepo s)
1157 [255] 1157 [255]
1158 $ test -f pwned.txt && cat pwned.txt || true 1158 $ f -Dq pwned.txt
1159 pwned.txt: file not found
1159 1160
1160 whitelisting of ext should be respected (that's the git submodule behaviour) 1161 whitelisting of ext should be respected (that's the git submodule behaviour)
1161 $ rm -f pwned.txt 1162 $ rm -f pwned.txt
1162 $ env GIT_ALLOW_PROTOCOL=ext PWNED_MSG="you asked for it" hg clone \ 1163 $ env GIT_ALLOW_PROTOCOL=ext PWNED_MSG="you asked for it" hg clone \
1163 > malicious-subrepository malicious-subrepository-clone-allowed 1164 > malicious-subrepository malicious-subrepository-clone-allowed
1165 fatal: Could not read from remote repository. 1166 fatal: Could not read from remote repository.
1166 1167
1167 Please make sure you have the correct access rights 1168 Please make sure you have the correct access rights
1168 and the repository exists. 1169 and the repository exists.
1169 updating to branch default 1170 updating to branch default
1170 cloning subrepo s from ext::sh -c echo% $PWNED_MSG% >pwned.txt 1171 cloning subrepo s from ext::sh -c echo% pwned:% $PWNED_MSG% >pwned.txt
1171 abort: git clone error 128 in s (in subrepo s) 1172 abort: git clone error 128 in s (in subrepo s)
1172 [255] 1173 [255]
1173 $ cat pwned.txt 1174 $ f -Dq pwned.txt
1174 you asked for it 1175 pwned: you asked for it