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

Fixes #225 : Option to configure audit rules from this module itself #226

Merged
merged 7 commits into from
Mar 20, 2020
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
17 changes: 11 additions & 6 deletions manifests/agent.pp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@
$ossec_syscheck_skip_nfs = $wazuh::params_agent::ossec_syscheck_skip_nfs,
$ossec_syscheck_windows_audit_interval = $wazuh::params_agent::windows_audit_interval,

# Audit
$audit_manage_rules = $wazuh::params_agent::audit_manage_rules,
$audit_buffer_bytes = $wazuh::params_agent::audit_buffer_bytes,
$audit_backlog_wait_time = $wazuh::params_agent::audit_backlog_wait_time,
$audit_rules = $wazuh::params_agent::audit_rules,

# active-response
$ossec_active_response_disabled = $wazuh::params_agent::active_response_disabled,
$ossec_active_response_linux_ca_store = $wazuh::params_agent::active_response_linux_ca_store,
Expand Down Expand Up @@ -208,12 +214,11 @@
validate_string($agent_service_name)

if (( $ossec_syscheck_whodata_directories_1 == 'yes' ) or ( $ossec_syscheck_whodata_directories_2 == 'yes' )) {
package { 'Installing Audit...':
name => 'audit',
}
service { 'auditd':
ensure => running,
enable => true,
class { "wazuh::audit":
audit_manage_rules => $audit_manage_rules,
audit_backlog_wait_time => $audit_backlog_wait_time,
audit_buffer_bytes => $audit_buffer_bytes,
audit_rules => $audit_rules,
}
}

Expand Down
41 changes: 41 additions & 0 deletions manifests/audit.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class wazuh::audit (
$audit_manage_rules = false,
$audit_buffer_bytes = "8192",
$audit_backlog_wait_time = "0",
$audit_rules = [],
) {

case $::kernel {
'Linux': {
case $::operatingsystem {
'Debian', 'debian', 'Ubuntu', 'ubuntu': {
package { 'Installing Audit...':
name => 'auditd',
}
}
default: {
package { 'Installing Audit...':
name => 'audit'
}
}
}

service { 'auditd':
ensure => running,
enable => true,
}

if $audit_manage_rules == true {

file { 'Configure audit.rules':
owner => 'root',
group => 'root',
path => '/etc/audit/rules.d/audit.rules',
mode => '0644',
notify => Service['auditd'], ## Restarts the service
content => template('wazuh/audit_rules.erb')
}
}
}
}
}
11 changes: 11 additions & 0 deletions manifests/params_agent.pp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,17 @@
$ossec_syscheck_nodiff = '/etc/ssl/private.key'
$ossec_syscheck_skip_nfs = 'yes'

# Audit
$audit_manage_rules = false
$audit_buffer_bytes = "8192"
$audit_backlog_wait_time = "0"
$audit_rules = [
'-D',
Copy link
Contributor

@rshad rshad Mar 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also removed -D to not delete the already loaded audit rules.

Done in 16619a4

Thank you

"-b ${audit_buffer_bytes}",
"--backlog_wait_time ${audit_backlog_wait_time}",
"-f 1"
]

# active-response
$active_response_linux_ca_store = '/var/ossec/etc/wpk_root.pem'

Expand Down
5 changes: 5 additions & 0 deletions templates/audit_rules.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% if !@audit_rules.empty? -%>
<% @audit_rules.each do |audit_rule| -%>
<%= audit_rule %>
<%- end -%>
<%- end -%>