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

SLE15 audit rules mac modification usr share depends on selinux policy packages #10883

Conversation

teacup-on-rockingchair
Copy link
Contributor

Description:

  • In SLE15 environment we have separate package for selinux policy

Rationale:

  • In order rules that audit selinux policy configuration to be relevant we need one of the dedicated selinux-policy packages to be installed otherwise the rule is irrelevant

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Jul 20, 2023
@openshift-ci
Copy link

openshift-ci bot commented Jul 20, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@github-actions
Copy link

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

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

Fedora Testing Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

@teacup-on-rockingchair teacup-on-rockingchair marked this pull request as ready for review July 20, 2023 12:16
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label Jul 20, 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.

My main concern is that the change of the XCCDF manual file isn't mentioned in the PR description. It gives a false impression that this PR is solely about the single audit rule. Such a big change as XCCDF manual update should be submitted as a separate PR instead.

Comment on lines 7 to 14
{{%- if 'sle15' in product -%}}
<criteria operator="AND">
<criterion test_ref="check_selinux_policy_devel_installed"
comment="Check no selinux-policy-devel package installed" negate="true"/>
<criterion test_ref="check_selinux_policy_targeted_installed"
comment="Check no selinux-policy-targeted package installed" negate="true"/>
</criteria>
{{%- endif -%}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you considered creating a platform restriction in the rule.yml instad of modifying the OVAL? What are the reasons for this solution?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main reason here is that for sle platform, not sure about the others, we need to have some of the selinux-policy packages installed in order the whole rule to be relevant because otherwise even if we have selinux installed with no policies there is nothing to audit

Copy link
Collaborator

Choose a reason for hiding this comment

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

That doesn't explain why you chose this way, you can get the same result with using platform expressions. Also if you used platforms you would get "notapplicable" results if the package isn't present, and that way you can get more understandable user experience in the HTML report.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I assume your suggestion to rework it, so the rule is limited by platform clause:
platform: package[selinux-policy-devel] or [selinux-policy-targeted] ,
and add declaration of the relevant packages for all linux flavours?

@@ -22,6 +30,11 @@
</criteria>
</definition>

{{%- if 'sle15' in product -%}}
{{{ oval_test_package_installed(package="selinux-policy-devel", evr=EVR, test_id="check_selinux_policy_devel_installed") }}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

The EVR variable isn't defined. You probably wanted to set it to None or you can remove the evr=EVR, completely because it's a parameter with a default value (see the definition of the oval_test_package_installed macro).

@teacup-on-rockingchair teacup-on-rockingchair force-pushed the sle15_audit_rules_mac_modification_usr_share_depends_selinux_policy branch from ff68aba to c59f17e Compare July 22, 2023 05:27
Comment on lines 7 to 14
{{%- if 'sle15' in product -%}}
<criteria operator="AND">
<criterion test_ref="check_selinux_policy_devel_installed"
comment="Check no selinux-policy-devel package installed" negate="true"/>
<criterion test_ref="check_selinux_policy_targeted_installed"
comment="Check no selinux-policy-targeted package installed" negate="true"/>
</criteria>
{{%- endif -%}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

That doesn't explain why you chose this way, you can get the same result with using platform expressions. Also if you used platforms you would get "notapplicable" results if the package isn't present, and that way you can get more understandable user experience in the HTML report.

@@ -4,6 +4,14 @@
mandatory access controls (SELinux) in usr/share/selinux are enabled.") }}}

<criteria operator="OR">
{{%- if 'sle15' in product -%}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This condition also matches any other string that contains "sle15" as a substring, eg. "sle158", "ssle15". That means it can match unwanted products in future. Normally, you should do product == "sle15", or better, product in ["sle15"]. The latter will allow people do have an easier expansion in future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the tip changed it in c3a8fb7

@jan-cerny jan-cerny self-assigned this Jul 24, 2023
@jan-cerny jan-cerny added this to the 0.1.70 milestone Jul 24, 2023
@jan-cerny jan-cerny added the OVAL OVAL update. Related to the systems assessments. label Jul 25, 2023
@codeclimate
Copy link

codeclimate bot commented Jul 27, 2023

Code Climate has analyzed commit c3a8fb7 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 53.2% (0.0% change).

View more on Code Climate.

@teacup-on-rockingchair teacup-on-rockingchair merged commit 8d96a74 into ComplianceAsCode:master Jul 29, 2023
33 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OVAL OVAL update. Related to the systems assessments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants