forked from k8stopologyawareschedwg/deployer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rte: selinux: support for OCP up to 4.15
4.14 is identical to 4.13, but changes are needed for 4.15 Signed-off-by: Francesco Romani <[email protected]>
- Loading branch information
Showing
4 changed files
with
124 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* Copyright 2024 Red Hat, Inc. | ||
*/ | ||
|
||
package selinux | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/k8stopologyawareschedwg/deployer/pkg/deployer/platform" | ||
) | ||
|
||
func TestGetPolicy(t *testing.T) { | ||
type testCase struct { | ||
name string | ||
ver platform.Version | ||
expectedError bool | ||
} | ||
|
||
testCases := []testCase{ | ||
{ | ||
name: "supported", | ||
ver: platform.Version("v4.12"), | ||
expectedError: false, | ||
}, | ||
{ | ||
name: "more recent", | ||
ver: platform.Version("v4.99"), | ||
expectedError: false, | ||
}, | ||
{ | ||
name: "too old", | ||
ver: platform.Version("v3.11"), | ||
expectedError: false, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
_, err := GetPolicy(tc.ver) | ||
gotErr := (err != nil) | ||
if gotErr != tc.expectedError { | ||
t.Fatalf("GetPolicy(%v) unexpected result: expected error %v got %v", tc.ver, tc.expectedError, gotErr) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
(block rte | ||
(type process) | ||
(roletype system_r process) | ||
(typeattributeset domain (process)) | ||
; | ||
; Giving rte.process the same attributes as container_t | ||
(typeattributeset container_domain (process)) | ||
(typeattributeset container_net_domain (process)) | ||
(typeattributeset svirt_sandbox_domain (process)) | ||
(typeattributeset sandbox_net_domain (process)) | ||
; MCS is leveraged by container_t and others, like us, to prevent cross-pod communication. | ||
(typeattributeset mcs_constrained_type (process)) | ||
; | ||
; Allow access to procfs (also needed by libraries) | ||
(allow process proc_type (file (open read))) | ||
; | ||
; Allow to RTE pod access to /run/rte directory | ||
(allow process container_var_run_t (dir (add_name write))) | ||
(allow process container_var_run_t (file (create read write open))) | ||
; | ||
; Allow to RTE pod connect, read and write permissions to /var/lib/kubelet/pod-resource/kubelet.sock | ||
(allow process container_var_lib_t (sock_file (open getattr read write ioctl lock append))) | ||
(allow process container_var_lib_t (unix_stream_socket (connectto))) | ||
(allow process unconfined_service_t (unix_stream_socket (connectto))) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
(block rte | ||
(type process) | ||
(roletype system_r process) | ||
(typeattributeset domain (process)) | ||
; | ||
; Giving rte.process the same attributes as container_t | ||
(typeattributeset container_domain (process)) | ||
(typeattributeset container_net_domain (process)) | ||
(typeattributeset svirt_sandbox_domain (process)) | ||
(typeattributeset sandbox_net_domain (process)) | ||
; MCS is leveraged by container_t and others, like us, to prevent cross-pod communication. | ||
(typeattributeset mcs_constrained_type (process)) | ||
; | ||
; Allow access to procfs (also needed by libraries) | ||
(allow process proc_type (file (open read))) | ||
; | ||
; Allow to RTE pod access to /run/rte directory | ||
(allow process container_var_run_t (dir (add_name write))) | ||
(allow process container_var_run_t (file (create read write open))) | ||
; | ||
; Allow to RTE pod connect, read and write permissions to /var/lib/kubelet/pod-resource/kubelet.sock | ||
(allow process container_var_lib_t (sock_file (open getattr read write ioctl lock append))) | ||
(allow process container_var_lib_t (unix_stream_socket (connectto))) | ||
(allow process kubelet_t (unix_stream_socket (connectto))) | ||
) |