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

Update firewalld rules for bootable containers #12626

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

matusmarhefka
Copy link
Member

The rules firewalld_loopback_traffic_restricted, firewalld_loopback_traffic_trusted and configure_firewalld_rate_limiting have been updated for bootable containers (only their remediations needed an update).

@matusmarhefka matusmarhefka added the Image Mode Bootable containers and Image Mode RHEL label Nov 21, 2024
@matusmarhefka matusmarhefka added this to the 0.1.76 milestone Nov 21, 2024
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

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_firewalld_loopback_traffic_restricted' differs.
--- xccdf_org.ssgproject.content_rule_firewalld_loopback_traffic_restricted
+++ xccdf_org.ssgproject.content_rule_firewalld_loopback_traffic_restricted
@@ -8,7 +8,7 @@
 ipv4_rule='rule family=ipv4 source address="127.0.0.1" destination not address="127.0.0.1" drop'
 ipv6_rule='rule family=ipv6 source address="::1" destination not address="::1" drop'
 
-if test "$(stat -c %d:%i /)" != "$(stat -c %d:%i /proc/1/root/.)"; then
+if test "$(stat -c %d:%i /)" != "$(stat -c %d:%i /proc/1/root/.)" || [[ "$OSCAP_BOOTC_BUILD" == "YES" ]]; then
     firewall-offline-cmd --zone=trusted --add-rich-rule="${ipv4_rule}"
     firewall-offline-cmd --zone=trusted --add-rich-rule="${ipv6_rule}"
 elif systemctl is-active firewalld; then

bash remediation for rule 'xccdf_org.ssgproject.content_rule_firewalld_loopback_traffic_trusted' differs.
--- xccdf_org.ssgproject.content_rule_firewalld_loopback_traffic_trusted
+++ xccdf_org.ssgproject.content_rule_firewalld_loopback_traffic_trusted
@@ -5,7 +5,7 @@
     yum install -y "firewalld"
 fi
 
-if test "$(stat -c %d:%i /)" != "$(stat -c %d:%i /proc/1/root/.)"; then
+if test "$(stat -c %d:%i /)" != "$(stat -c %d:%i /proc/1/root/.)" || [[ "$OSCAP_BOOTC_BUILD" == "YES" ]]; then
     firewall-offline-cmd --zone=trusted --add-interface=lo
 elif systemctl is-active firewalld; then
     firewall-cmd --permanent --zone=trusted --add-interface=lo

@jan-cerny jan-cerny self-assigned this Nov 22, 2024
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.

I have built a CS 9 bootable container image with the cis profile using the content with this PR and then I booted a VM from the container image using podman-bootc. Both rules firewalld_loopback_traffic_restricted and firewalld_loopback_traffic_trusted are PASS in the after-boot scan.

We can see that the firewall output contains the expected configuration:

[admin@ibm-p8-kvm-03-guest-02 ~]$ sudo firewall-cmd --zone trusted --list-all
trusted (active)
  target: ACCEPT
  icmp-block-inversion: no
  interfaces: lo
  sources: 
  services: 
  ports: 
  protocols: 
  forward: yes
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 
	rule family="ipv6" source address="::1" destination NOT address="::1" drop
	rule family="ipv4" source address="127.0.0.1" destination NOT address="127.0.0.1" drop

Copy link

codeclimate bot commented Nov 22, 2024

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

View more on Code Climate.

@jan-cerny jan-cerny merged commit bc0a4a0 into ComplianceAsCode:master Nov 26, 2024
99 of 105 checks passed
@matusmarhefka matusmarhefka deleted the bootc_firewalld branch November 26, 2024 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Image Mode Bootable containers and Image Mode RHEL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants