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

Make selinux context elevation for sudo more flexible #11224

Conversation

Mab879
Copy link
Member

@Mab879 Mab879 commented Oct 25, 2023

Description:

  • Don't hardcode wheel in selinux_context_elevation_for_sudo
  • Make the tests for selinux_context_elevation_for_sudo applicable to all platforms

Rationale:

  • More tests for RHEL
  • Keep up to date with the STIG

Review Updates:

And add the right shebang to the tests as well.
As of OL7/RHEL7 STIG release for CY23Q4 no longer requires the group
be wheel.

Also add a test for this.
@Mab879 Mab879 added Update Rule Issues or pull requests related to Rules updates. STIG STIG Benchmark related. labels Oct 25, 2023
@Mab879 Mab879 added this to the 0.1.71 milestone Oct 25, 2023
@github-actions
Copy link

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

rhel7 (from CTF) Environment (using Fedora as testing environment)
Open in Gitpod

Fedora Testing Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

@codeclimate
Copy link

codeclimate bot commented Oct 25, 2023

Code Climate has analyzed commit 0ad34bc 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 57.0%.

View more on Code Climate.

@jan-cerny jan-cerny changed the title Make selinux context elevation for sudo more flexaible Make selinux context elevation for sudo more flexible Oct 26, 2023
@jan-cerny jan-cerny self-assigned this Oct 26, 2023
Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

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

The CI fail on CentOS Stream 8 and 9 are caused by a fact that this rule is marked as only for RHEL 7 and OL 7 according to prodtype, therefore they aren't part of RHEL 8 or 9. The CI fail on SLE 15 is caused by a missing package during the container build, but the rule isn't part of sle15 product anyway so it doesn't matter.

The test scenarios pass when executed locally on a RHEL 7 virtual machine back end.

jcerny@fedora ~/work/git/scap-security-guide (pr/11224) $ python3 tests/automatus.py rule --libvirt qemu:///system ssgts_rhel7 --dontclean selinux_context_elevation_for_sudo 
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-2023-10-26-1321/test_suite.log
INFO - xccdf_org.ssgproject.content_rule_selinux_context_elevation_for_sudo
INFO - Script conflicting_value.fail.sh using profile (all) OK
INFO - Script correct_value_multiple_files.pass.sh using profile (all) OK
INFO - Script correct_value_single_file.pass.sh using profile (all) OK
INFO - Script custom_group_name.pass.sh using profile (all) OK
INFO - Script missing_role.fail.sh using profile (all) OK
INFO - Script missing_type.fail.sh using profile (all) OK
jcerny@fedora ~/work/git/scap-security-guide (pr/11224) $ python3 tests/automatus.py rule --libvirt qemu:///system ssgts_rhel7 --remediate-using ansible --dontclean selinux_context_elevation_for_sudo 
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-2023-10-26-1342/test_suite.log
INFO - xccdf_org.ssgproject.content_rule_selinux_context_elevation_for_sudo
INFO - Script conflicting_value.fail.sh using profile (all) OK
INFO - Script correct_value_multiple_files.pass.sh using profile (all) OK
INFO - Script correct_value_single_file.pass.sh using profile (all) OK
INFO - Script custom_group_name.pass.sh using profile (all) OK
INFO - Script missing_role.fail.sh using profile (all) OK
INFO - Script missing_type.fail.sh using profile (all) OK

Thanks for adding this scenario.

@jan-cerny jan-cerny merged commit 97399d9 into ComplianceAsCode:master Oct 26, 2023
31 of 34 checks passed
@Mab879 Mab879 deleted the make_selinux_context_elevation_for_sudo_more_flexaible branch October 26, 2023 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STIG STIG Benchmark related. Update Rule Issues or pull requests related to Rules updates.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants