Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7b372cd
add rego integration to source policies
tonistiigi Nov 15, 2025
f80ab5a
policy: remove http perm/uid/gid
tonistiigi Dec 2, 2025
ed4d034
policy: add custom builtins list and remove v0 compat
tonistiigi Dec 2, 2025
39ed7e8
policy: print debug helper
tonistiigi Dec 3, 2025
b1b2ca4
policy: add helper modules loading
tonistiigi Dec 3, 2025
0be8ad4
policy: add custom builtin load_json
tonistiigi Dec 3, 2025
8f5fda2
policy: add git signature verification support
tonistiigi Dec 3, 2025
59cecbb
policy: image signature verification support
tonistiigi Dec 4, 2025
42787d1
policy: move custom functions to separate file
tonistiigi Dec 12, 2025
7750f32
policy: update verify_git_signature to take git object as parameter
tonistiigi Dec 12, 2025
18caf8c
policy: add pin_image helper
tonistiigi Dec 18, 2025
1346493
build: add --policy flag for controlling policy configuration
tonistiigi Jan 7, 2026
a5f592c
policy: add multiple policy support
tonistiigi Jan 7, 2026
1536df4
policy: add strict policy config support
tonistiigi Jan 7, 2026
7373825
commands: add stubs for policy commands
tonistiigi Jan 8, 2026
696264d
commands: implement policy eval command
tonistiigi Jan 8, 2026
a6849b0
policy: implement policy logging via progress printer
tonistiigi Jan 9, 2026
7a1112f
tests: add policy flag integration test
tonistiigi Jan 12, 2026
4a7900e
tests: add image and env based policy build tests
tonistiigi Jan 12, 2026
1545f9b
tests: add policy eval integration tests
tonistiigi Jan 12, 2026
b2eecf4
tests: update policy tests matrix to require modern buildkit
tonistiigi Jan 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG ALPINE_VERSION=3.22
ARG XX_VERSION=1.7.0

# for testing
ARG DOCKER_VERSION=29.0.0
ARG DOCKER_VERSION=29.1
ARG DOCKER_VERSION_ALT_28=28.5
ARG DOCKER_VERSION_ALT_27=27.5.1
ARG DOCKER_CLI_VERSION=${DOCKER_VERSION}
Expand Down
92 changes: 91 additions & 1 deletion build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/json"
"fmt"
"io"
"io/fs"
"maps"
"os"
"slices"
Expand All @@ -21,6 +22,7 @@ import (
noderesolver "github.com/docker/buildx/build/resolver"
"github.com/docker/buildx/builder"
"github.com/docker/buildx/driver"
"github.com/docker/buildx/policy"
"github.com/docker/buildx/util/buildflags"
"github.com/docker/buildx/util/confutil"
"github.com/docker/buildx/util/desktop"
Expand Down Expand Up @@ -95,6 +97,15 @@ type Options struct {
SourcePolicy *spb.Policy
GroupRef string
Annotations map[exptypes.AnnotationKey]string // Not used during build, annotations are already set in Exports. Just used to check for support with drivers.
Policy []PolicyConfig
}

type PolicyConfig struct {
Files []policy.File
Reset bool
Disabled bool
Strict *bool
LogLevel *logrus.Level
}

type CallFunc struct {
Expand All @@ -113,6 +124,85 @@ type Inputs struct {
// DockerfileMappingSrc and DockerfileMappingDst are filled in by the builder.
DockerfileMappingSrc string
DockerfileMappingDst string

policy *policyOpt
}

type policyOpt struct {
Files []policy.File
FS func() (fs.StatFS, func() error, error)
Strict bool
LogLevel *logrus.Level
}

func withPolicyConfig(defaultPolicy policyOpt, configs []PolicyConfig) ([]policyOpt, error) {
if len(configs) == 0 {
if len(defaultPolicy.Files) == 0 {
return nil, nil
}
return []policyOpt{defaultPolicy}, nil
}

for _, cfg := range configs {
if !cfg.Disabled {
continue
}
if cfg.Reset || cfg.Strict != nil || cfg.LogLevel != nil || len(cfg.Files) > 0 {
return nil, errors.New("disabled policy cannot be combined with other policy flags")
}
if len(configs) > 1 {
return nil, errors.New("disabled policy cannot be combined with other policy flags")
}
return nil, nil
}

out := make([]policyOpt, 0, len(configs)+1)
if len(defaultPolicy.Files) != 0 {
out = append(out, defaultPolicy)
}

var last PolicyConfig

for _, cfg := range configs {
if cfg.Reset {
out = nil
}

if len(cfg.Files) == 0 {
if len(out) == 0 {
last = cfg
} else {
last := &out[len(out)-1]
if cfg.Strict != nil {
last.Strict = *cfg.Strict
}
if cfg.LogLevel != nil {
last.LogLevel = cfg.LogLevel
}
}
continue
}

opt := policyOpt{
Files: cfg.Files,
}
if last.Strict != nil {
opt.Strict = *last.Strict
}
if last.LogLevel != nil {
opt.LogLevel = last.LogLevel
}
if cfg.Strict != nil {
opt.Strict = *cfg.Strict
}
if cfg.LogLevel != nil {
opt.LogLevel = cfg.LogLevel
}
opt.FS = defaultPolicy.FS
out = append(out, opt)
}

return out, nil
}

type NamedContext struct {
Expand Down Expand Up @@ -926,7 +1016,7 @@ func detectSharedMounts(ctx context.Context, reqs map[string][]*reqForNode) (_ m
}
fsMap := m[nodeName]
for name, m := range req.so.LocalMounts {
fs, ok := m.(*fs)
fs, ok := m.(*fsMount)
if !ok {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion build/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func getGitAttributes(ctx context.Context, contextPath, dockerfilePath string) (
}

for key, mount := range so.LocalMounts {
fs, ok := mount.(*fs)
fs, ok := mount.(*fsMount)
if !ok {
continue
}
Expand Down
Loading
Loading