46 Commits

Author SHA1 Message Date
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
s3onghyun
23d37f2a89 sourcepolicy: fix grammar in Evaluate doc comment
Signed-off-by: s3onghyun <s3onghyun.hong@gmail.com>
2026-06-18 17:52:02 +09:00
CrazyMax
e4d0dbaf3f chore: update generated files
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-06-12 09:44:45 +02:00
ZRHann
28ce6844cf sourcepolicy: fix exact match convert ignoring destination
A CONVERT rule whose selector uses matchType EXACT matched the source but
silently performed no conversion: the source identifier was left unchanged
and no error was returned.

The destination of a CONVERT is computed by selectorCache.Format(match,
format), where format is the rule's Updates.Identifier. For WILDCARD and
REGEX the groups captured from match are substituted into format. The EXACT
branch has no captures and should return the target format verbatim, but it
returned s.Identifier (the selector's own identifier, i.e. the matched
source) instead. mutate() then computed a destination equal to the source,
saw op.Identifier == dest, and returned mutated=false without applying the
update.

This made exact-match source pinning/substitution silently fail, e.g.
pinning an image tag to a digest for reproducible builds.

Return format from the EXACT branch. The empty-destination case is
unaffected: mutate() already falls back to the selector identifier before
calling Format, so an empty Updates.Identifier remains a correct no-op.

Add testConvertExact covering an explicit MatchType_EXACT conversion; the
existing testConvert only exercised the default wildcard path.

Signed-off-by: ZRHann <zrhann@foxmail.com>
2026-06-11 14:01:01 +08: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
Tonis Tiigi
b61489948c tests: use t.Context in unit tests
Replace context.TODO/background calls in targeted unit tests with
t.Context().

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-02-25 16:41:54 -08:00
Tõnis Tiigi
38a4ba9771 Merge pull request #6458 from tonistiigi/policy-deny-msg
policy: propagate deny messages from policy error
2026-01-14 07:32:55 -08:00
CrazyMax
18ad342e57 Merge pull request #6460 from tonistiigi/golint-v2.8.0-update
hack: golangci v2.8.0 and gopls v0.38.0 update
2026-01-14 15:44:19 +01:00
Tonis Tiigi
a8b83196f3 ci: update golangci to v2.8.0
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-01-13 22:09:20 -08:00
Tonis Tiigi
ddeb26c5e1 vendor: update outdated patch versions of dependencies
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-01-13 22:08:15 -08:00
Tonis Tiigi
51376425c5 policy: propagate deny messages from policy error
If policy responds deny messages, make sure they
carry over to the build error.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-01-13 17:14:30 -08:00
Brian Goff
f7682feb14 Fix concurrency issues with source policy
This is more stuff where we weren't accounting for concurrent access.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2026-01-06 15:41:53 -08:00
Tonis Tiigi
a3df584704 sourcepolicy: fix possible concurrent map write on sourceCache
Connecurrent writes became possible when policy evaluation
was made to run in parallel recently.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-11-07 07:50:22 -08:00
Tonis Tiigi
8e6ee36421 sourcepolicy: make sure rule constraints are not used from selectorCache
SelectorCache only stores the identifier and type. Constraints need to
be passed directly outside of cache.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-11-07 07:50:16 -08:00
Tonis Tiigi
bab17afc53 llbsolver: update policy validation to parallel
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-11-05 14:54:58 -08:00
Tonis Tiigi
badc4d9756 client: add policy test for source meta resolver
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-11-05 14:54:52 -08:00
Tonis Tiigi
f79f1a98c4 policysession: dynamic source policy support
Add support for dynamic source policies via client session.

Client session can allow or deny specific source or
ask additional metadata information via sourcemetaresolver if
that is needed to make the decision.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-11-05 14:28:13 -08:00
Tonis Tiigi
09426caaae vendor: update containerd to v2.2.0-rc.0
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-11-03 11:11:53 -08:00
Jonathan A. Sternberg
f4339fd00b tools: utilize the new tool functionality introduced in go 1.24
Removes the `tools/tools.go` file used as a hack to get `go.mod` to
track tools in favor of the new method introduced in go 1.24 of being
formally supported in the `go.mod` file. This will allow the tools to be
managed with the new `go get tool` and `go install tool` commands.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-09-10 10:08:03 -05:00
Tonis Tiigi
9a5dff09b5 vendor: update to containerd v2.1.1
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-21 09:09:33 -06:00
Tonis Tiigi
9fcedf9807 update gopls to go1.24 compatible version
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-07 18:23:20 -07:00
Tonis Tiigi
1e512a15c3 lint: add fatcontext
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-02 12:19:22 -07:00
Tonis Tiigi
f1f56c2b77 golangci-lint: v2 upgrade
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-02 12:19:17 -07:00
Sebastiaan van Stijn
d709e4bb1c vendor: google.golang.org/protobuf v1.35.2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 14:03:31 +01:00
Tonis Tiigi
c9a25c4d8a pb: regenerate protobuf
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-10-28 12:56:03 -07:00
Jonathan A. Sternberg
41a0a0c37d protobuf: add vtproto as a supplemental marshaler
vtproto is an extra protobuf compiler that generates special methods
suffixed with `VT` that create typed and unrolled marshal and unmarshal
functions similar to gogo that can be used for performance sensitive
code. These extensions are optional for code to use but buildkit uses
them.

