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

Initial (sans Arch) auditd management support. #260

Merged
merged 2 commits into from
Mar 26, 2020
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
16 changes: 16 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,19 @@
end
end
# rubocop:enable Metrics/BlockLength

# auditd config
default['os-hardening']['auditd']['flush'] = 'INCREMENTAL'
default['os-hardening']['auditd']['log_group'] = 'root'
default['os-hardening']['auditd']['priority_boost'] = '4'
default['os-hardening']['auditd']['freq'] = '20'
default['os-hardening']['auditd']['num_logs'] = '5'
default['os-hardening']['auditd']['disp_qos'] = 'lossy'
default['os-hardening']['auditd']['dispatcher'] = '/sbin/audispd'
default['os-hardening']['auditd']['name_format'] = 'NONE'
default['os-hardening']['auditd']['max_log_file'] = '6'
default['os-hardening']['auditd']['tcp_listen_queue'] = '5'
default['os-hardening']['auditd']['tcp_max_per_addr'] = '1'
default['os-hardening']['auditd']['tcp_client_max_idle'] = '0'
default['os-hardening']['auditd']['enable_krb5'] = 'no'
default['os-hardening']['auditd']['krb5_principal'] = 'auditd'
40 changes: 40 additions & 0 deletions recipes/auditd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,43 @@
#

package node['os-hardening']['packages']['auditd']

service 'auditd' do
supports %i[start stop restart reload status]
if (node['platform_family'] == 'rhel' && node['platform_version'].to_f >= 7) ||
(node['platform_family'] == 'fedora' && node['platform_version'].to_f >= 27)
restart_command 'service auditd restart'
end
action [:enable]
end

unless node['os-hardening']['auditd']['flush'].match(/^INCREMENTAL|INCREMENTAL_ASYNC$/) ||
node['os-hardening']['auditd']['flush'].empty?
Chef::Log.fatal('If specifying a value for auditd flush parameter, must be one of INCREMENTAL or INCREMENTAL_ASYNC')
raise
end

template '/etc/audit/auditd.conf' do
source 'auditd.conf.erb'
mode '0400'
owner 'root'
group 'root'
variables(
flush: node['os-hardening']['auditd']['flush'],
log_group: node['os-hardening']['auditd']['log_group'],
priority_boost: node['os-hardening']['auditd']['priority_boost'],
freq: node['os-hardening']['auditd']['freq'],
num_logs: node['os-hardening']['auditd']['num_logs'],
disp_qos: node['os-hardening']['auditd']['disp_qos'],
dispatcher: node['os-hardening']['auditd']['dispatcher'],
name_format: node['os-hardening']['auditd']['name_format'],
max_log_file: node['os-hardening']['auditd']['max_log_file'],
tcp_listen_queue: node['os-hardening']['auditd']['tcp_listen_queue'],
tcp_max_per_addr: node['os-hardening']['auditd']['tcp_max_per_addr'],
tcp_client_max_idle: node['os-hardening']['auditd']['tcp_client_max_idle'],
enable_krb5: node['os-hardening']['auditd']['enable_krb5'],
krb5_principal: node['os-hardening']['auditd']['krb5_principal']
)
notifies :restart, 'service[auditd]'
action :create
end
33 changes: 33 additions & 0 deletions templates/default/auditd.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<% node['config_disclaimer'].to_s.split("\n").each do |l| %>
# <%= l %>
<% end %>
#
#--

# Specified by linux-baseline
log_file = /var/log/audit/audit.log
log_format = RAW
flush = <%= @flush %>
max_log_file_action = keep_logs
space_left = 75
action_mail_acct = root
space_left_action = SYSLOG
admin_space_left = 50
admin_space_left_action = SUSPEND
disk_full_action = SUSPEND
disk_error_action = SUSPEND

# Unspecified, auditd defaults unless overwritten
log_group = <%= @log_group %>
priority_boost = <%= @priority_boost %>
freq = <%= @freq %>
num_logs = <%= @num_logs %>
disp_qos = <%= @disp_qos %>
dispatcher = <%= @dispatcher %>
name_format = <%= @name_format %>
max_log_file = <%= @max_log_file %>
tcp_listen_queue = <%= @tcp_listen_queue %>
tcp_max_per_addr = <%= @tcp_max_per_addr %>
tcp_client_max_idle = <%= @tcp_client_max_idle %>
enable_krb5 = <%= @enable_krb5 %>
krb5_principal = <%= @krb5_principal %>
2 changes: 0 additions & 2 deletions test/integration/default/controls/tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
# skip entropy test, as our short living test VMs usually do not
# have enough
skip_control 'os-08'
# skip auditd tests, we do not have any implementation for audit management yet
skip_control 'package-08'
end