Skip to content

Commit 1922c58

Browse files
committed
UPSTREAM: <drop>: util/image: unset PAXRecords and Xattrs when applying files
Signed-off-by: Joe Lanford <[email protected]>
1 parent 7aefe70 commit 1922c58

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

internal/rukpak/source/containers_image.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,8 @@ func applyLayerFilter() archive.Filter {
295295
h.Uid = os.Getuid()
296296
h.Gid = os.Getgid()
297297
h.Mode |= 0700
298+
h.PAXRecords = nil
299+
h.Xattrs = nil //nolint:staticcheck
298300
return true, nil
299301
}
300302
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package source
2+
3+
import (
4+
"archive/tar"
5+
"os"
6+
"testing"
7+
8+
"github.com/stretchr/testify/assert"
9+
"github.com/stretchr/testify/require"
10+
"k8s.io/apimachinery/pkg/util/rand"
11+
)
12+
13+
func TestApplyLayerFilter(t *testing.T) {
14+
h := tar.Header{
15+
Name: "foo/bar",
16+
Mode: 0000,
17+
Uid: rand.Int(),
18+
Gid: rand.Int(),
19+
Xattrs: map[string]string{ //nolint:staticcheck
20+
"foo": "bar",
21+
},
22+
PAXRecords: map[string]string{
23+
"fizz": "buzz",
24+
},
25+
}
26+
ok, err := applyLayerFilter()(&h)
27+
require.NoError(t, err)
28+
assert.True(t, ok)
29+
30+
assert.Equal(t, "foo/bar", h.Name)
31+
assert.Equal(t, int64(0700), h.Mode)
32+
assert.Equal(t, os.Getuid(), h.Uid)
33+
assert.Equal(t, os.Getgid(), h.Gid)
34+
assert.Nil(t, h.PAXRecords)
35+
assert.Nil(t, h.Xattrs) //nolint:staticcheck
36+
}

0 commit comments

Comments
 (0)