-
Notifications
You must be signed in to change notification settings - Fork 823
Implement automation and checks for configured_firewalld_default_deny #14995
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
base: master
Are you sure you want to change the base?
Changes from 6 commits
ae5a708
2b805db
6a1839b
00b6afc
7955be0
d1de3c8
da31ce5
6998838
63b7ed2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # platform = multi_platform_all | ||
| # reboot = false | ||
| # strategy = configure | ||
| # complexity = low | ||
| # disruption = low | ||
|
|
||
| - name: Ensure firewalld default zone is drop | ||
| lineinfile: | ||
| path: /etc/firewalld/firewalld.conf | ||
| regexp: '^DefaultZone=' | ||
| line: 'DefaultZone=drop' | ||
| create: yes | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this file doesn't exist is firewalld installed? Also it seems this might be a symlink on some systems. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # platform = multi_platform_all | ||
| # reboot = false | ||
| # strategy = configure | ||
| # complexity = low | ||
| # disruption = low | ||
|
|
||
| {{{ bash_replace_or_append('/etc/firewalld/firewalld.conf', '^DefaultZone', 'drop', '%s=%s') }}} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <def-group> | ||
| <definition class="compliance" id="{{{ rule_id }}}" version="1"> | ||
| {{{ oval_metadata("Firewalld Must Employ a Deny-all, Allow-by-exception Policy") }}} | ||
| <criteria operator="AND"> | ||
| <criterion comment="firewalld default zone is drop" | ||
| test_ref="test_firewalld_default_zone_drop" /> | ||
| <criteria operator="OR"> | ||
| <criterion comment="firewalld default zone has target DROP in /etc" | ||
| test_ref="test_firewalld_default_zone_target_drop_etc" /> | ||
| <criterion comment="firewalld default zone has target DROP in /usr" | ||
| test_ref="test_firewalld_default_zone_target_drop_usr" /> | ||
| </criteria> | ||
| </criteria> | ||
| </definition> | ||
|
|
||
| <ind:textfilecontent54_test id="test_firewalld_default_zone_drop" version="1" check="all" check_existence="all_exist" comment="Ensure DefaultZone is drop"> | ||
| <ind:object object_ref="object_firewalld_default_zone_drop" /> | ||
| </ind:textfilecontent54_test> | ||
|
|
||
| <ind:textfilecontent54_object id="object_firewalld_default_zone_drop" version="1"> | ||
| <ind:filepath>/etc/firewalld/firewalld.conf</ind:filepath> | ||
| <ind:pattern operation="pattern match">^DefaultZone=drop$</ind:pattern> | ||
| <ind:instance datatype="int">1</ind:instance> | ||
| </ind:textfilecontent54_object> | ||
|
|
||
| <ind:xmlfilecontent_test id="test_firewalld_default_zone_target_drop_etc" version="1" check="all" check_existence="at_least_one_exists" comment="Ensure default zone has target DROP in /etc"> | ||
| <ind:object object_ref="object_firewalld_default_zone_target_drop_etc" /> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is invalid OVAL. You need split this into test two tests. |
||
| </ind:xmlfilecontent_test> | ||
|
|
||
| <ind:xmlfilecontent_test id="test_firewalld_default_zone_target_drop_usr" version="1" check="all" check_existence="at_least_one_exists" comment="Ensure default zone has target DROP in /usr"> | ||
| <ind:object object_ref="object_firewalld_default_zone_target_drop_usr" /> | ||
| </ind:xmlfilecontent_test> | ||
|
|
||
| <ind:xmlfilecontent_object id="object_firewalld_default_zone_target_drop_etc" version="1"> | ||
| <ind:path>/etc/firewalld/zones</ind:path> | ||
| <ind:filename>drop.xml</ind:filename> | ||
| <ind:xpath>/zone[@target='DROP']</ind:xpath> | ||
| </ind:xmlfilecontent_object> | ||
|
|
||
| <ind:xmlfilecontent_object id="object_firewalld_default_zone_target_drop_usr" version="1"> | ||
| <ind:path>/usr/lib/firewalld/zones</ind:path> | ||
| <ind:filename>drop.xml</ind:filename> | ||
| <ind:xpath>/zone[@target='DROP']</ind:xpath> | ||
| </ind:xmlfilecontent_object> | ||
|
|
||
| </def-group> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #!/bin/bash | ||
| # packages = firewalld | ||
| # platform = multi_platform_all | ||
|
|
||
| mkdir -p /etc/firewalld | ||
| if grep -q "^DefaultZone=" /etc/firewalld/firewalld.conf; then | ||
| sed -i 's/^DefaultZone=.*/DefaultZone=drop/' /etc/firewalld/firewalld.conf | ||
| else | ||
| echo "DefaultZone=drop" >> /etc/firewalld/firewalld.conf | ||
| fi |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #!/bin/bash | ||
| # packages = firewalld | ||
| # platform = multi_platform_all | ||
|
|
||
| mkdir -p /etc/firewalld | ||
| if grep -q "^DefaultZone=" /etc/firewalld/firewalld.conf; then | ||
| sed -i 's/^DefaultZone=.*/DefaultZone=public/' /etc/firewalld/firewalld.conf | ||
| else | ||
| echo "DefaultZone=public" >> /etc/firewalld/firewalld.conf | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be way it was before using the FQCN.