git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] t7406: submodule.<name>.update command must not be run from .gitmodules

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Sep 26, 2017, 00:01 UTC
Message-ID
<20170926000121.GM27425@aiede.mtv.corp.google.com>
In-Reply-To
<20170925225054.10819-1-sbeller@google.com>
Stefan Beller wrote:
Show 30 quoted lines
> submodule.<name>.update can be assigned an arbitrary command via setting
> it to "!command". When this command is found in the regular config, Git
> ought to just run that command instead of other update mechanisms.
>
> However if that command is just found in the .gitmodules file, it is
> potentially untrusted, which is why we do not run it.  Add a test
> confirming the behavior.
>
> Suggested-by: Jonathan Nieder <jrnieder@gmail.com>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  t/t7406-submodule-update.sh | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>
> diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
> index 034914a14f..d718cb00e7 100755
> --- a/t/t7406-submodule-update.sh
> +++ b/t/t7406-submodule-update.sh
> @@ -406,6 +406,20 @@ test_expect_success 'submodule update - command in .git/config' '
>  	)
>  '
>  
> +test_expect_success 'submodule update - command in .gitmodules is ignored' '
> +	test_when_finished "git -C super reset --hard HEAD^" &&
> +
> +	write_script must_not_run.sh <<-EOF &&
> +	>$TEST_DIRECTORY/bad
> +	EOF
> +
> +	git -C super config -f .gitmodules submodule.submodule.update "!$TEST_DIRECTORY/must_not_run.sh" &&

Long line, but I don't think I care. I wish there were a tool like "make style" to format shell scripts.

Show 5 quoted lines
> +	git -C super commit -a -m "add command to .gitmodules file" &&
> +	git -C super/submodule reset --hard $submodulesha1^ &&
> +	git -C super submodule update submodule &&
> +	test_path_is_missing bad
> +'

Per offline discussion, you tested that this fails when you use .git/config instead of .gitmodules, so there aren't any subtle typos here. :)

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Thanks for writing it.
Previous: Stefan BellerNext: Johannes Sixt
Message 4 of 10 in “t7406: submodule.<name>.update command must not be run from .gitmodules”
  1. t7406: submodule.<name>.update command must not be run from .gitmodulesStefan Beller, Sep 25, 2017
  2. Jonathan NiederSep 25, 2017
  3. t7406: submodule.<name>.update command must not be run from .gitmodulesStefan Beller, Sep 25, 2017
  4. Jonathan NiederSep 26, 2017
  5. Johannes SixtSep 26, 2017
  6. Junio C HamanoSep 26, 2017
  7. t7406: submodule.<name>.update command must not be run from .gitmodulesStefan Beller, Sep 26, 2017
  8. Johannes SixtSep 26, 2017
  9. t7406: submodule.<name>.update command must not be run from .gitmodulesStefan Beller, Sep 26, 2017
  10. Junio C HamanoSep 27, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.