mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-05 03:26:37 +00:00
genpolicy: Parse secContext runAsGroup and allowPrivilegeEscalation
Our policy should cover these fields for securityContexts at the pod or container level of granularity. Signed-off-by: Cameron Baird <cameronbaird@microsoft.com>
This commit is contained in:
parent
349ce8c339
commit
c13d7796ee
@ -296,6 +296,9 @@ struct SecurityContext {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
runAsUser: Option<i64>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
runAsGroup: Option<i64>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
seccompProfile: Option<SeccompProfile>,
|
||||
}
|
||||
@ -318,6 +321,12 @@ pub struct PodSecurityContext {
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub sysctls: Option<Vec<Sysctl>>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub runAsGroup: Option<i64>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub allowPrivilegeEscalation: Option<bool>,
|
||||
// TODO: additional fields.
|
||||
}
|
||||
|
||||
@ -962,6 +971,11 @@ impl Container {
|
||||
if let Some(uid) = context.runAsUser {
|
||||
process.User.UID = uid.try_into().unwrap();
|
||||
}
|
||||
|
||||
if let Some(gid) = context.runAsGroup {
|
||||
process.User.GID = gid.try_into().unwrap();
|
||||
}
|
||||
|
||||
if let Some(allow) = context.allowPrivilegeEscalation {
|
||||
process.NoNewPrivileges = !allow
|
||||
}
|
||||
@ -1008,6 +1022,7 @@ pub async fn add_pause_container(containers: &mut Vec<Container>, config: &Confi
|
||||
privileged: None,
|
||||
capabilities: None,
|
||||
runAsUser: None,
|
||||
runAsGroup: None,
|
||||
seccompProfile: None,
|
||||
}),
|
||||
..Default::default()
|
||||
|
@ -391,6 +391,14 @@ pub fn get_process_fields(
|
||||
if let Some(uid) = context.runAsUser {
|
||||
process.User.UID = uid.try_into().unwrap();
|
||||
}
|
||||
|
||||
if let Some(gid) = context.runAsGroup {
|
||||
process.User.GID = gid.try_into().unwrap();
|
||||
}
|
||||
|
||||
if let Some(allow) = context.allowPrivilegeEscalation {
|
||||
process.NoNewPrivileges = !allow
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user