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

Include remediation for fapolicy_default_deny rule #11211

Merged
merged 4 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# platform = multi_platform_all
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low

- name: {{{ rule_title }}} - Ensure a Final Rule Denying Everything
ansible.builtin.copy:
content: |
# Red Hat KCS 7003854 (https://access.redhat.com/solutions/7003854)
deny perm=any all : all
dest: /etc/fapolicyd/rules.d/99-deny-everything.rules
owner: root
group: fapolicyd
mode: '0644'
register: result_fapolicyd_final_rule

- name: {{{ rule_title }}} - Ensure fapolicyd is Not Permissive
ansible.builtin.lineinfile:
path: /etc/fapolicyd/fapolicyd.conf
regexp: '^(permissive\s*=).*$'
line: '\1 0'
backrefs: true
register: result_fapolicyd_enforced

- name: "{{{ rule_title }}} - Restart fapolicyd If Permissive Mode or Final Rule is Changed"
ansible.builtin.service:
name: fapolicyd
state: restarted
when:
- result_fapolicyd_final_rule is changed or result_fapolicyd_enforced is changed
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# platform = multi_platform_all
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low

cat > /etc/fapolicyd/rules.d/99-deny-everything.rules << EOF
# Red Hat KCS 7003854 (https://access.redhat.com/solutions/7003854)
deny perm=any all : all
EOF

chmod 644 /etc/fapolicyd/rules.d/99-deny-everything.rules
chgrp fapolicyd /etc/fapolicyd/rules.d/99-deny-everything.rules

{{{ set_config_file(path="/etc/fapolicyd/fapolicyd.conf",
parameter="permissive",
value="0",
create=true,
insensitive=true,
separator=" = ",
separator_regex="\s*=\s*",
prefix_regex="^\s*") }}}

systemctl restart fapolicyd
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/bash
# packages = fapolicyd
# remediation = none

{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf", "permissive", "1", "true") }}}

if [ -f /etc/fapolicyd/compiled.rules ]; then
active_rules_file="/etc/fapolicyd/compiled.rules"
Expand All @@ -11,8 +8,14 @@ else
fi

truncate -s 0 $active_rules_file

echo "allow exe=/usr/bin/python3.7 : ftype=text/x-python" >> $active_rules_file
echo "allow perm=any all : all" >> $active_rules_file

{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf", "permissive", "0", "true") }}}
{{{ set_config_file(path="/etc/fapolicyd/fapolicyd.conf",
parameter="permissive",
value="0",
create=true,
insensitive=true,
separator=" = ",
separator_regex="\s*=\s*",
prefix_regex="^\s*") }}}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/bash
# packages = fapolicyd
# remediation = none

{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf", "permissive", "1", "true") }}}

if [ -f /etc/fapolicyd/compiled.rules ]; then
active_rules_file="/etc/fapolicyd/compiled.rules"
Expand All @@ -11,8 +8,14 @@ else
fi

truncate -s 0 $active_rules_file

echo "allow exe=/usr/bin/python3.7 : ftype=text/x-python" >> $active_rules_file
echo "deny perm=any all : all" >> $active_rules_file

{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf", "permissive", "0", "true") }}}
{{{ set_config_file(path="/etc/fapolicyd/fapolicyd.conf",
parameter="permissive",
value="0",
create=true,
insensitive=true,
separator=" = ",
separator_regex="\s*=\s*",
prefix_regex="^\s*") }}}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/bash
# packages = fapolicyd
# remediation = none

{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf", "permissive", "1", "true") }}}

if [ -f /etc/fapolicyd/compiled.rules ]; then
active_rules_file="/etc/fapolicyd/compiled.rules"
Expand All @@ -11,6 +8,14 @@ else
fi

truncate -s 0 $active_rules_file

echo "allow exe=/usr/bin/python3.7 : ftype=text/x-python" >> $active_rules_file
echo "deny perm=any all : all" >> $active_rules_file

{{{ set_config_file(path="/etc/fapolicyd/fapolicyd.conf",
parameter="permissive",
value="1",
create=true,
insensitive=true,
separator=" = ",
separator_regex="\s*=\s*",
prefix_regex="^\s*") }}}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/bash
# packages = fapolicyd
# remediation = none

{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf", "permissive", "1", "true") }}}

if [ -f /etc/fapolicyd/compiled.rules ]; then
active_rules_file="/etc/fapolicyd/compiled.rules"
Expand All @@ -11,8 +8,14 @@ else
fi

truncate -s 0 $active_rules_file

echo "allow exe=/usr/bin/python3.7 : ftype=text/x-python" >> $active_rules_file
echo "# deny perm=any all : all" >> $active_rules_file

{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf", "permissive", "0", "true") }}}
{{{ set_config_file(path="/etc/fapolicyd/fapolicyd.conf",
parameter="permissive",
value="0",
create=true,
insensitive=true,
separator=" = ",
separator_regex="\s*=\s*",
prefix_regex="^\s*") }}}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/bash
# packages = fapolicyd
# remediation = none

{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf", "permissive", "1", "true") }}}

if [ -f /etc/fapolicyd/compiled.rules ]; then
active_rules_file="/etc/fapolicyd/compiled.rules"
Expand All @@ -11,8 +8,14 @@ else
fi

truncate -s 0 $active_rules_file

echo "deny perm=any all : all" >> $active_rules_file
echo "allow exe=/usr/bin/python3.7 : ftype=text/x-python" >> $active_rules_file

{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf", "permissive", "0", "true") }}}
{{{ set_config_file(path="/etc/fapolicyd/fapolicyd.conf",
parameter="permissive",
value="0",
create=true,
insensitive=true,
separator=" = ",
separator_regex="\s*=\s*",
prefix_regex="^\s*") }}}
Loading