Skip to content
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

Remove similar test scenarios on rules templated by file_groupownership #8755

Merged

Conversation

marcusburghardt
Copy link
Member

Description:

The file_groupowner already has templated test scenarios.
Reviewed and cleaned-up rules which use this template and have similar test scenarios.

Rationale:

Reduction of duplication.

@github-actions
Copy link

github-actions bot commented May 11, 2022

Start a new ephemeral environment with changes proposed in this pull request:

Open in Gitpod

@marcusburghardt marcusburghardt added the Test Suite Update in Test Suite. label May 11, 2022
@marcusburghardt marcusburghardt added this to the 0.1.62 milestone May 11, 2022
@yuumasato yuumasato self-assigned this May 11, 2022
Copy link
Member

@yuumasato yuumasato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems you forgot rule file_groupownership_audit_configuration.

I picked some rules randomly to test and of those, root_permissions_syslibrary_files and file_groupownership_audit_configuration are failing on incorrect_groupowner.fail.sh.
Could you check what is wrong with them?

@codeclimate
Copy link

codeclimate bot commented May 12, 2022

Analysis results are not available for those commits

View more on Code Climate.

@marcusburghardt
Copy link
Member Author

It seems you forgot rule file_groupownership_audit_configuration.

It was not forgotten. I won't include this rule in this PR. Its custom test scenarios install a package and this case will not be covered in this PR.

I picked some rules randomly to test and of those, root_permissions_syslibrary_files and file_groupownership_audit_configuration are failing on incorrect_groupowner.fail.sh. Could you check what is wrong with them?

I investigated the root_permissions_syslibrary_files rule and fixed it.

@github-actions
Copy link

This datastream diff is auto generated by the check Compare DS/Generate Diff

Click here to see the full diff
bash remediation for rule 'xccdf_org.ssgproject.content_rule_root_permissions_syslibrary_files' differs:
--- old datastream
+++ new datastream
@@ -1,13 +1,10 @@
 
 
 
-find /lib/ -maxdepth 1 -type f ! -gid 0 -regex '^.*$' -exec chgrp 0 {} \;
+find -H /lib/ -type d -exec chgrp 0 {} \;
 
+find -H /lib64/ -type d -exec chgrp 0 {} \;
 
-find /lib64/ -maxdepth 1 -type f ! -gid 0 -regex '^.*$' -exec chgrp 0 {} \;
+find -H /usr/lib/ -type d -exec chgrp 0 {} \;
 
-
-find /usr/lib/ -maxdepth 1 -type f ! -gid 0 -regex '^.*$' -exec chgrp 0 {} \;
-
-
-find /usr/lib64/ -maxdepth 1 -type f ! -gid 0 -regex '^.*$' -exec chgrp 0 {} \;
+find -H /usr/lib64/ -type d -exec chgrp 0 {} \;

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_root_permissions_syslibrary_files' differs:
--- old datastream
+++ new datastream
@@ -1,9 +1,9 @@
-- name: Find /lib/ file(s) matching ^.*$
- command: find -H /lib/ -maxdepth 1 -type f ! -gid 0 -regex "^.*$"
- register: files_found
- changed_when: false
- failed_when: false
- check_mode: false
+- name: Ensure group owner on /lib/ recursively
+ file:
+ path: /lib/
+ state: directory
+ recurse: true
+ group: '0'
 tags:
 - CCE-86523-8
 - DISA-STIG-RHEL-08-010350
@@ -16,13 +16,12 @@
 - no_reboot_needed
 - root_permissions_syslibrary_files
 
-- name: Ensure group owner on /lib/ file(s) matching ^.*$
+- name: Ensure group owner on /lib64/ recursively
 file:
- path: '{{ item }}'
+ path: /lib64/
+ state: directory
+ recurse: true
 group: '0'
- state: file
- with_items:
- - '{{ files_found.stdout_lines }}'
 tags:
 - CCE-86523-8
 - DISA-STIG-RHEL-08-010350
@@ -35,12 +34,12 @@
 - no_reboot_needed
 - root_permissions_syslibrary_files
 
