Skip to content

Use bash_package_* #10557

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

Merged
merged 14 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
@@ -1,4 +1,5 @@
#!/bin/bash
# packages = crontabs

FILE=/etc/cron.deny

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
# packages = crontabs

touch /etc/cron.deny
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#
# packages = crontabs

rm -f /etc/cron.allow
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# profiles = xccdf_org.ssgproject.content_profile_stig

yum remove -y ntp
{{{ bash_package_remove("ntp") }}}

# Remove all pool options
sed -i "/^pool.*/d" {{{ chrony_conf_path }}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# profiles = xccdf_org.ssgproject.content_profile_stig

yum remove -y ntp
{{{ bash_package_remove("ntp") }}}

# Remove all pool and server options
sed -i "/^pool.*/d" {{{ chrony_conf_path }}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
# profiles = xccdf_org.ssgproject.content_profile_stig
# platform = Oracle Linux 7,Red Hat Enterprise Linux 7

yum remove -y ntp
{{{ bash_package_remove("ntp") }}}

systemctl enable chronyd.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# profiles = xccdf_org.ssgproject.content_profile_stig

yum remove -y ntp
{{{ bash_package_remove("ntp") }}}

# Remove all server or pool options
sed -i "/^\(server\|pool\).*/d" {{{ chrony_conf_path }}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# profiles = xccdf_org.ssgproject.content_profile_stig

yum remove -y ntp
{{{ bash_package_remove("ntp") }}}

# Remove all server or pool options
sed -i "/^\(server\|pool\).*/d" {{{ chrony_conf_path }}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# profiles = xccdf_org.ssgproject.content_profile_stig

yum remove -y ntp
{{{ bash_package_remove("ntp") }}}

# Remove all server options
sed -i "/^\(server\|pool\).*/d" {{{ chrony_conf_path }}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# profiles = xccdf_org.ssgproject.content_profile_stig

yum remove -y ntp
{{{ bash_package_remove("ntp") }}}

# Remove all pool options
sed -i "/^pool.*/d" {{{ chrony_conf_path }}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# profiles = xccdf_org.ssgproject.content_profile_stig
# platform = Oracle Linux 7,Red Hat Enterprise Linux 7

yum remove -y chrony
{{{ bash_package_remove("chrony") }}}

if ! grep "^server.*maxpoll 10" /etc/ntp.conf; then
sed -i "s/^server.*/& maxpoll 10/" /etc/ntp.conf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# profiles = xccdf_org.ssgproject.content_profile_stig
# platform = Oracle Linux 7,Red Hat Enterprise Linux 7

yum remove -y chrony
{{{ bash_package_remove("chrony") }}}

sed -i "s/^server.*/& maxpoll 17/" /etc/ntp.conf
echo "server 0.test.ntp.org maxpoll 17 iburst" >> /etc/ntp.conf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# profiles = xccdf_org.ssgproject.content_profile_stig
# platform = Oracle Linux 7,Red Hat Enterprise Linux 7

yum remove -y chrony
{{{ bash_package_remove("chrony") }}}

sed -i "s/^server.*/& maxpoll 17/" /etc/ntp.conf

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
# packages = net-snmp

yum -y install net-snmp
rm -f /etc/snmp/snmpd.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

yum -y remove net-snmp
{{{ bash_package_remove("net-snmp") }}}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# platform = Red Hat Enterprise Linux 7,Red Hat Enterprise Linux 8,multi_platform_ol,multi_platform_sle

# Install required packages
if ! rpm --quiet -q pam_pkcs11; then yum -y -d 1 install pam_pkcs11; fi
{{{ bash_package_install("pam_pkcs11") }}}

if grep "^\s*cert_policy" /etc/pam_pkcs11/pam_pkcs11.conf | grep -qv "ocsp_on"; then
sed -i "/^\s*#/! s/cert_policy.*/cert_policy = ca, ocsp_on, signature;/g" /etc/pam_pkcs11/pam_pkcs11.conf
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# packages = audit
# packages = audit,crontabs
# remediation = none

mkdir -p /etc/cron.weekly/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# packages = audit
# packages = audit,crontabs
# remediation = none

mkdir -p /etc/cron.weekly/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
# platform = multi_platform_fedora,Oracle Linux 8,Oracle Linux 9,Red Hat Enterprise Linux 8,Red Hat Enterprise Linux 9

yum remove -y bind || true
{{{ bash_package_remove("bind") }}}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
# platform = multi_platform_fedora,Oracle Linux 8,Oracle Linux 9,Red Hat Enterprise Linux 8,Red Hat Enterprise Linux 9

yum remove -y libreswan || true
{{{ bash_package_remove("libreswan") }}}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{{% if 'rhel' not in product and 'ubuntu' not in product and product != 'ol8' %}}
<ind:subexpression operation="equals">p+i+n+u+g+s+b+acl+selinux+xattrs+sha512</ind:subexpression>
{{% else %}}
<ind:subexpression operation="pattern match">p\+i\+n\+u\+g\+s\+b\+acl(|\+selinux)\+xattrs\+sha512</ind:subexpression>
<ind:subexpression operation="pattern match">^p\+i\+n\+u\+g\+s\+b\+acl(|\+selinux)\+xattrs\+sha512$</ind:subexpression>
{{% endif %}}
</ind:textfilecontent54_state>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/bin/bash
# platform = multi_platform_fedora,multi_platform_ol,multi_platform_rhel
# packages = aide


yum -y install aide
aide --init


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/bin/bash
# platform = multi_platform_fedora,multi_platform_ol,multi_platform_rhel

yum -y install aide
# packages = aide

declare -a bins
bins=('/usr/sbin/auditctl' '/usr/sbin/auditd' '/usr/sbin/augenrules' '/usr/sbin/aureport' '/usr/sbin/ausearch' '/usr/sbin/autrace' '/usr/sbin/rsyslogd')

for theFile in "${bins[@]}"
do
echo "$theFile p+i+n+u+g+s+b+acl+selinux+xattrs+sha5122" >> /etc/aide.conf
echo "$theFile p+i+n+u+g+s+b+acl+selinux+xattrs+sha512" >> /etc/aide.conf
done
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
# platform = multi_platform_fedora,multi_platform_ol,multi_platform_rhel
# packages = aide

declare -a bins
bins=('/usr/sbin/auditctl' '/usr/sbin/auditd' '/usr/sbin/augenrules' '/usr/sbin/aureport' '/usr/sbin/ausearch' '/usr/sbin/autrace' '/usr/sbin/rsyslogd')

for theFile in "${bins[@]}"
do
echo "$theFile p+i+n+u+g+s+b+acl+selinux+xattrs+sha5122" >> /etc/aide.conf
done
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/bin/bash
# platform = multi_platform_fedora,multi_platform_ol,multi_platform_rhel
# packages = aide


yum -y install aide
aide --init

declare -a bins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
# disruption = low
- name: "Ensure AIDE is installed"
package:
name: "{{ item }}"
name:
- aide
- crontabs
state: present
with_items:
- aide

- name: Set cron package name - RedHat
set_fact:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# platform = Red Hat Virtualization 4,multi_platform_fedora,multi_platform_ol,multi_platform_rhel,multi_platform_sle

{{{ bash_package_install("aide") }}}
{{{ bash_package_install("crontabs") }}}

if ! grep -q "{{{ aide_bin_path }}} --check" /etc/crontab ; then
echo "05 4 * * * root {{{ aide_bin_path }}} --check" >> /etc/crontab
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# platform = multi_platform_ubuntu

{{{ bash_package_install("aide") }}}
{{{ bash_package_install("crontabs") }}}

# AiDE usually adds its own cron jobs to /etc/cron.daily. If script is there, this rule is
# compliant. Otherwise, we copy the script to the /etc/cron.weekly
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/bin/bash
# packages = aide,crontabs

if command -v yum; then
yum remove -y aide
elif command -v apt-get; then
DEBIAN_FRONTEND=noninteractive apt-get remove -y aide
fi
{{{ bash_package_remove("aide") }}}

echo '21 21 * * * root /usr/sbin/aide --check &>/dev/null' >> /etc/crontab
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash
#
# packages = aide
# packages = aide,crontabs

mkdir -p /etc/cron.daily
echo "/usr/sbin/aide --check" > /etc/cron.daily/aide
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash
#
# packages = aide
# packages = aide,crontabs

# This TS is a regression test for https://bugzilla.redhat.com/show_bug.cgi?id=2175684

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash
#
# packages = aide
# packages = aide,crontabs

echo '21 21 * * * root /usr/sbin/aide --check &>/dev/null' >> /etc/crontab
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash
#
# packages = aide
# packages = aide,crontabs

echo '@daily root /usr/sbin/aide --check &>/dev/null' >> /etc/crontab
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash
#
# packages = aide
# packages = aide,crontabs

# aide installs automatically a file that is periodically run on /etc/cron.daily/aide
rm -f /etc/cron.daily/aide
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash
#
# packages = aide
# packages = aide,crontabs

echo '21 21 * * 1-2 root /usr/sbin/aide --check &>/dev/null' >> /etc/crontab
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash
#
# packages = aide
# packages = aide,crontabs

echo '21 21 * * 3 root /usr/sbin/aide --check &>/dev/null' >> /etc/crontab
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash
#
# packages = aide
# packages = aide,crontabs

echo '@weekly root /usr/sbin/aide --check &>/dev/null' >> /etc/crontab
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash
#
# packages = aide
# packages = aide,crontabs

echo '21 21 * * mon root /usr/sbin/aide --check &>/dev/null' >> /etc/crontab
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash
#
# packages = aide
# packages = aide,crontabs

# aide installs automatically a file that is periodically run on /etc/cron.daily/aide
rm -f /etc/cron.daily/aide
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash
#
# packages = aide
# packages = aide,crontabs,cronie

# aide installs automatically a file that is periodically run on /etc/cron.daily/aide
rm -f /etc/cron.daily/aide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

- name: "Ensure AIDE is installed"
package:
name: "{{ item }}"
name:
- aide
- crontabs
state: present
with_items:
- aide

- name: "{{{ rule_title }}}"
cron:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# platform = multi_platform_all

{{{ bash_package_install("aide") }}}
{{{ bash_package_install("crontabs") }}}
{{{ bash_instantiate_variables("var_aide_scan_notification_email") }}}

CRONTAB=/etc/crontab
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# packages = aide
# packages = aide,crontabs

# configured in crontab
echo '0 5 * * * root /usr/sbin/aide --check | /bin/mail -s "SSG Test Suite - AIDE Integrity Check" admin@ssgtestsuite' > /etc/cron.weekly/aidescan
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# packages = aide
# packages = aide,crontabs

# configured in crontab
echo '0 5 * * * root /usr/sbin/aide --check | /bin/mail -s "SSG Test Suite - AIDE Integrity Check" admin@ssgtestsuite' >> /etc/crontab
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# packages = aide
# packages = aide,crontabs

# configured in crontab
echo '0 5 * * * root /usr/sbin/aide --check' >> /etc/crontab
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# packages = aide
# packages = aide,cronie

# configured in crontab
echo '0 5 * * * root /usr/sbin/aide --check | /bin/mail -s "SSG Test Suite - AIDE Integrity Check" admin@ssgtestsuite' >> /var/spool/cron/root