3 test_description='check handling of .. in submodule names
5 Exercise the name-checking function on a variety of names, and then give a
6 real-world setup that confirms we catch this in practice.
10 test_expect_success 'check names' '
11 cat >expect <<-\EOF &&
16 git submodule--helper check-name >actual <<-\EOF &&
31 test_cmp expect actual
34 test_expect_success 'create innocent subrepo' '
36 git -C innocent commit --allow-empty -m foo
39 test_expect_success 'submodule add refuses invalid names' '
41 git submodule add --name ../../modules/evil "$PWD/innocent" evil
44 test_expect_success 'add evil submodule' '
45 git submodule add "$PWD/innocent" evil &&
48 cp -r .git/modules/evil modules &&
49 write_script modules/evil/hooks/post-checkout <<-\EOF &&
50 echo >&2 "RUNNING POST CHECKOUT"
53 git config -f .gitmodules submodule.evil.update checkout &&
54 git config -f .gitmodules --rename-section \
55 submodule.evil submodule.../../modules/evil &&
60 # This step seems like it shouldn't be necessary, since the payload is
61 # contained entirely in the evil submodule. But due to the vagaries of the
62 # submodule code, checking out the evil module will fail unless ".git/modules"
63 # exists. Adding another submodule (with a name that sorts before "evil") is an
64 # easy way to make sure this is the case in the victim clone.
65 test_expect_success 'add other submodule' '
66 git submodule add "$PWD/innocent" another-module &&
67 git add another-module &&
68 git commit -am another
71 test_expect_success 'clone evil superproject' '
72 git clone --recurse-submodules . victim >output 2>&1 &&
73 ! grep "RUNNING POST CHECKOUT" output