Commit Graph

9 Commits

Author SHA1 Message Date
Tonis Tiigi
d19ecc730c git: normalize and validate subdir paths
Normalize Git subdir fragments and validate checkout subdir components
so each segment must be a real directory, preventing traversal and symlink escapes.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 8c994eb561a2646b35352e5663afecd225306214)
2026-03-25 08:14:30 -07:00
CrazyMax
0888dc458c dfgitutil: FragmentFormat func
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-10-11 12:47:17 +02:00
Tonis Tiigi
c8ce372293 dfgitutil: add querystring style URLs to dfgitutil
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-08-28 15:33:19 -07:00
Akihiro Suda
e6676287ca git url: support query form
Fix issue 4905, but the syntax differs from the original proposal.

The document will be added to
https://github.com/docker/docs/blob/main/content/manuals/build/concepts/context.md#url-fragments

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-08-28 13:50:17 -07:00
Akihiro Suda
2207a88aad mv util/gitutil/git_ref.go frontend/dockerfile/dfgitutil/git_ref.go
The `ParseGitRef` function was only used in `frontend/{dockerfile, dockerui}`,
expect a single occurrence in `solver/llbsolver/history.go`.

The occurrence in `solver/llbsolver/history.go` now uses
`util/gitutil/git_url.go:ParseURL()`.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-08-20 18:09:59 +09:00
Akihiro Suda
f8447d305c git url: rename GitURLFragment to GitURLOpts
No substantial code change.
Non-fragment data can be added in this structure too.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-06-05 15:12:44 +09:00
Justin Chadwell
3c6f6e4ee1 chore: refactor IsGitTransport to avoid duplication
Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-02-01 15:39:16 +00:00
Justin Chadwell
9a51bb0ff1 git: use custom giturl type to preserve original remote
This resolves a regression introduced in
50e75e3565. In this previous patch, I'd
incorrectly assumed that scp-like URLs can express a subset of
"standard"-URLs and so we can always safely convert them for
consistency. This isn't true - the URL "git@example.com:foo" should be
resolved to the home directory of the host, however, the converted URL
"ssh://git@example.com/foo" will be resolved to the root of the host.

To resolve this, we need to not perform this conversion. However, we
also need preserve the behaviour of firm distinction between SCP and
normal URL types (so as to keep proper port parsing).

To do this, we add a new GitURL type to the gitutil package. This new
type contains all useful fields shared in common between the standard
libraries url package and our custom scp-style url parsing package. This
keeps the previous property of a single clean interface to all GitURLs,
while also ensuring that we preserve the original URL to pass to the Git
CLI (making sure we strip fragments out, which are used as
buildkit-level metadata).

As a side-effect of this, the client-side calling code for parsing
git urls is simplified (so we don't have to do fragment wrangling at
every call point).

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-10-12 19:17:11 +01:00
Justin Chadwell
50e75e3565 git: update parsing to clarify between scp-style urls
This should also resolve the ports parsing issue.

Co-authored-by: Aaron Lehmann <alehmann@netflix.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-08-22 11:36:35 +01:00