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 add nftables ensure default deny policy #10249

Conversation

teacup-on-rockingchair
Copy link
Contributor

@teacup-on-rockingchair teacup-on-rockingchair commented Feb 23, 2023

Description:

  • Add rule definition and OVAL check for nftables ensure default deny policy

Rationale:

  • Define the new rule to match CIS SLE15 requirement 3.5.2.8
  • Add CCE and OVAL check

Review Hints:

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Used by openshift-ci bot. needs-ok-to-test Used by openshift-ci bot. labels Feb 23, 2023
@openshift-ci
Copy link

openshift-ci bot commented Feb 23, 2023

Hi @teacup-on-rockingchair. 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

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

@teacup-on-rockingchair teacup-on-rockingchair force-pushed the sle_add_nftables_ensure_default_deny_policy branch from 0b02ab9 to a09610f Compare April 12, 2023 02:41
@teacup-on-rockingchair teacup-on-rockingchair marked this pull request as ready for review April 12, 2023 04:46
@teacup-on-rockingchair teacup-on-rockingchair requested a review from a team as a code owner April 12, 2023 04:46
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label Apr 12, 2023
@marcusburghardt marcusburghardt self-assigned this Apr 18, 2023
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.

I couldn't test it so for now I have some comments about Style Guide and we have some opportunities to improve the OVAL readability. Test scenario scripts would also be great.

controls/cis_sle15.yml Outdated Show resolved Hide resolved
rationale: |-
There are two policies: accept (Default) and drop. If the policy is set to accept, the
firewall will accept any packet that is not configured to be denied and the packet will
continue traversing the network stack. It is easier to allow acceptable usage than to block
Copy link
Member

Choose a reason for hiding this comment

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

I think an easier management is an argument, but not the strongest one for this requirement. Maybe the main argument here is to ensure that any traffic without an explicit rule is denied by default.

The first part seems to fit better in the description section:

    There are two policies: accept (Default) and drop. If the policy is set to accept, the
    firewall will accept any packet that is not configured to be denied and the packet will
    continue traversing the network stack.

teacup-on-rockingchair and others added 5 commits May 2, 2023 08:16
var_nftable_master_config_file changed to var_nftables_master_config_file
…_default_deny_policy/oval/sle15.xml

Co-authored-by: Marcus Burghardt <2074099+marcusburghardt@users.noreply.github.com>
…_default_deny_policy/oval/sle15.xml

Co-authored-by: Marcus Burghardt <2074099+marcusburghardt@users.noreply.github.com>
…_default_deny_policy/oval/sle15.xml

Co-authored-by: Marcus Burghardt <2074099+marcusburghardt@users.noreply.github.com>
…_default_deny_policy/oval/sle15.xml

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

github-actions bot commented May 2, 2023

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

Click here to see the full diff
New content has different text for rule 'xccdf_org.ssgproject.content_rule_nftables_rules_permanent'.
--- xccdf_org.ssgproject.content_rule_nftables_rules_permanent
+++ xccdf_org.ssgproject.content_rule_nftables_rules_permanent
@@ -1,11 +1,11 @@
 
 [title]:
-Ensure nftables rules are permanent
+Ensure nftables Rules are Permanent
 
 [description]:
 nftables is a subsystem of the Linux kernel providing filtering and classification of
 network packets/datagrams/frames. The nftables service reads the
-'xccdf_org.ssgproject.content_value_var_nftable_master_config_file' file for a nftables file or files to
+'xccdf_org.ssgproject.content_value_var_nftables_master_config_file' file for a nftables file or files to
 include in the nftables ruleset. A nftables ruleset containing the input, forward, and output
 base chains allow network traffic to be filtered.
 

bash remediation for rule 'xccdf_org.ssgproject.content_rule_nftables_rules_permanent' differs.
--- xccdf_org.ssgproject.content_rule_nftables_rules_permanent
+++ xccdf_org.ssgproject.content_rule_nftables_rules_permanent
@@ -1,19 +1,19 @@
 
 
 
