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

Re: [PATCH 2/2] setup: make bareRepository=explicit work in GIT_DIR of a secondary worktree

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 9, 2024, 01:14 UTC
Message-ID
<xmqqttlgdx4t.fsf@gitster.g>
In-Reply-To
<CAO_smVjD8DFcvveAg2iiWGhtNJGCT1ieAUzJbX3TNNJjm-5rMw@mail.gmail.com>
Kyle Lippincott <spectral@google.com> writes:
Show 6 quoted lines
>> > What loss of security do we have if we don't have as stringent of a
>> > check? i.e. if we just did `return !!strstr(path, "/.git/worktrees/)`?
>>
>> No loss of security.
>
> Then should we just do that?
I do not see what you mean.
Show 18 quoted lines
> + /* Assumption: `path` points to the root of a $GIT_DIR. */
>  static int is_repo_with_working_tree(const char *path)
>  {
> -       return ends_with_path_components(path, ".git");
> +       /* $GIT_DIR immediately below the primary working tree */
> +       if (ends_with_path_components(path, ".git"))
> +               return 1;
> +
> +       /*
> +        * Also allow $GIT_DIRs in secondary worktrees.
> +        * These do not end in .git, but are still considered safe because
> +        * of the .git component in the path.
> +        */
> +       if (strstr(path, "/.git/worktrees/"))
> +               return 1;
> +
> +       return 0;
>  }

Ah, no. I thought you were asking "goto out" vs "return", and my answer was about these two. Whether you leave with "goto out" or "return", it does not change the security posture. Direct return will raise the risk of leaking resources after careless future updates to the code.

I didn't get that you do not want to see the other two "sanity check".

Losing these sanity checks may not lose "security" per-se, but it may raise the risk of misidentification. A healthy GIT_DIR of a secondary worktree should satisfy these two extra conditions.

Previous: Kyle LippincottNext: Kyle Meyer
Message 11 of 17 in “setup: allow cwd=.git w/ bareRepository=explicit”
  1. setup: allow cwd=.git w/ bareRepository=explicitKyle Lippincott via GitGitGadget, Jan 20, 2024
  2. Junio C HamanoJan 20, 2024
  3. Kyle LippincottJan 22, 2024
  4. Junio C HamanoMar 6, 2024
  5. 0/2 Loosening safe.bareRepository=explicit even furtherJunio C Hamano, Mar 8, 2024
  6. 2/2 setup: make bareRepository=explicit work in GIT_DIR of a secondary worktreeJunio C Hamano, Mar 8, 2024
  7. Junio C HamanoMar 8, 2024
  8. Kyle LippincottMar 8, 2024
  9. Junio C HamanoMar 8, 2024
  10. Kyle LippincottMar 9, 2024
  11. Junio C HamanoMar 9, 2024
  12. Kyle MeyerMar 9, 2024
  13. Junio C HamanoMar 9, 2024
  14. 1/2 setup: detect to be in $GIT_DIR with a new helperJunio C Hamano, Mar 8, 2024
  15. setup: notice more types of implicit bare repositoriesJunio C Hamano, Mar 9, 2024
  16. Kyle LippincottMar 11, 2024
  17. Junio C HamanoMar 11, 2024

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.