A codec is also included to utilize vtproto for grpc code. If the
package `github.com/moby/buildkit/util/grpcutil/encoding/proto` is
imported then vtproto will be used if it exists and otherwise it will
use the standard marshaling and unmarshaling methods.

This codec has an important difference from the default codec. The
default codec will always reset messages before unmarshaling. In most
cases, this is unnecessary and is only relevant for `RecvMsg` on
streams. In most cases, if we are passing in an existing message to this
method, we want to reuse the buffers. This codec will always merge the
message when unmarshaling instead of resetting the input message.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-10-04 12:52:15 -05:00
Jonathan A. Sternberg
ffd8ff490e protobuf: normalize how protobuf files are generated
The relative paths option for protoc generators doesn't work well when
it comes to dependencies. This simplifies the code generation to avoid
using `go generate` and to use one global command for protoc generation.

This is similar to https://github.com/docker/buildx/pull/2713 since the
same problems with code generation occur here too.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-10-03 17:40:53 -05:00
Jonathan A. Sternberg
1a3fc0aa15 protobuf: remove gogoproto
Remove gogoproto in favor of the standard protobuf compiler. This
removes any nonstandard extensions that were part of gogoproto such as
the custom types.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-09-26 12:57:45 -05:00
Tonis Tiigi
03c7a6d769 lint: fix some testifylint warnings
This does not cover all warning yet but split
into chunks to ease review.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-05-30 11:32:55 -07:00
cuiyourong
5570d92a76 chore: remove repetitive word
Signed-off-by: cuiyourong <cuiyourong@gmail.com>
2024-04-23 18:13:33 +08:00
Tonis Tiigi
1f9988911f lint: unusedparams fixes
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-04-09 07:23:16 -07:00
Tonis Tiigi
30c069cb03 replace resolveimageconfig with generic sourcemetaresolver
This is more versatile function that works for any source,
not just images.

It can be used together with a policy that switches
between input and output source as well as for adding
additional metadata for other sources in the future.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-02-11 22:06:23 -08:00
Tonis Tiigi
e11862c24d sourcepolicy: add validations for nil values
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 4e2569e796aae398648082689d70ca1d4f4f74a8)
2024-01-31 12:37:22 -08:00
Brian Goff
330cf7ae7d Fix ResolveImageConfig to evaluate source policy
Before this change, ResolveImageConfig was unaware of source policies.
This means that:

1. Images for denied sources may be resolved
2. Image configs may get pulled for sources that are later converted to
   a different image

The update makes it so the image resolver first runs a given ref through
the source policy and uses any mutated ref for the actual resolve
(instead of the original ref).
It also returns the mutated ref so it can be used correctly by the
frontend (e.g. don't want to do llb.Image(oldRef@resolvedDigest)).

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2023-07-10 17:44:50 +00:00
Brian Goff
c40f30e45b sourcepolicy: fix policy so last rule wins
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-12-13 13:02:15 -08:00
Brian Goff
6d061b9a3a sourcepolicy: Change field names and collapse type
Updates the field names for source policies to be a little less
confusing: `Source` -> `Selector`, `Destination` -> `Updates`.

Also collapse `Type` into the `Identifier` which matches how the rest of
buildkit works and greatly simplifies matching.. and generally makes it
so the policy engine doesn't need to care about schemes.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-12-13 13:02:15 -08:00
Brian Goff
b6db53addf sourcepolicy: remove evalState
This makes it so a deny is always a deny regardless of if it was allowed
in a prior rule.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-12-13 13:02:14 -08:00
Brian Goff
e4ff85a935 sourcepolicy: extra test
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-12-13 13:02:14 -08:00
Brian Goff
18939126f8 Fix some typos
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-12-13 13:02:14 -08:00
Brian Goff
3e93b541fd sourcepolicy: Do not pass state between policies
Per our discussion on github, each policy should be evaluated on it's
own.
ie. an "allow" in one policy should be able to change to a "deny" in
another policy.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-12-13 13:02:14 -08:00
Brian Goff
c7a54c7453 sourcepolicy: cleanup uneccessary interfaces
These were just there while figuring out how things would work and are
not needed now.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-12-13 13:02:14 -08:00
Brian Goff
7a08c9dbdf sourcepolicy: Add support for frontend policies
Allows frontends to pass in a list of policies in the solve request.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-12-13 13:02:12 -08:00
Brian Goff
6e89b21e21 sourcepolicy: split dest type from identifier
This makes destination more symetrical with sources.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-12-13 13:01:54 -08:00
Brian Goff
51ad0c7d7f sourcepolicy: add wildcard match type
This defines a better type for wildcard matching as well as a more
appropritate package (contributed by Akihiro) for doing wildcard
matching.

Also some improvements to caching state such as compiled regexes.

Co-authored-by: Akihiro Suda <suda.kyoto@gmail.com>
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-12-13 13:01:54 -08:00
Brian Goff
7526659ab0 Update source pinning to use proposed policy
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-12-13 13:01:54 -08:00
Akihiro Suda
0d3f71ee18 llbsolver: support pinning sources
Alternative to PR 2816 ("dockerfile: support Dockerfile.pin for pinning sources")

This version is implemented on the llbsolver side and agnostic to the LLB frontends.
See `solver/llbsolver/vertex.go:loadLLB()`.

See `docs/build-repro.md` for the usage.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2022-12-13 13:01:54 -08:00