Skip to content

Commit c22cf5d

Browse files
klihubmikebrow
authored andcommitted
cri,nri: pass any linux security profile to plugins.
Signed-off-by: Krisztian Litkey <[email protected]>
1 parent d7532de commit c22cf5d

3 files changed

Lines changed: 27 additions & 9 deletions

File tree

internal/cri/nri/nri_api_linux.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,22 @@ func (c *criContainer) GetRdt() *api.LinuxRdt {
900900
}
901901
}
902902

903+
func (c *criContainer) GetSeccompProfile() *api.SecurityProfile {
904+
if c == nil || c.meta == nil || c.meta.Config == nil {
905+
return nil
906+
}
907+
908+
profile := c.meta.Config.GetLinux().GetSecurityContext().GetSeccomp()
909+
if profile == nil {
910+
return nil
911+
}
912+
913+
return &api.SecurityProfile{
914+
ProfileType: api.SecurityProfile_ProfileType(profile.GetProfileType()),
915+
LocalhostRef: profile.GetLocalhostRef(),
916+
}
917+
}
918+
903919
func (c *criContainer) GetPid() uint32 {
904920
return c.pid
905921
}

internal/nri/container.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ type LinuxContainer interface {
4949
GetScheduler() *nri.LinuxScheduler
5050
GetNetDevices() map[string]*nri.LinuxNetDevice
5151
GetRdt() *nri.LinuxRdt
52+
GetSeccompProfile() *nri.SecurityProfile
5253
}
5354

5455
func commonContainerToNRI(ctr Container) *nri.Container {

internal/nri/container_linux.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ func containerToNRI(ctr Container) *nri.Container {
2626
nriCtr := commonContainerToNRI(ctr)
2727
lnxCtr := ctr.GetLinuxContainer()
2828
nriCtr.Linux = &nri.LinuxContainer{
29-
Namespaces: lnxCtr.GetLinuxNamespaces(),
30-
Devices: lnxCtr.GetLinuxDevices(),
31-
Resources: lnxCtr.GetLinuxResources(),
32-
OomScoreAdj: nri.Int(lnxCtr.GetOOMScoreAdj()),
33-
CgroupsPath: lnxCtr.GetCgroupsPath(),
34-
IoPriority: lnxCtr.GetIOPriority(),
35-
Scheduler: lnxCtr.GetScheduler(),
36-
NetDevices: lnxCtr.GetNetDevices(),
37-
Rdt: lnxCtr.GetRdt(),
29+
Namespaces: lnxCtr.GetLinuxNamespaces(),
30+
Devices: lnxCtr.GetLinuxDevices(),
31+
Resources: lnxCtr.GetLinuxResources(),
32+
OomScoreAdj: nri.Int(lnxCtr.GetOOMScoreAdj()),
33+
CgroupsPath: lnxCtr.GetCgroupsPath(),
34+
IoPriority: lnxCtr.GetIOPriority(),
35+
Scheduler: lnxCtr.GetScheduler(),
36+
NetDevices: lnxCtr.GetNetDevices(),
37+
Rdt: lnxCtr.GetRdt(),
38+
SeccompProfile: lnxCtr.GetSeccompProfile(),
3839
}
3940
return nriCtr
4041
}

0 commit comments

Comments
 (0)