From 51e448d6afa10ee8b127af981d6abbc53ab8169a Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Fri, 6 Sep 2024 12:22:57 -0700 Subject: [PATCH] Fix `cabal-install:long-tests` with Git >=2.38.1 Closes #10312. Git 2.38.1 and newer fails to clone from local paths with `fatal: transport 'file' not allowed` unless `protocol.file.allow=always` is set. This is not safe in general, but it's fine in the test suite. See: https://github.blog/open-source/git/git-security-vulnerabilities-announced/#fn-67904-1 See: https://git-scm.com/docs/git-config#Documentation/git-config.txt-protocolallow --- .github/workflows/validate.yml | 3 --- .../UnitTests/Distribution/Client/VCS.hs | 24 ++++++++++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 2d8be7f02a3..d29ff811fd7 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -133,9 +133,6 @@ jobs: key: ${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }} restore-keys: ${{ runner.os }}-${{ matrix.ghc }}- - - name: "Work around git problem https://bugs.launchpad.net/ubuntu/+source/git/+bug/1993586 (cabal PR #8546)" - run: git config --global protocol.file.allow always - # The tool is not essential to the rest of the test suite. If # hackage-repo-tool is not present, any test that requires it will # be skipped. diff --git a/cabal-install/tests/UnitTests/Distribution/Client/VCS.hs b/cabal-install/tests/UnitTests/Distribution/Client/VCS.hs index 0bd49355913..a76dd39b082 100644 --- a/cabal-install/tests/UnitTests/Distribution/Client/VCS.hs +++ b/cabal-install/tests/UnitTests/Distribution/Client/VCS.hs @@ -847,7 +847,7 @@ vcsTestDriverGit -> VCSTestDriver vcsTestDriverGit verbosity vcs submoduleDir repoRoot = VCSTestDriver - { vcsVCS = vcs + { vcsVCS = vcs' , vcsRepoRoot = repoRoot , vcsIgnoreFiles = Set.empty , vcsInit = @@ -872,7 +872,7 @@ vcsTestDriverGit verbosity vcs submoduleDir repoRoot = , vcsTagState = \_ tagname -> git ["tag", "--force", "--no-sign", tagname] , vcsSubmoduleDriver = - pure . vcsTestDriverGit verbosity vcs submoduleDir . (submoduleDir ) + pure . vcsTestDriverGit verbosity vcs' submoduleDir . (submoduleDir ) , vcsAddSubmodule = \_ source dest -> do destExists <- (||) @@ -897,8 +897,26 @@ vcsTestDriverGit verbosity vcs submoduleDir repoRoot = updateSubmodulesAndCleanup } where + -- Git 2.38.1 and newer fails to clone from local paths with `fatal: transport 'file' + -- not allowed` unless `protocol.file.allow=always` is set. + -- + -- This is not safe in general, but it's fine in the test suite. + -- + -- See: https://github.blog/open-source/git/git-security-vulnerabilities-announced/#fn-67904-1 + -- See: https://git-scm.com/docs/git-config#Documentation/git-config.txt-protocolallow + vcs' = + vcs + { vcsProgram = + (vcsProgram vcs) + { programDefaultArgs = + programDefaultArgs (vcsProgram vcs) + ++ [ "-c" + , "protocol.file.allow=always" + ] + } + } gitInvocation args = - (programInvocation (vcsProgram vcs) args) + (programInvocation (vcsProgram vcs') args) { progInvokeCwd = Just repoRoot } git = runProgramInvocation verbosity . gitInvocation