Skip to content

Commit

Permalink
bake: add wildcard to fs entitlements to allow any volumes on windows
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Nov 22, 2024
1 parent 17eff25 commit 36de6d0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
25 changes: 25 additions & 0 deletions bake/entitlements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,31 @@ func TestValidateEntitlements(t *testing.T) {
conf: EntitlementConf{
FSRead: []string{"/"},
},
expected: EntitlementConf{
FSRead: func() []string {
// on windows root (/) is only allowed if it is the same volume as wd
if filepath.VolumeName(wd) == filepath.VolumeName(escapeLink) {
return nil
}
// if not, then escapeLink is not allowed
p, err := evaluateToExistingPath(escapeLink)
require.NoError(t, err)
return []string{p}
}(),
},
},
{
name: "SecretFromEscapeLinkAllowWildcard",
opt: build.Options{
SecretSpecs: []*pb.Secret{
{
FilePath: escapeLink,
},
},
},
conf: EntitlementConf{
FSRead: []string{"*"},
},
expected: EntitlementConf{},
},
}
Expand Down
3 changes: 3 additions & 0 deletions bake/entitlements_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import (
func evaluatePaths(in []string) ([]string, error) {
out := make([]string, 0, len(in))
for _, p := range in {
if p == "*" {
p = "/"
}
v, err := filepath.Abs(p)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion bake/entitlements_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func evaluatePaths(in []string) ([]string, error) {
out := make([]string, 0, len(in))
for _, p := range in {
if p == "/" {
if p == "*" {
out = append(out, getAllVolumes()...)
continue
}
Expand Down

0 comments on commit 36de6d0

Please sign in to comment.