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

Re: [PATCH 2/7] t: introduce tests for unexpected object types

From
Taylor Blau <me@ttaylorr.com>
Date
Apr 6, 2019, 05:23 UTC
Message-ID
<20190406052322.GA37216@Taylors-MBP.hsd1.wa.comcast.net>
In-Reply-To
<20190405183142.GD2284@sigill.intra.peff.net>
Hi Peff,
On Fri, Apr 05, 2019 at 02:31:42PM -0400, Jeff King wrote:
Show 26 quoted lines
> On Thu, Apr 04, 2019 at 08:37:44PM -0700, Taylor Blau wrote:
>
> > Let A be the object referenced with an unexpected type, and B be the
> > object doing the referencing. Do the following:
> >
> >   - test 'git rev-list --objects A B'. This causes A to be "cached", and
> >     presents the above scenario.
> >
> > Likewise, if we have a tree entry that claims to be a tree (for example)
> > but points to another object type (say, a blob), there are two ways we
> > might find out:
> >
> >   - when we call lookup_tree(), we might find that we've already seen
> >     the object referenced as another type, in which case we'd get NULL
> >
> >   - we call lookup_tree() successfully, but when we try to read the
> >     object, we find out it's something else.
> >
> > We should check that we behave sensibly in both cases (especially
> > because it is easy for a malicious actor to provoke one case or the
> > other).
>
> I think our pasting together of multiple commits adding the lone/seen
> cases ended up in some redundancy in the description. In particular, I'm
> not sure what the first paragraph/bullet quoted above is trying to say,
> as it corresponds to the second bullet in the later list.

I agree that this is at the very least redundant, and at the most, confusing. I think that you're right that this is the result of squashing the commits often enough that some of this cruft stuck around and got combined in ways that it shouldn't have.

Show 15 quoted lines
> Maybe collapse them together like:
>
>   We might hit an unexpected type in two different ways (imagine we have
>   a tree entry that claims to be a tree but actually points to a blob):
>
>     - when we call lookup_tree(), we might find that we've already seen
>       the object referenced as a blob, in which case we'd get NULL. We
>       can exercise this with "git rev-list --objects $blob $tree", which
>       guarantees that the blob will have been parsed before we look in
>       the tree. These tests are marked as "seen" in the test script.
>
>     - we call lookup_tree() successfully, but when we try to read the
>       object, we find out it's something else. We construct our tests
>       such that $blob is not otherwise mentioned in $tree. These tests
>       are marked as "lone" in the script.

Indeed, this is much cleaner (and thanks for writing it here, and saving me the work). I think that I will take this as-is for 2/7 in v2.

> -Peff

Thanks, Taylor

Previous: Jeff KingNext: Taylor Blau
Message 24 of 41 in “harden unexpected object types checks”
  1. 0/7 harden unexpected object types checksTaylor Blau, Apr 5, 2019
  2. 1/7 t: move 'hex2oct' into test-lib-functions.shTaylor Blau, Apr 5, 2019
  3. 2/7 t: introduce tests for unexpected object typesTaylor Blau, Apr 5, 2019
  4. SZEDER GáborApr 5, 2019
  5. Jeff KingApr 5, 2019
  6. SZEDER GáborApr 5, 2019
  7. Jeff KingApr 5, 2019
  8. Ævar Arnfjörð BjarmasonApr 7, 2019
  9. Taylor BlauApr 9, 2019
  10. Ævar Arnfjörð BjarmasonApr 9, 2019
  11. Taylor BlauApr 10, 2019
  12. Junio C HamanoApr 8, 2019
  13. Eric SunshineApr 5, 2019
  14. Jeff KingApr 5, 2019
  15. Taylor BlauApr 6, 2019
  16. Junio C HamanoApr 8, 2019
  17. Taylor BlauApr 9, 2019
  18. Eric SunshineApr 9, 2019
  19. Taylor BlauApr 9, 2019
  20. Eric SunshineApr 9, 2019
  21. Taylor BlauApr 10, 2019
  22. Taylor BlauApr 6, 2019
  23. Jeff KingApr 5, 2019
  24. Taylor BlauApr 6, 2019
  25. 3/7 list-objects.c: handle unexpected non-blob entriesTaylor Blau, Apr 5, 2019
  26. 4/7 list-objects.c: handle unexpected non-tree entriesTaylor Blau, Apr 5, 2019
  27. 5/7 get_commit_tree(): return NULL for broken treeTaylor Blau, Apr 5, 2019
  28. 6/7 rev-list: let traversal die when --missing is not in useTaylor Blau, Apr 5, 2019
  29. Jeff KingApr 5, 2019
  30. Taylor BlauApr 6, 2019
  31. Jeff KingApr 7, 2019
  32. Taylor BlauApr 9, 2019
  33. 7/7 rev-list: detect broken root treesTaylor Blau, Apr 5, 2019
  34. 0/7 harden unexpected object types checksTaylor Blau, Apr 10, 2019
  35. 1/7 t: move 'hex2oct' into test-lib-functions.shTaylor Blau, Apr 10, 2019
  36. 2/7 t: introduce tests for unexpected object typesTaylor Blau, Apr 10, 2019
  37. 3/7 list-objects.c: handle unexpected non-blob entriesTaylor Blau, Apr 10, 2019
  38. 4/7 list-objects.c: handle unexpected non-tree entriesTaylor Blau, Apr 10, 2019
  39. 5/7 get_commit_tree(): return NULL for broken treeTaylor Blau, Apr 10, 2019
  40. 6/7 rev-list: let traversal die when --missing is not in useTaylor Blau, Apr 10, 2019
  41. 7/7 rev-list: detect broken root treesTaylor Blau, Apr 10, 2019

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.