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

Re: [PATCH 1/2] show-ref --verify: accept pseudorefs

From
Patrick Steinhardt <ps@pks.im>
Date
Feb 8, 2024, 08:24 UTC
Message-ID
<ZcSPpbL6AWAOkkCI@tanuki>
In-Reply-To
<xmqq5xz0b3lu.fsf@gitster.g>
On Wed, Feb 07, 2024 at 09:12:29AM -0800, Junio C Hamano wrote:
Show 8 quoted lines
> "Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 
> > ... when CHERRY_PICK_HEAD exists. By calling refname_is_safe() instead
> > of comparing the refname to "HEAD" we can accept all one-level refs that
> > contain only uppercase ascii letters and underscores.
> 
> Geez.  We have at least three implementations to determine if a ref
> is a valid name?

`check_refname_format()` and `refname_is_safe()` are often used in tandem. `check_refname_format()` performs the first set of checks to verify whether the pathname components are valid, whereas `refname_is_safe()` checks for refs which are unsafe e.g. because they try to escape out of "refs/".

I think that we really ought to merge `refname_is_safe()` into `check_refname_format()`. It would require us to introduce a new flag `REFNAME_ALLOW_BAD_NAME` to the latter function so that it would accept refs with a bad name that are otherwise safe. But I think we shouldn't ever allow unsafe names, so merging these two functions would overall reduce the potential for security-relevant issues.

Patrick
Previous: Junio C HamanoNext: phillip.wood123@gmail.com
Message 4 of 6 in “show-ref --verify: accept psuedorefs”
  1. 0/2 show-ref --verify: accept psuedorefsPhillip Wood via GitGitGadget, Feb 7, 2024
  2. 1/2 show-ref --verify: accept pseudorefsPhillip Wood via GitGitGadget, Feb 7, 2024
  3. Junio C HamanoFeb 7, 2024
  4. Patrick SteinhardtFeb 8, 2024
  5. phillip.wood123@gmail.comFeb 8, 2024
  6. 2/2 t1400: use show-ref to check pseudorefsPhillip Wood via GitGitGadget, Feb 7, 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.