build: avoid empty source policy sessions - #4028
Conversation
5c390b2 to
ed838db
Compare
tonistiigi
left a comment
There was a problem hiding this comment.
Change looks good but the new test testBakeRemoteGitNoPolicyWithProxyNetwork seems to pass with or without the patch.
ed838db to
4befbc5
Compare
4befbc5 to
b62b768
Compare
Ah yes it passed without the fix because the request was plain HTTP, and the empty source policy session didn't make that path fail.
I updated the test to mirror the original repro more closely by using |
b62b768 to
879a464
Compare
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
879a464 to
bf223fb
Compare
Remote Git contexts can enqueue an optional
Dockerfile.regolookup even when the build doesn't include a policy file. When that optional file was absent, Buildx resolved zero policy files but still attached a no-opSourcePolicyProvider, which made the solve request carry aSourcePolicySession. That matters for builders created withproxyNetwork = true, because BuildKit treats the presence of a source policy session as part of proxy-network enforcement, so a Git-context could fail with a proxy403 Forbiddeneven though the same target succeeded from a local context.The issue is reproducible with:
against a docker-container builder using
moby/buildkit:v0.32.2andproxyNetwork = true.This change keeps
SourcePolicyProviderunset when policy resolution loads no policy files, so builds without policies don't accidentally opt into source-policy session behavior.