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

Ubuntu: Add missing nftables variables and improve remediation and checks #11134

Merged
merged 5 commits into from
Sep 27, 2023

Conversation

dodys
Copy link
Contributor

@dodys dodys commented Sep 21, 2023

Description:

  • Basically title

Rationale:

  • Bug fix

@dodys dodys requested a review from a team as a code owner September 21, 2023 14:51
@dodys dodys added Ubuntu Ubuntu product related. CIS CIS Benchmark related. labels Sep 21, 2023
@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

@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_set_nftables_loopback_traffic' differs.
--- xccdf_org.ssgproject.content_rule_set_nftables_loopback_traffic
+++ xccdf_org.ssgproject.content_rule_set_nftables_loopback_traffic
@@ -1,13 +1,15 @@
 # Remediation is applicable only in certain platforms
 if ( rpm --quiet -q nftables ); then
+
+grubfile="/boot/grub2/grub.cfg"
 
 # Implement the loopback rules:
 nft add rule inet filter input iif lo accept
 nft insert rule inet filter input ip saddr 127.0.0.0/8 counter drop
 
 # Check IPv6 is disabled, if false implement IPv6 loopback rules
-[ -n "$passing" ] && passing=""
-[ -z "$(grep "^\s*linux" /boot/grub2/grub.cfg | grep -v ipv6.disabled=1)" ] && passing="true"
+disabled="false"
+[ -f "$grubfile" ] && ! grep "^\s*linux" "$grubfile" | grep -vq "ipv6.disable=1" && disabled="true"
 
 grep -Eq "^\s*net\.ipv6\.conf\.all\.disable_ipv6\s*=\s*1\b(\s+#.*)?$" \
 /etc/sysctl.conf /etc/sysctl.d/*.conf && \
@@ -15,10 +17,10 @@
 /etc/sysctl.conf /etc/sysctl.d/*.conf && sysctl net.ipv6.conf.all.disable_ipv6 | \
 grep -Eq "^\s*net\.ipv6\.conf\.all\.disable_ipv6\s*=\s*1\b(\s+#.*)?$" && \
 sysctl net.ipv6.conf.default.disable_ipv6 | \
-grep -Eq "^\s*net\.ipv6\.conf\.default\.disable_ipv6\s*=\s*1\b(\s+#.*)?$" && passing="true"
+grep -Eq "^\s*net\.ipv6\.conf\.default\.disable_ipv6\s*=\s*1\b(\s+#.*)?$" && disabled="true"
 
 # Is IPv6 Disabled? (true/false)
-if [ "$passing" = false ] ; then
+if [ "$disabled" = false ] ; then
     nft add rule inet filter input ip6 saddr ::1 counter drop
 fi
 

@codeclimate
Copy link

codeclimate bot commented Sep 21, 2023

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

View more on Code Climate.

@Mab879
Copy link
Member

Mab879 commented Sep 25, 2023

/test images

@Mab879 Mab879 self-assigned this Sep 27, 2023
Copy link
Member

@Mab879 Mab879 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 PR!

Overriding the CODEOWNERS was @dodys cannot approve his own PRs.

@Mab879
Copy link
Member

Mab879 commented Sep 27, 2023

The Automatus failures are expected, waving.

@Mab879 Mab879 merged commit 86f6761 into ComplianceAsCode:master Sep 27, 2023
34 of 38 checks passed
@Mab879 Mab879 added this to the 0.1.70 milestone Oct 11, 2023
@Mab879 Mab879 added the Update Rule Issues or pull requests related to Rules updates. label Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CIS CIS Benchmark related. Ubuntu Ubuntu product related. Update Rule Issues or pull requests related to Rules updates.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants