1182 Commits

Author SHA1 Message Date
CrazyMax
b4e609fb7c exporter: revert attestation manifest push order
This reverts the change from #7012.

Referrer manifests may be pushed before their subject, and the OCI distribution spec requires registries to initially accept a manifest whose subject does not exist yet. Keep BuildKit's default push order aligned with that behavior instead of working around registries that reject this flow.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
(cherry picked from commit 409c8da50f)
2026-08-04 12:00:06 +02:00
CrazyMax
c300afc325 exporter: fix attestation manifest push order
OCI artifact attestations carry a subject reference to the image manifest.
Push manifests in an order that keeps child manifests before parent indexes
while also pushing any in-stack subject manifest before the attestation
that references it.

Add an integration test variant with a strict registry proxy to cover
registries that reject manifests whose subject doesn't already exist.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
(cherry picked from commit 067b18bd03)
2026-08-03 11:41:44 +02:00
Tõnis Tiigi
b8a2467139 Merge pull request #6966 from nomad3/fix/otel-ignore-error
detect: read OTEL_IGNORE_ERROR from environment
2026-07-22 10:24:42 -07:00
Tõnis Tiigi
36d75d2267 Merge pull request #6933 from thaJeztah/zstd_mapping
util/compression: use zstd.EncoderLevelFromZstd to map compression levels
2026-07-22 07:35:32 -07:00
CrazyMax
e89fccf347 cache/s3: only request required upload checksums
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-07-22 13:23:28 +02:00
Tonis Tiigi
cdb7d70861 Update patch dependencies
Bump patch-level dependencies while leaving
packageurl-go unchanged. This updates AWS config/credentials,
smithy-go, klauspost/compress, and sigstore-go, with required
companion bumps from their module constraints.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-07-21 22:24:51 -07:00
Simon Aguilera
14e0dfbd2c detect: read OTEL_IGNORE_ERROR from environment
Signed-off-by: Simon Aguilera <saguilera1608@gmail.com>
2026-07-18 21:52:28 -04:00
Sebastiaan van Stijn
ae67797786 Use bolt hashmap freelist for metadata databases
bolt documents the array freelist as potentially degrading significantly
for large fragmented databases, while the hashmap freelist is faster in
almost all circumstances. From the [DB.FreelistType] GoDoc:

    // FreelistType sets the backend freelist type. There are two options. Array which is simple but endures
    // dramatic performance degradation if database is large and fragmentation in freelist is common.
    // The alternative one is using hashmap, it is faster in almost all circumstances
    // but it doesn't guarantee that it offers the smallest page id available. In normal case it is safe.
    // The default type is array
    FreelistType FreelistType

While the default is still `FreelistArrayType`, the package shows that
the intent is to make `FreelistMapType` the default in future;
https://pkg.go.dev/go.etcd.io/bbolt@v1.5.0#pkg-constants

    // TODO(ahrtr): eventually we should (step by step)
    //  1. default to `FreelistMapType`;
    //  2. remove the `FreelistArrayType`, do not export `FreelistMapType`
    //     and remove field `FreelistType' from both `DB` and `Options`;

This keeps the on-disk format unchanged and only changes the in-memory
freelist implementation used after opening the DB.

[DB.FreelistType]: https://pkg.go.dev/go.etcd.io/bbolt@v1.5.0#DB.FreelistType

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-07-10 11:41:13 +02:00
Sebastiaan van Stijn
c4c8751ce0 use consistent alias for go.etcd.io/bbolt
All imports aliased it, except for one.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-07-10 11:39:58 +02:00
Sebastiaan van Stijn
7f3be9faca fix: G118: Goroutine uses context.Background/TODO (gosec)
cache/manager.go:238:3: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
            go link.Release(context.TODO())
            ^
    cache/refs.go:1519:2: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
        go func() {
        ^
    session/testutil/testutil.go:22:3: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
            go func() {
            ^
    solver/edge.go:975:4: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
                go results[i].Release(context.TODO())
                ^
    util/leaseutil/manager.go:79:2: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
        go l.Discard()
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-07-09 12:43:29 +02:00
Sebastiaan van Stijn
fcb7e529c2 util/compression: use zstd.EncoderLevelFromZstd to map compression levels
The toZstdEncoderLevel utility was introduced in cab33b1e31,
and has a custom mapping of zstd compressions levels to their go (klauspost/compress)
counterparts.

Swap our local implementation for the one in klauspost/compress so that new levels
implemented in klauspost/compress will also be mapped if they arrive.

This does change some mappings;

| Input level | Before                 | After                    |
|-------------|------------------------|--------------------------|
| `< 0`       | `SpeedDefault`         | `SpeedFastest`           |
| `6`         | `SpeedDefault`         | `SpeedBetterCompression` |
| `9`         | `SpeedBestCompression` | `SpeedBetterCompression` |

While updating, also slightly refactor;

- use an options slice to skip setting the option if no config was set, and
  to allow adding additional options.
- inline zstdWriter where used, as it was only used in a single place.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-07-07 19:55:33 +02:00
Tõnis Tiigi
587d308bea Merge pull request #6895 from gilescope/giles-fix-sshkeyscan-nonstandard-port
feat: not fail on non-default ports
2026-06-26 16:42:33 -07:00
Giles Cope
6678be5be2 feat: not fail on non-default ports
Signed-off-by: Giles Cope <gilescope@gmail.com>
2026-06-24 06:30:57 +01:00
Tõnis Tiigi
28fb74fa00 Merge pull request #6874 from thaJeztah/rm_deprecated_otel_envs
util/tracing: remove fallbacks for OTEL_TRACE_PARENT, OTEL_TRACE_STATE
2026-06-22 23:57:29 -07:00
MohammadHasan Akbari
8086fae369 gitutil: preserve SUDO_UID for git subprocesses
When git runs as root under sudo it consults SUDO_UID to decide whether a
repository's ownership can be trusted, additionally granting access to
repositories owned by the user who invoked sudo. GitCLI builds a
restricted environment for the git subprocess and did not forward
SUDO_UID, so commands such as `sudo docker build` tripped git's "detected
dubious ownership" check and silently lost commit provenance: the build
still succeeds but prints "current commit information was not captured by
the build".

Forward SUDO_UID (only when present) on the host git config path enabled
via WithHostGitConfig, i.e. client-side local git inspection. The default
isolated path used by daemon-side callers is left untouched so it does not
pick up host environment. This matches git's own default behavior under
sudo: it does not disable safe.directory checks and is not equivalent to
safe.directory=*; it merely lets git trust repositories owned by the
invoking user. Only SUDO_UID is forwarded (git's ownership check is
uid-based and never consults SUDO_GID).

Fixes the root cause for docker/buildx#3855. buildx inspects the build
context through this GitCLI with WithHostGitConfig enabled, so buildx
picks the fix up via a moby/buildkit dependency bump with no buildx-side
code change.

Signed-off-by: MohammadHasan Akbari <jarqvi.jarqvi@gmail.com>
2026-06-18 10:28:08 +04:00
Sebastiaan van Stijn
61e69f5da0 util/tracing: remove fallbacks for OTEL_TRACE_PARENT, OTEL_TRACE_STATE
The OTEL_TRACE_PARENT and OTEL_TRACE_STATE environment variables were
deprecated in BuildKit v0.10 (f5dbcf6e99)
because they were deprecated in the OTel specification in favor of the
TRACEPARENT and TRACESTATE env-vars, aligning with the [W3C traceparent]
and [W3C tracestate] headers.

[W3C traceparent]: https://www.w3.org/TR/trace-context/#traceparent-header
[W3C tracestate]: https://www.w3.org/TR/trace-context/#tracestate-header

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-06-15 11:12:12 +02:00
CrazyMax
bac24d3910 cniprovider: keep loopback DNS dials in caller netns
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-06-11 11:27:10 -07:00
Tonis Tiigi
4015a3c77c cniprovider: keep proxy dials in CNI netns
Dialing from a CNI namespace with the standard net.Dialer can escape the
namespace through happy-eyeballs connection attempts or resolver goroutines.

Use a serial dialer and route Go resolver sockets through the target
namespace, while preserving host loopback DNS stubs such as systemd-resolved
and Docker embedded DNS.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-11 11:27:09 -07:00
CrazyMax
3719550704 proxyprovider: test HTTP/2 transport clone with custom dialer
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-06-11 11:39:21 +02:00
Tonis Tiigi
19bcaabb39 proxyprovider: fix exec proxy HTTPS regressions
Commit 91cc422d5 split exec proxying from exec network mode and
started cloning the proxy transport per egress namespace with a custom
DialContext.

Without ForceAttemptHTTP2, the cloned transport could advertise h2 via
ALPN without a registered HTTP/2 RoundTripper, causing Alpine apk update
requests to fail with proxy 502 responses.

Restoring HTTP/2 upstream also exposes unknown-length HTTP/2 responses.
When those responses are rewritten for the MITM HTTP/1.1 client, close
the client-facing connection so clients can delimit the response body.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-10 22:32:37 -07:00
Tonis Tiigi
cd33910d58 network: fix proxy default egress
Use the worker default provider for proxy UNSET egress so host fallback
is preserved when no CNI config is configured.

Extend proxy integration coverage across default, host, bridge, and
default-no-cni worker network modes.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-10 08:33:16 -07:00
CrazyMax
ef191af965 vendor: github.com/urfave/cli/v3 v3.9.0
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-06-10 10:12:36 +02:00
Tonis Tiigi
91cc422d5f network: split exec proxy from net mode
Keep exec network modes limited to sandbox, host, and none, and pass proxy
network configuration separately through solve and executor runtime state.

Proxy execs now use bridge-style egress by default, host egress only for host
network mode with entitlement, and no proxy for none mode. Add integration
coverage for bridge, host, and none proxy behavior across OCI and containerd
workers.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-09 09:11:33 -07:00
CrazyMax
a23d9dbc0c Merge pull request #6842 from tonistiigi/progress-test-fix
test: stabilize nested progress assertions
2026-06-09 14:36:22 +02:00
Tonis Tiigi
3584437722 testutil: match exact platform for mirrored images
resolveDefaultPlatform used platforms.Default(), which also matches
sub-platforms (e.g. 386 for amd64, arm for arm64). When an index lists a
compatible variant before the host platform, the wrong single-arch
manifest could be copied to the local mirror.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-08 21:15:40 -07:00
Tonis Tiigi
1579c97dac test: stabilize nested progress assertions
Progress reads collapse unread updates by ID, so the raw item count can vary
with scheduling. Assert the final status for each nested writer instead.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-08 17:01:10 -07:00
Tõnis Tiigi
c6626669bc Merge pull request #6740 from tonistiigi/exec-net-proxy
solver: add proxy network mode
2026-06-08 10:09:34 -07:00
Tõnis Tiigi
74c7cb701f Merge pull request #6834 from thaJeztah/update_protos
remove deprecated github.com/golang/protobuf dependency
2026-06-05 16:05:11 -07:00
Sebastiaan van Stijn
94dcaca630 update protoc to v3.14.0
Updating to the lowest release that includes [protobuf@dfab275], which
removed use of the github.com/golang/protobuf/ptypes/timestamp.Timestamp
type alias (deprecated).

[protobuf@dfab275]: dfab275eca

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-06-05 18:01:59 +02:00
Sebastiaan van Stijn
b79c112e22 util/grpcerrors: remove import of deprecated github.com/golang/protobuf
The github.com/golang/protobuf/ptypes/any.Any type is an alias for
google.golang.org/protobuf/types/known/anypb.Any, so we can remove those
direct imports of the deprecated github.com/golang/protobuf module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-06-05 18:01:26 +02:00
CrazyMax
bd53b4191f bound telemetry shutdown when trace forwarding stalls
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-06-05 16:48:22 +02:00
Jonathan A. Sternberg
d4ac72d232 control: forward traces in a non-blocking goroutine
Traces are now forwarded in a non-blocking goroutine when sent through
the traces exporter. This prevents traces forwarded from the client from
being stalled while waiting for an upstream uploader to appear.

In addition, adds a shutdown context to `appcontext` that will only
cancel when an interrupt has been received twice. One interrupt will
signal the program should clean up and shut down, the second indicates
we should skip shutdown procedures (more forceful), and the third will
indicate that we should immediately terminate the program.

This gives a bit more of a degree of control to shutdown procedures like
the traces and metrics exporter so there's a difference between forcibly
calling exit and just waiting a long time for the shutdown to happen.

Includes a more aggressive shutdown timeout for `buildctl` that is
similar to the export timeout on `docker-buildx` for the tracing
shutdown as another preventative measure to ensure the CLI hangs up at
an appropriate time interval.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2026-06-05 15:55:22 +02:00
Tonis Tiigi
8cd053320c proxyprovider: bound proxy cert cache
Refresh generated proxy leaf certificates before they expire and cap cached
hosts to avoid daemon-lifetime growth. Clean stale proxy network namespaces
on provider startup to mirror CNI cleanup after daemon crashes.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 13:33:36 -07:00
Tonis Tiigi
6f08a4ab4a test: cover proxy network source conversion
Add integration coverage for exec proxy source policy conversion. The test
requests /foo, rewrites it to /bar, and verifies exported content and
provenance materials use the converted source.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:03 -07:00
Tonis Tiigi
217b4f7ebc proxyprovider: fix redirects capturing
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:03 -07:00
Tonis Tiigi
f30c4c57c1 proxyprovider: better url formatting
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:03 -07:00
Tonis Tiigi
5e84b4f773 proxyprovider: avoid untracted requests because transfer encoding
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:03 -07:00
Tonis Tiigi
564e42d9b4 proxyprovider: log response status code
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:02 -07:00
Tonis Tiigi
afc8765864 proxyprovider: fix early context cancel
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:02 -07:00
Tonis Tiigi
d6973c12f6 solver: log proxy network requests
Record each proxied exec request and print a redacted method and URL list in
the exec progress logs after the process completes.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:02 -07:00
Tonis Tiigi
4f41b04f78 solver: reuse source policy for proxy network
Route proxy network policy checks through the existing source policy evaluator so
session metadata, deny messages, and URL converts use the same path as LLB
sources. Keep proxy-specific request rewriting in the proxy provider.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:02 -07:00
Tonis Tiigi
2bdf6abf99 network: capture proxy exec materials
Record successful GET responses through the exec proxy as provenance
materials and report incomplete material coverage as a typed solve error.
Thread proxy policy and capture state through typed executor/network options.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:02 -07:00
Tonis Tiigi
3254832159 solver: add proxy network mode
Add a build request option that rewrites default exec networking to an
internal proxy network while preserving explicit none networking.

Route HTTP and HTTPS traffic through a BuildKit-owned proxy namespace, enforce
source policy checks for proxied requests, and inject a temporary CA into Linux
rootfs trust bundles for HTTPS interception.

Share namespace pooling between CNI and proxy providers, and cover proxy mode
with unit and integration tests.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:00 -07:00
Tõnis Tiigi
2ff20da8b4 Merge pull request #6824 from tonistiigi/oci-mediatypes
exporter/containerimage: default to oci-mediatypes=true
2026-06-04 08:45:50 -07:00
Tonis Tiigi
aa246dce50 test: log integration helper timing
Add process runtime and socket wait diagnostics to integration test helpers
so future daemon startup flakes include useful timing data.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-03 12:04:14 -07:00
Tonis Tiigi
c4ce866e0f exporter: fix OCI media type test coverage
Allow annotation and attestation exports with OCI media types enabled, fix
the zstd media type map, and update integration tests for the new default.
Keep Docker media types explicit where legacy behavior is under test.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-03 08:52:31 -07:00
Tõnis Tiigi
174f4f07dd Merge pull request #6760 from crazy-max/session-empty-fallback
resolver: allow anonymous auth while preserving local image fallback
2026-06-03 08:40:56 -07:00
Bjorn Neergaard
c9f1690554 all: use well-known zstd mediaType constants
When support for zstd was introduced, these mediaTypes were not yet
available in released versions of their respective Go packages. That is
no longer the case.

Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2026-06-02 23:11:12 -07:00
Tonis Tiigi
28315c3500 test: avoid shared containerd worker env
Clone the containerd worker environment before sandbox setup so
parallel integration tests do not race while appending debug env.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-01 14:15:14 -07:00
CrazyMax
ca9bcf049c containerimage: preserve local fallback for default image resolution
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-05-29 17:17:04 +02:00