-var_nftable_master_config_file=''
+var_nftables_master_config_file=''
 
 
-if [ ! -f "${var_nftable_master_config_file}" ]; then
- touch "${var_nftable_master_config_file}"
+if [ ! -f "${var_nftables_master_config_file}" ]; then
+ touch "${var_nftables_master_config_file}"
 fi
 
 
-grep -qxF 'include "/etc/nftables/bridge-filter"' "${var_nftable_master_config_file}" \
- || echo 'include "/etc/nftables/bridge-filter"' >> "${var_nftable_master_config_file}"
+grep -qxF 'include "/etc/nftables/bridge-filter"' "${var_nftables_master_config_file}" \
+ || echo 'include "/etc/nftables/bridge-filter"' >> "${var_nftables_master_config_file}"
 
-grep -qxF 'include "/etc/nftables/arp-filter"' "${var_nftable_master_config_file}" \
- || echo 'include "/etc/nftables/arp-filter"' >> "${var_nftable_master_config_file}"
+grep -qxF 'include "/etc/nftables/arp-filter"' "${var_nftables_master_config_file}" \
+ || echo 'include "/etc/nftables/arp-filter"' >> "${var_nftables_master_config_file}"
 
-grep -qxF 'include "/etc/nftables/inet-filter"' "${var_nftable_master_config_file}" \
- || echo 'include "/etc/nftables/inet-filter"' >> "${var_nftable_master_config_file}"
+grep -qxF 'include "/etc/nftables/inet-filter"' "${var_nftables_master_config_file}" \
+ || echo 'include "/etc/nftables/inet-filter"' >> "${var_nftables_master_config_file}"

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_nftables_rules_permanent' differs.
--- xccdf_org.ssgproject.content_rule_nftables_rules_permanent
+++ xccdf_org.ssgproject.content_rule_nftables_rules_permanent
@@ -1,12 +1,12 @@
-- name: XCCDF Value var_nftable_master_config_file # promote to variable
+- name: XCCDF Value var_nftables_master_config_file # promote to variable
 set_fact:
- var_nftable_master_config_file: !!str 
+ var_nftables_master_config_file: !!str 
 tags:
 - always
 
 - name: Check the top-level configuration file exists
 ansible.builtin.stat:
- path: '{{ var_nftable_master_config_file }}'
+ path: '{{ var_nftables_master_config_file }}'
 tags:
 - CCE-92485-2
 - low_complexity
@@ -18,7 +18,7 @@
 
 - name: Check the relevant file is included configuration
 ansible.builtin.lineinfile:
- path: '{{ var_nftable_master_config_file }}'
+ path: '{{ var_nftables_master_config_file }}'
 line: include "/etc/nftables/{{ item }}-filter"
 create: true
 loop:

@marcusburghardt marcusburghardt added SLES SUSE Linux Enterprise Server product related. New Rule Issues or pull requests related to new Rules. labels May 2, 2023
teacup-on-rockingchair and others added 2 commits May 3, 2023 07:00
Also re-word description and rationale sections
Thanks to @marcusburghardt for the feedback on that
…_default_deny_policy/rule.yml

Co-authored-by: Marcus Burghardt <2074099+marcusburghardt@users.noreply.github.com>
@teacup-on-rockingchair teacup-on-rockingchair force-pushed the sle_add_nftables_ensure_default_deny_policy branch from 2b8d8ee to 1e202ca Compare May 3, 2023 04:01
@codeclimate
Copy link

codeclimate bot commented May 3, 2023

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

View more on Code Climate.

@marcusburghardt
Copy link
Member

@teacup-on-rockingchair , do you plan to include test scenario scripts? I think it would be great.

@marcusburghardt marcusburghardt added this to the 0.1.68 milestone May 4, 2023
@marcusburghardt
Copy link
Member

Overriding CODEOWNERS as @teacup-on-rockingchair can't approve his own PR.

@marcusburghardt marcusburghardt merged commit 1b4bae3 into ComplianceAsCode:master May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

2 participants