mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2024-11-15 07:54:17 +01:00
fix(build): ensure attachment nesting return value even on non valid string.
This commit is contained in:
parent
991d692a0d
commit
d2c1aa72ff
@ -100,7 +100,11 @@ func (p *AppArmorProfile) NestAttachments() string {
|
|||||||
} else {
|
} else {
|
||||||
res := []string{}
|
res := []string{}
|
||||||
for _, attachment := range p.Attachments {
|
for _, attachment := range p.Attachments {
|
||||||
|
if strings.HasPrefix(attachment, "/") {
|
||||||
res = append(res, attachment[1:])
|
res = append(res, attachment[1:])
|
||||||
|
} else {
|
||||||
|
res = append(res, attachment)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return "/{" + strings.Join(res, ",") + "}"
|
return "/{" + strings.Join(res, ",") + "}"
|
||||||
}
|
}
|
||||||
|
@ -185,6 +185,21 @@ func TestAppArmorProfile_NestAttachments(t *testing.T) {
|
|||||||
},
|
},
|
||||||
want: "/{{usr/,}libexec/geoclue,{usr/,}libexec/geoclue-2.0/demos/agent}",
|
want: "/{{usr/,}libexec/geoclue,{usr/,}libexec/geoclue-2.0/demos/agent}",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "null",
|
||||||
|
Attachments: []string{},
|
||||||
|
want: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "empty",
|
||||||
|
Attachments: []string{""},
|
||||||
|
want: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "not valid aare",
|
||||||
|
Attachments: []string{"/file", "relative"},
|
||||||
|
want: "/{file,relative}",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user