-- name: Find /lib64/ file(s) matching ^.*$
- command: find -H /lib64/ -maxdepth 1 -type f ! -gid 0 -regex "^.*$"
- register: files_found
- changed_when: false
- failed_when: false
- check_mode: false
+- name: Ensure group owner on /usr/lib/ recursively
+ file:
+ path: /usr/lib/
+ state: directory
+ recurse: true
+ group: '0'
 tags:
 - CCE-86523-8
 - DISA-STIG-RHEL-08-010350
@@ -53,13 +52,12 @@
 - no_reboot_needed
 - root_permissions_syslibrary_files
 
-- name: Ensure group owner on /lib64/ file(s) matching ^.*$
+- name: Ensure group owner on /usr/lib64/ recursively
 file:
- path: '{{ item }}'
+ path: /usr/lib64/
+ state: directory
+ recurse: true
 group: '0'
- state: file
- with_items:
- - '{{ files_found.stdout_lines }}'
 tags:
 - CCE-86523-8
 - DISA-STIG-RHEL-08-010350
@@ -71,77 +69,3 @@
 - medium_severity
 - no_reboot_needed
 - root_permissions_syslibrary_files
-
-- name: Find /usr/lib/ file(s) matching ^.*$
- command: find -H /usr/lib/ -maxdepth 1 -type f ! -gid 0 -regex "^.*$"
- register: files_found
- changed_when: false
- failed_when: false
- check_mode: false
- tags:
- - CCE-86523-8
- - DISA-STIG-RHEL-08-010350
- - NIST-800-53-CM-5(6)
- - NIST-800-53-CM-5(6).1
- - configure_strategy
- - low_complexity
- - low_disruption
- - medium_severity
- - no_reboot_needed
- - root_permissions_syslibrary_files
-
-- name: Ensure group owner on /usr/lib/ file(s) matching ^.*$
- file:
- path: '{{ item }}'
- group: '0'
- state: file
- with_items:
- - '{{ files_found.stdout_lines }}'
- tags:
- - CCE-86523-8
- - DISA-STIG-RHEL-08-010350
- - NIST-800-53-CM-5(6)
- - NIST-800-53-CM-5(6).1
- - configure_strategy
- - low_complexity
- - low_disruption
- - medium_severity
- - no_reboot_needed
- - root_permissions_syslibrary_files
-
-- name: Find /usr/lib64/ file(s) matching ^.*$
- command: find -H /usr/lib64/ -maxdepth 1 -type f ! -gid 0 -regex "^.*$"
- register: files_found
- changed_when: false
- failed_when: false
- check_mode: false
- tags:
- - CCE-86523-8
- - DISA-STIG-RHEL-08-010350
- - NIST-800-53-CM-5(6)
- - NIST-800-53-CM-5(6).1
- - configure_strategy
- - low_complexity
- - low_disruption
- - medium_severity
- - no_reboot_needed
- - root_permissions_syslibrary_files
-
-- name: Ensure group owner on /usr/lib64/ file(s) matching ^.*$
- file:
- path: '{{ item }}'
- group: '0'
- state: file
- with_items:
- - '{{ files_found.stdout_lines }}'
- tags:
- - CCE-86523-8
- - DISA-STIG-RHEL-08-010350
- - NIST-800-53-CM-5(6)
- - NIST-800-53-CM-5(6).1
- - configure_strategy
- - low_complexity
- - low_disruption
- - medium_severity
- - no_reboot_needed
- - root_permissions_syslibrary_files

@openshift-ci
Copy link

openshift-ci bot commented May 12, 2022

@marcusburghardt: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-rhcos4-e8 1ba11cb link true /test e2e-aws-rhcos4-e8
ci/prow/e2e-aws-rhcos4-high 1ba11cb link true /test e2e-aws-rhcos4-high
ci/prow/e2e-aws-rhcos4-moderate 1ba11cb link true /test e2e-aws-rhcos4-moderate

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.

@yuumasato
Copy link
Member

It seems you forgot rule file_groupownership_audit_configuration.

It was not forgotten. I won't include this rule in this PR. Its custom test scenarios install a package and this case will not be covered in this PR.

Thank you for the clarification

@yuumasato yuumasato merged commit 77cff05 into ComplianceAsCode:master May 13, 2022
@marcusburghardt marcusburghardt deleted the file_groupowner_template branch May 13, 2022 16:01
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Test Suite Update in Test Suite.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants