File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ const (
2121
2222var (
2323 relevantAttributes = []string {"security.capability" , imaXattr , "user.*" } // the attributes that we preserve - we discard others
24+ irrelevantAttributes = []string {"user.overlay.*" } // the attributes that we discard, even from the relevantAttributes list
2425 initialXattrListSize = 64 * 1024
2526 initialXattrValueSize = 64 * 1024
2627)
@@ -33,6 +34,13 @@ func isRelevantXattr(attribute string) bool {
3334 if err != nil || ! matched {
3435 continue
3536 }
37+ for _ , irrelevant := range irrelevantAttributes {
38+ matched , err := filepath .Match (irrelevant , attribute )
39+ if err != nil || ! matched {
40+ continue
41+ }
42+ return false
43+ }
3644 return true
3745 }
3846 return false
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
1010 "testing"
1111
1212 "github.com/stretchr/testify/assert"
13+ "github.com/stretchr/testify/require"
1314)
1415
1516func init () {
@@ -18,6 +19,30 @@ func init() {
1819 initialXattrValueSize = 1
1920}
2021
22+ func TestXattrIsRelevant (t * testing.T ) {
23+ cases := []struct {
24+ xattrName string
25+ relevant bool
26+ }{
27+ {"user.a" , true },
28+ {"user.b" , true },
29+ {"security.foo" , false },
30+ {imaXattr , true },
31+ {"security.capability" , true },
32+ {"user.overlay.base" , false },
33+ }
34+ for _ , c := range cases {
35+ t .Run (c .xattrName , func (t * testing.T ) {
36+ relevant := isRelevantXattr (c .xattrName )
37+ if c .relevant {
38+ require .True (t , relevant , "should be considered relevant and kept" )
39+ } else {
40+ require .False (t , relevant , "should be considered irrelevant and discarded" )
41+ }
42+ })
43+ }
44+ }
45+
2146func TestXattrs (t * testing.T ) {
2247 t .Parallel ()
2348 if ! xattrsSupported {
You can’t perform that action at this time.
0 commit comments