Skip to content
Merged
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
93341aa
add rego integration to source policies
tonistiigi Nov 15, 2025
adb9386
policy: remove http perm/uid/gid
tonistiigi Dec 2, 2025
547f1ab
policy: add custom builtins list and remove v0 compat
tonistiigi Dec 2, 2025
7247c1e
policy: print debug helper
tonistiigi Dec 3, 2025
70da643
policy: add helper modules loading
tonistiigi Dec 3, 2025
1b7a5f2
policy: add custom builtin load_json
tonistiigi Dec 3, 2025
b2697ae
policy: add git signature verification support
tonistiigi Dec 3, 2025
87d4189
policy: image signature verification support
tonistiigi Dec 4, 2025
8906b25
policy: move custom functions to separate file
tonistiigi Dec 12, 2025
df5d9eb
policy: update verify_git_signature to take git object as parameter
tonistiigi Dec 12, 2025
d0e9e8c
policy: add pin_image helper
tonistiigi Dec 18, 2025
4af8cdb
build: add --policy flag for controlling policy configuration
tonistiigi Jan 7, 2026
0e1036b
policy: add multiple policy support
tonistiigi Jan 7, 2026
61843e0
policy: add strict policy config support
tonistiigi Jan 7, 2026
d232d4c
commands: add stubs for policy commands
tonistiigi Jan 8, 2026
5ad09ce
commands: implement policy eval command
tonistiigi Jan 8, 2026
be42b48
policy: implement policy logging via progress printer
tonistiigi Jan 9, 2026
ae86c58
tests: add policy flag integration test
tonistiigi Jan 12, 2026
02719d0
tests: add image and env based policy build tests
tonistiigi Jan 12, 2026
30b6352
tests: add policy eval integration tests
tonistiigi Jan 12, 2026
e5116c1
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.23
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