-
Notifications
You must be signed in to change notification settings - Fork 698
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
Update Account Home Folder Rules #12465
Update Account Home Folder Rules #12465
Conversation
This datastream diff is auto generated by the check Click here to see the full diffbash remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_users_home_files_groupownership' differs.
--- xccdf_org.ssgproject.content_rule_accounts_users_home_files_groupownership
+++ xccdf_org.ssgproject.content_rule_accounts_users_home_files_groupownership
@@ -1,5 +1,5 @@
-for user in $(awk -F':' '{ if ($3 >= 1000 && $3 != 65534) print $1 }' /etc/passwd); do
+for user in $(awk -F':' '{ if ($3 >= 1000 && $3 != 65534 && $6 != "/") print $1 }' /etc/passwd); do
home_dir=$(getent passwd $user | cut -d: -f6)
group=$(getent passwd $user | cut -d: -f4)
# Only update the group-ownership when necessary. This will avoid changing the inode timestamp
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_users_home_files_groupownership' differs.
--- xccdf_org.ssgproject.content_rule_accounts_users_home_files_groupownership
+++ xccdf_org.ssgproject.content_rule_accounts_users_home_files_groupownership
@@ -34,6 +34,7 @@
when:
- item.value[1]|int >= 1000
- item.value[1]|int != 65534
+ - item.value[4] != "/"
tags:
- CCE-86534-5
- DISA-STIG-RHEL-08-010741
bash remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_users_home_files_ownership' differs.
--- xccdf_org.ssgproject.content_rule_accounts_users_home_files_ownership
+++ xccdf_org.ssgproject.content_rule_accounts_users_home_files_ownership
@@ -1,5 +1,5 @@
-for user in $(awk -F':' '{ if ($3 >= 1000 && $3 != 65534) print $1 }' /etc/passwd); do
+for user in $(awk -F':' '{ if ($3 >= 1000 && $3 != 65534 && $6 != "/") print $1 }' /etc/passwd); do
home_dir=$(getent passwd $user | cut -d: -f6)
# Only update the ownership when necessary. This will avoid changing the inode timestamp
# when the owner is already defined as expected, therefore not impacting in possible integrity
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_users_home_files_ownership' differs.
--- xccdf_org.ssgproject.content_rule_accounts_users_home_files_ownership
+++ xccdf_org.ssgproject.content_rule_accounts_users_home_files_ownership
@@ -32,6 +32,7 @@
when:
- item.value[1]|int >= 1000
- item.value[1]|int != 65534
+ - item.value[4] != "/"
tags:
- CCE-87040-2
- accounts_users_home_files_ownership
bash remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_users_home_files_permissions' differs.
--- xccdf_org.ssgproject.content_rule_accounts_users_home_files_permissions
+++ xccdf_org.ssgproject.content_rule_accounts_users_home_files_permissions
@@ -1,5 +1,5 @@
-for home_dir in $(awk -F':' '{ if ($3 >= 1000 && $3 != 65534) print $6 }' /etc/passwd); do
+for home_dir in $(awk -F':' '{ if ($3 >= 1000 && $3 != 65534 && $6 != "/") print $6 }' /etc/passwd); do
# Only update the permissions when necessary. This will avoid changing the inode timestamp when
# the permission is already defined as expected, therefore not impacting in possible integrity
# check systems that also check inodes timestamps.
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_users_home_files_permissions' differs.
--- xccdf_org.ssgproject.content_rule_accounts_users_home_files_permissions
+++ xccdf_org.ssgproject.content_rule_accounts_users_home_files_permissions
@@ -33,6 +33,7 @@
when:
- item.value[1]|int >= 1000
- item.value[1]|int != 65534
+ - item.value[4] != "/"
tags:
- CCE-85888-6
- DISA-STIG-RHEL-08-010731
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_home_directories' differs.
--- xccdf_org.ssgproject.content_rule_file_permissions_home_directories
+++ xccdf_org.ssgproject.content_rule_file_permissions_home_directories
@@ -1,5 +1,5 @@
-for home_dir in $(awk -F':' '{ if ($3 >= 1000 && $3 != 65534) print $6 }' /etc/passwd); do
+for home_dir in $(awk -F':' '{ if ($3 >= 1000 && $3 != 65534 && $6 != "/") print $6 }' /etc/passwd); do
# Only update the permissions when necessary. This will avoid changing the inode timestamp when
# the permission is already defined as expected, therefore not impacting in possible integrity
# check systems that also check inodes timestamps.
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_home_directories' differs.
--- xccdf_org.ssgproject.content_rule_file_permissions_home_directories
+++ xccdf_org.ssgproject.content_rule_file_permissions_home_directories
@@ -33,6 +33,7 @@
when:
- item.value[1]|int >= 1000
- item.value[1]|int != 65534
+ - item.value[4] != "/"
tags:
- CCE-84038-9
- DISA-STIG-RHEL-08-010730
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_home_dirs' differs.
--- xccdf_org.ssgproject.content_rule_file_permissions_home_dirs
+++ xccdf_org.ssgproject.content_rule_file_permissions_home_dirs
@@ -1,5 +1,5 @@
-for home_dir in $(awk -F':' '{ if ($3 >= 1000 && $3 != 65534) print $6 }' /etc/passwd); do
+for home_dir in $(awk -F':' '{ if ($3 >= 1000 && $3 != 65534 && $6 != "/") print $6 }' /etc/passwd); do
# Only update the permissions when necessary. This will avoid changing the inode timestamp when
# the permission is already defined as expected, therefore not impacting in possible integrity
# check systems that also check inodes timestamps.
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_home_dirs' differs.
--- xccdf_org.ssgproject.content_rule_file_permissions_home_dirs
+++ xccdf_org.ssgproject.content_rule_file_permissions_home_dirs
@@ -37,6 +37,7 @@
when:
- item.value[1]|int >= 1000
- item.value[1]|int != 65534
+ - item.value[4] != "/"
tags:
- CCE-84274-0
- NIST-800-53-AC-6(1) |
🤖 A k8s content image for this PR is available at: Click here to see how to deploy itIf you alread have Compliance Operator deployed: Otherwise deploy the content and operator together by checking out ComplianceAsCode/compliance-operator and: |
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.
Can we have a test scenario covering the / situation?
I'm working on this, it's taking a bit of time to ensure I don't break other rules in the process. |
Make sure that script doesn't run on users that don't have proper home folder defined. This commit makes the script skip home folders defined as "/".
Make sure that script doesn't run on users that don't have proper home folder defined. This commit makes the script skip home folders defined as "/".
Make sure that script doesn't run on users that don't have proper home folder defined. This commit makes the script skip home folders defined as "/".
To show the rule will fail and will stay failing as remedating this situation doesn't make sense as change the permissions on / isn't a great idea.
7c6304c
to
a7f140d
Compare
I have added a test scenario. Since there really isn't way to fix the finding other assigning the user a proper home folder, I have disabled the remediation. |
Code Climate has analyzed commit a7f140d and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 59.5% (0.0% change). View more on Code Climate. |
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.
jcerny@fedora:~/work/git/scap-security-guide (pr/12465)$ python3 tests/automatus.py rule --libvirt qemu:///system ssgts_rhel9 accounts_users_home_files_ownership
Setting console output to log level INFO
INFO - The base image option has not been specified, choosing libvirt-based test environment.
INFO - Logging into /home/jcerny/work/git/scap-security-guide/logs/rule-custom-2024-10-11-1412/test_suite.log
INFO - xccdf_org.ssgproject.content_rule_accounts_users_home_files_ownership
INFO - Script expected_owner.pass.sh using profile (all) OK
INFO - Script home_dirs_all_absent.pass.sh using profile (all) OK
INFO - Script home_dirs_one_absent.pass.sh using profile (all) OK
INFO - Script unexpected_owner_system_id.fail.sh using profile (all) OK
INFO - Script unexpected_owner_unknown_id.fail.sh using profile (all) OK
INFO - Script warning_home_dirs_swapped_owner.pass.sh using profile (all) OK
INFO - Script interactive_users_absent.pass.sh using profile (all) OK
INFO - Script interactive_user_nologin_ignored.pass.sh using profile (all) OK
INFO - Script root_fs_home.fail.sh using profile (all) OK
jcerny@fedora:~/work/git/scap-security-guide (pr/12465)$ python3 tests/automatus.py rule --libvirt qemu:///system ssgts_rhel9 --remediate-using ansible accounts_users_home_files_ownership
Setting console output to log level INFO
INFO - The base image option has not been specified, choosing libvirt-based test environment.
INFO - Logging into /home/jcerny/work/git/scap-security-guide/logs/rule-custom-2024-10-11-1416/test_suite.log
INFO - xccdf_org.ssgproject.content_rule_accounts_users_home_files_ownership
INFO - Script expected_owner.pass.sh using profile (all) OK
INFO - Script home_dirs_all_absent.pass.sh using profile (all) OK
INFO - Script home_dirs_one_absent.pass.sh using profile (all) OK
INFO - Script unexpected_owner_system_id.fail.sh using profile (all) OK
INFO - Script unexpected_owner_unknown_id.fail.sh using profile (all) OK
INFO - Script warning_home_dirs_swapped_owner.pass.sh using profile (all) OK
INFO - Script interactive_users_absent.pass.sh using profile (all) OK
INFO - Script interactive_user_nologin_ignored.pass.sh using profile (all) OK
INFO - Script root_fs_home.fail.sh using profile (all) OK
jcerny@fedora:~/work/git/scap-security-guide (pr/12465)$ python3 tests/automatus.py rule --libvirt qemu:///system ssgts_rhel9 accounts_users_home_files_groupownership
Setting console output to log level INFO
INFO - The base image option has not been specified, choosing libvirt-based test environment.
INFO - Logging into /home/jcerny/work/git/scap-security-guide/logs/rule-custom-2024-10-11-1418/test_suite.log
INFO - xccdf_org.ssgproject.content_rule_accounts_users_home_files_groupownership
INFO - Script expected_groupowner.pass.sh using profile (all) OK
INFO - Script home_dirs_all_absent.pass.sh using profile (all) OK
INFO - Script home_dirs_one_absent.pass.sh using profile (all) OK
INFO - Script unexpected_groupowner_system_gid.fail.sh using profile (all) OK
INFO - Script unexpected_groupowner_unknown_gid.fail.sh using profile (all) OK
INFO - Script warning_home_dirs_swapped_groupowner.pass.sh using profile (all) OK
INFO - Script interactive_users_absent.pass.sh using profile (all) OK
INFO - Script interactive_user_nologin_ignored.pass.sh using profile (all) OK
INFO - Script root_fs_home.fail.sh using profile (all) OK
jcerny@fedora:~/work/git/scap-security-guide (pr/12465)$ python3 tests/automatus.py rule --libvirt qemu:///system ssgts_rhel9 --remediate-using ansible accounts_users_home_files_groupownership
Setting console output to log level INFO
INFO - The base image option has not been specified, choosing libvirt-based test environment.
INFO - Logging into /home/jcerny/work/git/scap-security-guide/logs/rule-custom-2024-10-11-1421/test_suite.log
INFO - xccdf_org.ssgproject.content_rule_accounts_users_home_files_groupownership
INFO - Script expected_groupowner.pass.sh using profile (all) OK
INFO - Script home_dirs_all_absent.pass.sh using profile (all) OK
INFO - Script home_dirs_one_absent.pass.sh using profile (all) OK
INFO - Script unexpected_groupowner_system_gid.fail.sh using profile (all) OK
INFO - Script unexpected_groupowner_unknown_gid.fail.sh using profile (all) OK
INFO - Script warning_home_dirs_swapped_groupowner.pass.sh using profile (all) OK
INFO - Script interactive_users_absent.pass.sh using profile (all) OK
INFO - Script interactive_user_nologin_ignored.pass.sh using profile (all) OK
INFO - Script root_fs_home.fail.sh using profile (all) OK
Description:
The following now skip users with home folders defined as
/
.bash_restrict_permissions_home_directories
ansible_restrict_permissions_home_directories
Rationale:
Ensuring the scripts complete successfully with a user doesn't a proper home folder defined.