Skip to content

Commit 2c988fa

Browse files
authored
test: fix tests use of 'file' protocol
In response to CVE-2022-39253, Git now considers the `file://` protocol to be unsafe by default. The default value of the `protocol.file.allow` config variable was changed to `user` [1], meaning that a file URL or a local path is only trusted if it came directly from user input, and not if it came through a command which executes a clone/fetch/push internally. The tests fall foul of this new requirement by attempting to run a `git submodule add` with a local directory. Internally, this performs a clone, which is no longer trusted because of the change described above. This results in the command failing with a "transport 'file' not allowed" message. Since this is only the case for a single command, then fix the test by setting `protocol.file.allow` to `always` when we run it. [1] https://github.blog/2022-10-18-git-security-vulnerabilities-announced/#cve-2022-39253
1 parent cc6b856 commit 2c988fa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

git_sizer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ func TestSubmodule(t *testing.T) {
701701
require.NoError(t, cmd.Run(), "creating main commit")
702702

703703
// Make subm a submodule of main:
704-
cmd = mainRepo.GitCommand(t, "submodule", "add", submRepo.Path, "sub")
704+
cmd = mainRepo.GitCommand(t, "-c", "protocol.file.allow=always", "submodule", "add", submRepo.Path, "sub")
705705
cmd.Dir = mainRepo.Path
706706
require.NoError(t, cmd.Run(), "adding submodule")
707707

0 commit comments

Comments
 (0)