FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Allow trusted submodule metadata redirection · gitpython-developers/GitPython@79db2ac · GitHub

Repository navigation

Commit 79db2ac

Browse files
authored andcommitted
Allow trusted submodule metadata redirection
The Python package and Alpine test workflows failed across the submodule suite because GitPython internally supplies --separate-git-dir when creating modern submodule layouts. The new public clone guard correctly rejected that option, but could not distinguish the library-generated path from caller input. Validate caller-provided keyword and multi-options before adding the library-controlled metadata path, then explicitly allow the resulting trusted clone invocation. This preserves rejection of unsafe clone_multi_options while restoring normal submodule creation. Update the one test that intentionally invokes Repo.clone_from() with its own separate git directory to opt in explicitly. Validation: test/test_submodule.py and test/test_clone.py (62 passed, 4 skipped, 1 xfailed).
1 parent cc9a4e0 commit 79db2ac

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎git/objects/submodule/base.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import ntpath
1010
import os
1111
import os.path as osp
12+
import shlex
1213
import stat
1314
import sys
1415
import uuid
@@ -363,6 +364,17 @@ def _clone_repo(
363364
module_abspath = cls._module_abspath(repo, path, name)
364365
module_checkout_path = module_abspath
365366
if cls._need_gitfile_submodules(repo.git):
367+
if not allow_unsafe_options:
368+
Git.check_unsafe_options(
369+
Git._option_candidates([], kwargs), repo.unsafe_git_clone_options
370+
)
371+
multi_options = kwargs.get("multi_options")
372+
if multi_options:
373+
Git.check_unsafe_options(
374+
shlex.split(" ".join(cast("Sequence[str]", multi_options))),
375+
repo.unsafe_git_clone_options,
376+
)
377+
allow_unsafe_options = True
366378
kwargs["separate_git_dir"] = module_abspath
367379
module_abspath_dir = osp.dirname(module_abspath)
368380
if not osp.isdir(module_abspath_dir):

‎test/test_submodule.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,7 @@ def test_update_rejects_parent_component_in_name(self, rwdir):
954954
source.working_tree_dir,
955955
osp.join(clone.working_tree_dir, "module"),
956956
separate_git_dir=osp.join(rwdir, "escaped", "module"),
957+
allow_unsafe_options=True,
957958
)
958959
with pytest.raises(ValueError, match="submodule name"):
959960
clone.submodules[0].update(init=True)

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL