Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit d49c198

Browse files
committed
Revert "add option additonal-whitelist"
This reverts commit 72bfed1.
1 parent c8b1989 commit d49c198

3 files changed

Lines changed: 11 additions & 44 deletions

File tree

cmd/executor/cmd/root.go

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ import (
3838
)
3939

4040
var (
41-
opts = &config.KanikoOptions{}
42-
logLevel string
43-
force bool
44-
additionalWhitelist []string
41+
opts = &config.KanikoOptions{}
42+
logLevel string
43+
force bool
4544
)
4645

4746
func init() {
@@ -74,16 +73,6 @@ var RootCmd = &cobra.Command{
7473
if len(opts.Destinations) == 0 && opts.ImageNameDigestFile != "" {
7574
return errors.New("You must provide --destination if setting ImageNameDigestFile")
7675
}
77-
78-
if additionalWhitelist == nil {
79-
additionalWhitelist = []string{
80-
"/var/run",
81-
}
82-
}
83-
84-
for _, path := range additionalWhitelist {
85-
util.AddToWhitelist(path)
86-
}
8776
}
8877
return nil
8978
},
@@ -155,10 +144,6 @@ func addKanikoOptionsFlags() {
155144
RootCmd.PersistentFlags().DurationVarP(&opts.CacheTTL, "cache-ttl", "", time.Hour*336, "Cache timeout in hours. Defaults to two weeks.")
156145
RootCmd.PersistentFlags().VarP(&opts.InsecureRegistries, "insecure-registry", "", "Insecure registry using plain HTTP to push and pull. Set it repeatedly for multiple registries.")
157146
RootCmd.PersistentFlags().VarP(&opts.SkipTLSVerifyRegistries, "skip-tls-verify-registry", "", "Insecure registry ignoring TLS verify to push and pull. Set it repeatedly for multiple registries.")
158-
159-
// We use nil as the default value so we can differentiate between the flag passed
160-
// with an empty list and the flag not set
161-
RootCmd.PersistentFlags().StringSliceVar(&additionalWhitelist, "additional-whitelist", nil, "Paths to whitelist. These will be ignored be kaniko to improve performance.")
162147
}
163148

164149
// addHiddenFlags marks certain flags as hidden from the executor help text

pkg/util/fs_util.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ var initialWhitelist = []WhitelistEntry{
5050
Path: "/kaniko",
5151
PrefixMatchOnly: false,
5252
},
53+
{
54+
// /var/run is a special case. It's common to mount in /var/run/docker.sock or something similar
55+
// which leads to a special mount on the /var/run/docker.sock file itself, but the directory to exist
56+
// in the image with no way to tell if it came from the base image or not.
57+
Path: "/var/run",
58+
PrefixMatchOnly: false,
59+
},
5360
{
5461
// similarly, we whitelist /etc/mtab, since there is no way to know if the file was mounted or came
5562
// from the base image
@@ -64,10 +71,6 @@ var volumes = []string{}
6471

6572
var excluded []string
6673

67-
func AddToWhitelist(path string) {
68-
initialWhitelist = append(initialWhitelist, WhitelistEntry{Path: path})
69-
}
70-
7174
type ExtractFunction func(string, *tar.Header, io.Reader) error
7275

7376
type FSConfig struct {

pkg/util/fs_util_test.go

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func Test_DetectFilesystemWhitelist(t *testing.T) {
6464
{"/dev", false},
6565
{"/dev/pts", false},
6666
{"/sys", false},
67+
{"/var/run", false},
6768
{"/etc/mtab", false},
6869
}
6970
actualWhitelist := whitelist
@@ -74,28 +75,6 @@ func Test_DetectFilesystemWhitelist(t *testing.T) {
7475
return expectedWhitelist[i].Path < expectedWhitelist[j].Path
7576
})
7677
testutil.CheckErrorAndDeepEqual(t, false, err, expectedWhitelist, actualWhitelist)
77-
78-
tmpInitial := make([]WhitelistEntry, len(initialWhitelist))
79-
80-
copy(tmpInitial, initialWhitelist)
81-
defer func() {
82-
initialWhitelist = tmpInitial
83-
}()
84-
85-
AddToWhitelist("/var/run")
86-
87-
err = DetectFilesystemWhitelist(path)
88-
expectedWhitelist = append(expectedWhitelist,
89-
WhitelistEntry{"/var/run", false})
90-
91-
actualWhitelist = whitelist
92-
sort.Slice(actualWhitelist, func(i, j int) bool {
93-
return actualWhitelist[i].Path < actualWhitelist[j].Path
94-
})
95-
sort.Slice(expectedWhitelist, func(i, j int) bool {
96-
return expectedWhitelist[i].Path < expectedWhitelist[j].Path
97-
})
98-
testutil.CheckErrorAndDeepEqual(t, false, err, expectedWhitelist, actualWhitelist)
9978
}
10079

10180
var tests = []struct {

0 commit comments

Comments
 (0)