-
Notifications
You must be signed in to change notification settings - Fork 817
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
Open
pradeepkch6-ai
wants to merge
9
commits into
ComplianceAsCode:master
Choose a base branch
from
pradeepkch6-ai:feature/firewalld-default-deny-implementation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ae5a708
Implement firewalld default deny remediations and checks
pradeepkch6-ai 2b805db
Fix OVAL definition ID to use rule_id macro
pradeepkch6-ai 6a1839b
Fix OVAL test schema, Ansible linting, and CRLF line endings
pradeepkch6-ai 00b6afc
Fix bash macro regex key to pass contest-oscap tests
pradeepkch6-ai 7955be0
Simplify OVAL rule to strictly evaluate drop zone and prevent variabl…
pradeepkch6-ai d1de3c8
Fix Ansible legacy syntax and ensure firewalld directory exists in tests
pradeepkch6-ai da31ce5
Change OVAL check_existence to at_least_one_exists to prevent OpenSCA…
pradeepkch6-ai 6998838
Fix test scripts printing to STDERR on missing config file, which cra…
pradeepkch6-ai 63b7ed2
Fix OVAL checking missing state and update pass scripts
pradeepkch6-ai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
...work-firewalld/ruleset_modifications/configured_firewalld_default_deny/ansible/shared.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
||
7 changes: 7 additions & 0 deletions
7
.../network-firewalld/ruleset_modifications/configured_firewalld_default_deny/bash/shared.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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') }}} |
48 changes: 48 additions & 0 deletions
48
...network-firewalld/ruleset_modifications/configured_firewalld_default_deny/oval/shared.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| <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:state state_ref="state_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:textfilecontent54_state id="state_firewalld_default_zone_drop" version="1"> | ||
| <ind:text datatype="string" operation="pattern match">^DefaultZone=drop$</ind:text> | ||
| </ind:textfilecontent54_state> | ||
|
|
||
| <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" /> | ||
| </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> |
20 changes: 20 additions & 0 deletions
20
...k-firewalld/ruleset_modifications/configured_firewalld_default_deny/tests/correct.pass.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #!/bin/bash | ||
| # packages = firewalld | ||
| # platform = multi_platform_all | ||
|
|
||
| mkdir -p /etc/firewalld/zones | ||
| touch /etc/firewalld/firewalld.conf | ||
| 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 | ||
|
|
||
| cat << EOF > /etc/firewalld/zones/drop.xml | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <zone target="DROP"> | ||
| <short>Drop</short> | ||
| <description>Unsolicited incoming network packets are dropped.</description> | ||
| </zone> | ||
| EOF | ||
|
|
11 changes: 11 additions & 0 deletions
11
...irewalld/ruleset_modifications/configured_firewalld_default_deny/tests/wrong_zone.fail.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #!/bin/bash | ||
| # packages = firewalld | ||
| # platform = multi_platform_all | ||
|
|
||
| mkdir -p /etc/firewalld/zones | ||
| touch /etc/firewalld/firewalld.conf | ||
| 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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.