-
Notifications
You must be signed in to change notification settings - Fork 718
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Check sssd conf.d files and fix bash remediation for sssd_enable_pam_services #6014
Check sssd conf.d files and fix bash remediation for sssd_enable_pam_services #6014
Conversation
Skipping CI for Draft Pull Request. |
A single regex which describes all possible locations together with check_existence="at_least_one_exists". Can that work? |
That might improve the situation, but I'm not sure if it would entirely solve it. If I understood correctly, if there is no I think we should split the check in two then and make one to check if there is any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Since `/etc/sssd/conf.d/` can be empty, we need a way to skip the check in this case. Using `existence=any_exist` does not help because if a given file exists and it doesn't comply with the requirement it will evaluate as `True`.
I think the problem is that the test is already looking for the object with the desired state. If the test has an explicit state it can work.
For example, if the object is the services line, and we capture the services list:
<ind:pattern operation="pattern match">^[\s]*\[sssd]([^\n\[\]]*\n+)+?[\s]*services[\s]*=[\s]*(.*)$</ind:pattern>
And then state makes sure that pam
is one of the captured services:
<ind:subexpression operation="pattern_match">.*pam.*</ind:subexpression>
</ind:textfilecontent54_state>
Edit: added explanation below.
This would work with check_existence="any_exist"
, any number of services =
line can be found.
And with check="all"
, all objects need to conform to the state, i.e. any services =
line found need to contain pam
.
Thanks for the thoroughly explanation, I'll run some tests based on feedback and then I'll submit new changes. |
004b320
to
e4f85f1
Compare
I have pushed new changes but the OVAL is not working properly, I can't make the check pass, even with |
linux_os/guide/services/sssd/sssd_enable_pam_services/oval/shared.xml
Outdated
Show resolved
Hide resolved
linux_os/guide/services/sssd/sssd_enable_pam_services/oval/shared.xml
Outdated
Show resolved
Hide resolved
e4f85f1
to
169e26c
Compare
Changes identified: Recommended tests to execute: |
/retest |
@ggbecker: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work.
Description:
Rule
sssd_enable_pam_services
:/etc/sssd/conf.d/
directory and to correctly detect the configuration.awk
combined withgrep
anduniq
to get exact lines that need to be changed in the configuration file. Inspired from: https://github.com/ComplianceAsCode/content/blob/master/linux_os/guide/services/sssd/sssd_run_as_sssd_user/bash/shared.shRationale:
Help needed:
- Since/etc/sssd/conf.d/
can be empty, we need a way to skip the check in this case. Usingexistence=any_exist
does not help because if a given file exists and it doesn't comply with the requirement it will evaluate asTrue
.- Since we are using this multi line regex, I didn't find a way to combine this withsed
to use in the remediation. Right now it will look for the lineservices =
and append pam when needed.- Maybe we don't need to be strict in many ways so we could drop the check of/etc/sssd/conf.d/
, but the remediation fix part is definitely something that needs to be fixed because the it is right now, it will always appendservices = pam
to the file.Note: to test this it is needed to havesssd
installed. This is something to be added to test scenarios yet.