-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
buildkitd: Frontend restriction support
This commit adds buildkitd configuration options `allowed-frontends` and `allowed-gateway-source`. These options enable restricting the allowed frontends or gateways sources to enforce local policy. If allowed-frontends is empty (the default), all frontends (e.g, "dockerfile.v0" and "gateway.v0") are allowed. Otherwise, only those listed are allowed If allowed-gateway-sources is empty (the default), all gateway sources are allowed. Otherwise, only sources that match the patterns in this list will be allowed. Patterns are matched using <https://pkg.go.dev/github.com/bmatcuk/doublestar/v4#Match>. Note that implicit references to docker.io should not be used in the patterns since matching occurs on a fully expanded image name (for example "docker/dockerfile" expands to "docker.io/docker/dockerfile"). Change-Id: Ia484401709ef6c13cf3e5a2e4d0e1c6bd0c47d13
- Loading branch information
Ahmon Dancy
committed
May 3, 2024
1 parent
51d85d7
commit 1f243d0
Showing
20 changed files
with
2,302 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package gateway | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCheckSourceIsAllowed(t *testing.T) { | ||
var gw = gatewayFrontend{ | ||
workers: nil, | ||
allowedSources: []string{}, // no restrictions | ||
} | ||
|
||
err := gw.checkSourceIsAllowed("anything") | ||
assert.NoError(t, err) | ||
|
||
gw.allowedSources = []string{"docker-registry.wikimedia.org/repos/releng/blubber/buildkit"} | ||
err = gw.checkSourceIsAllowed("docker-registry.wikimedia.org/repos/releng/blubber/buildkit") | ||
assert.NoError(t, err) | ||
err = gw.checkSourceIsAllowed("docker-registry.wikimedia.org/repos/releng/blubber/buildkit:v1.2.3") | ||
assert.NoError(t, err) | ||
err = gw.checkSourceIsAllowed("docker-registry.wikimedia.org/something-else") | ||
assert.Error(t, err) | ||
|
||
gw.allowedSources = []string{"implicit-docker-io-reference", "docker/dockerfile"} | ||
// This source will be rejected because after parsing it becomes | ||
// "docker.io/library/implicit-docker-io-reference" which does not match | ||
// the allowed source of "implicit-docker-io-reference". | ||
err = gw.checkSourceIsAllowed("implicit-docker-io-reference") | ||
assert.Error(t, err) | ||
// "docker/dockerfile" expands to "docker.io/docker/dockerfile", so no match here. | ||
err = gw.checkSourceIsAllowed("docker/dockerfile") | ||
assert.Error(t, err) | ||
|
||
gw.allowedSources = []string{"docker-registry.wikimedia.org/*"} | ||
err = gw.checkSourceIsAllowed("docker-registry.wikimedia.org/something-else") | ||
assert.NoError(t, err) | ||
err = gw.checkSourceIsAllowed("docker-registry.wikimedia.org/topdir/below") | ||
assert.Error(t, err) | ||
|
||
gw.allowedSources = []string{"docker-registry.wikimedia.org/**"} | ||
err = gw.checkSourceIsAllowed("docker-registry.wikimedia.org/topdir/below") | ||
assert.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.