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

New SLE 15 rule set_nftables_base_chain #10180

Merged

Conversation

rumch-se
Copy link
Contributor

@rumch-se rumch-se commented Feb 8, 2023

Description:

  • _New SLE 15 rule which covers CIS requirement 3.5.2.5 Ensure base chains exist _

Rationale:

  • At the moment CIS profile for SLE 15 does not include this rule

@rumch-se rumch-se requested a review from a team as a code owner February 8, 2023 10:03
@openshift-ci openshift-ci bot added the needs-ok-to-test Used by openshift-ci bot. label Feb 8, 2023
@openshift-ci
Copy link

openshift-ci bot commented Feb 8, 2023

Hi @rumch-se. Thanks for your PR.

I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@github-actions
Copy link

github-actions bot commented Feb 8, 2023

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

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

Fedora Testing Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

@marcusburghardt marcusburghardt added SLES SUSE Linux Enterprise Server product related. CIS CIS Benchmark related. New Rule Issues or pull requests related to new Rules. labels Feb 8, 2023
@marcusburghardt marcusburghardt added this to the 0.1.67 milestone Feb 8, 2023
@rumch-se
Copy link
Contributor Author

rumch-se commented Feb 8, 2023

Hello @marcusburghardt
Thank you for your feedback.
I have done the proposed corrections.
Have a nice day
Rumen

Copy link
Member

@marcusburghardt marcusburghardt left a comment

Choose a reason for hiding this comment

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

This requirement is intentionally manual in CIS benchmark because both the check and remediation is complex since the requirement can be accomplished by different ways.

Including a very specific approach in remediation is too risky for the system stability. In cases of intentionally manual requirements for CIS, it should be fine to create an OVAL assessment intended help admins and auditors, but I noticed there is no OVAL for this rule.

Regarding the remediation, it should be indeed manual to avoid system disruptions. I can't see a feasible approach robust enough to safely avoid disruptions or undesired changes in intentional settings present in the system.

@marcusburghardt marcusburghardt removed this from the 0.1.67 milestone Feb 14, 2023
@rumch-se
Copy link
Contributor Author

rumch-se commented Feb 14, 2023

Hello @marcusburghardt
The proposed corrections were done.
In the ansible part - I have added a code which erase the file after the remediation.
Have a nice day
Rumen

@openshift-merge-robot openshift-merge-robot added the needs-rebase Used by openshift-ci bot. label Feb 17, 2023
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Used by openshift-ci bot. label Feb 17, 2023
@marcusburghardt marcusburghardt self-assigned this Feb 17, 2023
@marcusburghardt
Copy link
Member

Please, take a look in the failed CI tests. It seems they are legit.

Copy link
Member

@marcusburghardt marcusburghardt left a comment

Choose a reason for hiding this comment

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

Creating a script, executing it and finally removing it in Ansible is definitely weird. It is feasible to decompose everything in this remediation in order to use individual Ansible tasks. Please, avoid using this approach in Ansible when individual tasks are doable.

@rumch-se
Copy link
Contributor Author

Hello @marcusburghardt
I have redesigned bash, and ansible parts of the rule.
Have a nice day
Rumen

@marcusburghardt
Copy link
Member

Hello @marcusburghardt I have redesigned bash, and ansible parts of the rule. Have a nice day Rumen

Much better now @rumch-se . I left some other comments after the changes. Thanks

@marcusburghardt marcusburghardt added this to the 0.1.68 milestone Mar 28, 2023
rumch-se and others added 2 commits March 29, 2023 10:15
…se_chain_priorities.var

Co-authored-by: Marcus Burghardt <2074099+marcusburghardt@users.noreply.github.com>
@rumch-se
Copy link
Contributor Author

rumch-se commented Apr 6, 2023

Hello @marcusburghardt
Most of the corrections were done. I did not combine type of chain(s) and policies in one variable. "input:accept,forward:accept,output:accept"
Have a nice day
Rumen

@rumch-se
Copy link
Contributor Author

Hello @marcusburghardt,

I have updated bash and ansible remediation in the following way
Now I check if a table exist - if "yes" I add only these chains which are not exist as a part of the table. If "not" I create a table and add all chains to it. The ansible works in the same way because we can use the following syntax:
nft list table inet example_table - which display all chains and their rules in example_table

source: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/security_guide/sec-creating_and_managing_nftables_tables_chains_and_rules

Have a nice day
Rumen

@marcusburghardt
Copy link
Member

/packit retest-failed

Copy link
Member

@marcusburghardt marcusburghardt left a comment

Choose a reason for hiding this comment

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

@rumch-se this rule is almost ready. Thanks for the updates. I have some few comments in the Ansible. Also, it would be great if you include an SCE check for it. We can't currently check this requirement using OVAL, but using SCE it is possible and would be very useful.

@marcusburghardt
Copy link
Member

Thanks for the updates in the Ansible remediation @rumch-se .
Regarding the check, do you plan to include a SCE check in this rule since an OVAL is not feasible?
It would be much more useful for users with a check.

@rumch-se
Copy link
Contributor Author

Hello @marcusburghardt

Would it be possible to give me an example for SCE check, and I will adapt to this case?
Have a nice day
Rumen

@marcusburghardt
Copy link
Member

@rumch-se
Copy link
Contributor Author

rumch-se commented May 3, 2023

Hello @marcusburghardt

I have added a SCE check

Have a nice day
Rumen

@marcusburghardt
Copy link
Member

Hello @marcusburghardt

I have added a SCE check

Have a nice day Rumen

Thanks!
What about test scenario scripts? This makes the rule much easier to test.

@rumch-se
Copy link
Contributor Author

rumch-se commented May 4, 2023

Hello @marcusburghardt
I have added test scenario scripts.
Have a nice day
Rumen

Copy link
Member

@marcusburghardt marcusburghardt left a comment

Choose a reason for hiding this comment

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

Unfortunately the remediation is failing with some errors. Please, see my comments.

@rumch-se
Copy link
Contributor Author

rumch-se commented May 8, 2023

Hello @marcusburghardt
I do believe that via my last commit I am providing all corrections you are expecting on.
Have a nice day
Rumen

Copy link
Member

@marcusburghardt marcusburghardt left a comment

Choose a reason for hiding this comment

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

Thanks for the updates @rumch-se . I could test the remediations and check successfully. However, I had to update the default values in the variables. Please, see my comments about it. Also, there are some minor issues about the Ansible tasks names.

@rumch-se
Copy link
Contributor Author

Hello @marcusburghardt
With my last commit I applied proposed changes
Have a nice day
Rumen

@marcusburghardt
Copy link
Member

/packit build

Copy link
Member

@marcusburghardt marcusburghardt left a comment

Choose a reason for hiding this comment

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

LGTM now. Thanks @rumch-se

@marcusburghardt
Copy link
Member

@teacup-on-rockingchair , could you take a look too, please?

…se_chain/sce/shared.sh

Co-authored-by: Marcus Burghardt <2074099+marcusburghardt@users.noreply.github.com>
@codeclimate
Copy link

codeclimate bot commented May 16, 2023

Code Climate has analyzed commit fb379e6 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 52.4%.

View more on Code Climate.

Copy link
Contributor

@teacup-on-rockingchair teacup-on-rockingchair left a comment

Choose a reason for hiding this comment

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

Great contribution 👍

@marcusburghardt marcusburghardt merged commit 437173e into ComplianceAsCode:master May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CIS CIS Benchmark related. needs-ok-to-test Used by openshift-ci bot. New Rule Issues or pull requests related to new Rules. SLES SUSE Linux Enterprise Server product related.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants