@@ -47,7 +47,7 @@ func unpackTar(tr *tar.Reader, path string, whitelist []string) error {
47
47
48
48
// Remove the whited-out path.
49
49
newName := strings .Replace (rmPath , ".wh." , "" , 1 )
50
- if err = walkAndRemove (newName ); err != nil {
50
+ if err = os . RemoveAll (newName ); err != nil {
51
51
logrus .Error (err )
52
52
}
53
53
continue
@@ -111,7 +111,7 @@ func unpackTar(tr *tar.Reader, path string, whitelist []string) error {
111
111
// Explicitly delete an existing file before continuing.
112
112
if _ , err := os .Stat (target ); ! os .IsNotExist (err ) {
113
113
logrus .Debugf ("Removing %s to create symlink." , target )
114
- if err := walkAndRemove (target ); err != nil {
114
+ if err := os . RemoveAll (target ); err != nil {
115
115
logrus .Debugf ("Unable to remove %s: %s" , target , err )
116
116
}
117
117
}
@@ -124,19 +124,10 @@ func unpackTar(tr *tar.Reader, path string, whitelist []string) error {
124
124
return nil
125
125
}
126
126
127
- func walkAndRemove (p string ) error {
128
- return filepath .Walk (p , func (path string , info os.FileInfo , err error ) error {
129
- if e := os .Chmod (path , 0777 ); e != nil {
130
- logrus .Errorf ("Error updating file permissions on %s before removing for symlink creation" , path )
131
- return e
132
- }
133
- return os .RemoveAll (path )
134
- })
135
- }
136
-
137
127
func checkWhitelist (target string , whitelist []string ) bool {
138
128
for _ , w := range whitelist {
139
129
if HasFilepathPrefix (target , w ) {
130
+ logrus .Debugf ("Not extracting %s, as it has prefix %s which is whitelisted" , target , w )
140
131
return true
141
132
}
142
133
}
0 commit comments