Skip to content

Commit edf39b0

Browse files
micromaomaoanmaxvl
andcommitted
rego: Allow sending SIGTERM and SIGKILL to the container init process in old policies
We used to allow SIGTERM/SIGKILL the container init process even if the container's signals list is empty due to a bug fixed in #2538. However, because our tooling has been generating policies with an empty signals list, we need to special case this for old policies to maintain backwards compatibility. Update framework.rego to have SIGTERM and SIGKILL as default kill signals for init process for framework API versions "0.4.1" and below. Newer policies must explicitly have these signals present, otherwise sending signal will be denied. Signed-off-by: Tingmao Wang <[email protected]> Co-authored-by: Maksim An <[email protected]>
1 parent 15a6afe commit edf39b0

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pkg/securitypolicy/framework.rego

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1960,7 +1960,7 @@ check_container(raw_container, framework_version) := container {
19601960
"allow_elevated": raw_container.allow_elevated,
19611961
"working_dir": raw_container.working_dir,
19621962
"exec_processes": raw_container.exec_processes,
1963-
"signals": raw_container.signals,
1963+
"signals": check_signals(raw_container, framework_version),
19641964
"allow_stdio_access": raw_container.allow_stdio_access,
19651965
# Additional fields need to have default logic applied
19661966
"no_new_privileges": check_no_new_privileges(raw_container, framework_version),
@@ -2026,6 +2026,16 @@ check_seccomp_profile_sha256(raw_container, framework_version) := seccomp_profil
20262026
seccomp_profile_sha256 := ""
20272027
}
20282028

2029+
check_signals(raw_container, framework_version) := signals {
2030+
semver.compare(framework_version, "0.4.1") >= 0
2031+
signals := raw_container.signals
2032+
}
2033+
2034+
check_signals(raw_container, framework_version) := signals {
2035+
semver.compare(framework_version, "0.4.1") < 0
2036+
signals := array.concat(raw_container.signals, [9, 15])
2037+
}
2038+
20292039
check_external_process(raw_process, framework_version) := process {
20302040
semver.compare(framework_version, version) == 0
20312041
process := raw_process
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.0
1+
0.4.1

0 commit comments

Comments
 (0)