-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for custom CIL rules #145
base: main
Are you sure you want to change the base?
Add support for custom CIL rules #145
Conversation
Could you provide some real world example? Do I read read it correctly that you need similar option to
|
Exactly. Reflecting directly on issue #130, we can consider a real-world scenario where someone might need an allow rule that isn't added by default by Udica. For instance, the In such cases, when Udica doesn't add a specific rule for their configuration by default, users could use their own CIL templates. This would help automate the process, eliminating the need to manually edit the generated Udica CIL file each time. This is the typical scenario I had in mind. # User realizes that permissions to connect to UNIX sockets are missing
# Create a custom template file for this
$ echo " (allow process container_runtime_t ( unix_stream_socket ( connectto )))" > custom_template.cil
# Take 'tests/test_basic.podman.json' and add custom template
$ sudo udica -j test_basic.podman.json --custom-template custom_template.cil test-container
# Verify that the custom policy is added
$ cat test-container.cil | grep "(allow process container_runtime_t ( unix_stream_socket ( connectto )))"
Very good to know. I'll do my best to fix this. Thank you for your attention! |
Agreed, not sure if we need validation at all given that the policy file will just fail to install in case of invalid rule. Also we may want to rename the command line argument to something like It would be quite easy to craft AVCs that can be passed to udica via |
Validation isn't absolutely necessary, but I see it as somewhat helpful for user guidance. The validation function provides specific error messages, assisting users in quickly identifying and correcting any major mistakes in their custom CIL files. Although the validation isn't exhaustive at all for now, as it only ensures balanced parentheses, I think it could still offer some useful checks for the user. |
Hi,
This PR addresses a suggestion from issue #130 by adding custom CIL templates:
This PR includes:
-t
or--custom-template
to specify the path to a custom CIL template file.validate_cil_template
function to ensure the provided custom template is correctly formatted.create_policy
function to include the custom template at the beginning of the policy if provided and valid.This feature enables users to define their own additional SELinux rules through custom CIL templates, enhancing Udica's flexibility and extensibility. Any feedback would be greatly appreciated.
Best,
Fabien