Skip to content

Commit b113b38

Browse files
author
Zhou Hao
committed
runtimetest: add apparmorProfile validation
Signed-off-by: Zhou Hao <[email protected]>
1 parent d4ec5b8 commit b113b38

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cmd/runtimetest/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,18 @@ func (c *complianceTester) validatePosixMounts(spec *rspec.Spec) error {
11971197
return mountErrs
11981198
}
11991199

1200+
func (c *complianceTester) validateApparmorProfile(spec *rspec.Spec) error {
1201+
if spec.Process == nil || spec.Process.ApparmorProfile == "" {
1202+
c.harness.Skip(1, "process.ApparmorProfile not set")
1203+
return nil
1204+
}
1205+
profilePath := filepath.Join(spec.Root.Path, "/etc/apparmor.d", spec.Process.ApparmorProfile)
1206+
_, err := os.Stat(profilePath)
1207+
c.harness.Ok(err != nil, "has expected apparmorProfile")
1208+
1209+
return nil
1210+
}
1211+
12001212
func (c *complianceTester) validateMountLabel(spec *rspec.Spec) error {
12011213
if spec.Linux == nil || spec.Linux.MountLabel == "" {
12021214
c.harness.Skip(1, "linux.mountlabel not set")
@@ -1279,6 +1291,7 @@ func run(context *cli.Context) error {
12791291
c.validateUIDMappings,
12801292
c.validateGIDMappings,
12811293
c.validateMountLabel,
1294+
c.validateApparmorProfile,
12821295
}
12831296

12841297
validations := defaultValidations

0 commit comments

Comments
 (0)