Merge branch 'jenkins-build-15' into 'master'
Auto-merge for build 15 See merge request puppet/clamav_cd!12
This commit is contained in:
@@ -140,10 +140,10 @@ class clamav_cd::main::config (
|
|||||||
|
|
||||||
# create a cron job to run a daily scan
|
# create a cron job to run a daily scan
|
||||||
cron { 'clamscan':
|
cron { 'clamscan':
|
||||||
command => '/bin/clamscan -r / >> /var/log/clamav/daily-scan.log',
|
command => $cv_shell_script,
|
||||||
user => 'root',
|
user => $cv_cron_user,
|
||||||
hour => 2,
|
hour => $cv_cron_hour,
|
||||||
minute => 0,
|
minute => $cv_cron_minute,
|
||||||
}
|
}
|
||||||
}</pre>
|
}</pre>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -145,7 +145,20 @@
|
|||||||
47
|
47
|
||||||
48
|
48
|
||||||
49
|
49
|
||||||
50</pre>
|
50
|
||||||
|
51
|
||||||
|
52
|
||||||
|
53
|
||||||
|
54
|
||||||
|
55
|
||||||
|
56
|
||||||
|
57
|
||||||
|
58
|
||||||
|
59
|
||||||
|
60
|
||||||
|
61
|
||||||
|
62
|
||||||
|
63</pre>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre class="code"><span class="info file"># File 'manifests/main/files.pp', line 6</span>
|
<pre class="code"><span class="info file"># File 'manifests/main/files.pp', line 6</span>
|
||||||
@@ -194,6 +207,19 @@ class clamav_cd::main::files (
|
|||||||
seluser => system_u,
|
seluser => system_u,
|
||||||
content => template($cv_freshclam_svc_erb),
|
content => template($cv_freshclam_svc_erb),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# shell script for scanning and alerting
|
||||||
|
file { $cv_shell_script :
|
||||||
|
ensure => file,
|
||||||
|
owner => 'root',
|
||||||
|
group => 'root',
|
||||||
|
mode => '0750',
|
||||||
|
selrange => s0,
|
||||||
|
selrole => object_r,
|
||||||
|
seltype => etc_t,
|
||||||
|
seluser => system_u,
|
||||||
|
content => template($cv_shell_script_erb),
|
||||||
|
}
|
||||||
}</pre>
|
}</pre>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ inherited by all classes except defines.
|
|||||||
<span class='type'>(<tt>Array</tt>)</span>
|
<span class='type'>(<tt>Array</tt>)</span>
|
||||||
|
|
||||||
|
|
||||||
<em class="default">(defaults to: <tt>['clamav','clamd']</tt>)</em>
|
<em class="default">(defaults to: <tt>['clamav','clamd','s-nail']</tt>)</em>
|
||||||
|
|
||||||
|
|
||||||
—
|
—
|
||||||
@@ -373,6 +373,114 @@ inherited by all classes except defines.
|
|||||||
—
|
—
|
||||||
<div class='inline'>
|
<div class='inline'>
|
||||||
<p>ip address to listen on</p>
|
<p>ip address to listen on</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<span class='name'>cv_alert_email</span>
|
||||||
|
|
||||||
|
|
||||||
|
<span class='type'>(<tt>String</tt>)</span>
|
||||||
|
|
||||||
|
|
||||||
|
<em class="default">(defaults to: <tt>'you@example.com'</tt>)</em>
|
||||||
|
|
||||||
|
|
||||||
|
—
|
||||||
|
<div class='inline'>
|
||||||
|
<p>email address to send alerts</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<span class='name'>cv_cron_hour</span>
|
||||||
|
|
||||||
|
|
||||||
|
<span class='type'>(<tt>String</tt>)</span>
|
||||||
|
|
||||||
|
|
||||||
|
<em class="default">(defaults to: <tt>'2'</tt>)</em>
|
||||||
|
|
||||||
|
|
||||||
|
—
|
||||||
|
<div class='inline'>
|
||||||
|
<p>which hour the scan should start</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<span class='name'>cv_cron_minute</span>
|
||||||
|
|
||||||
|
|
||||||
|
<span class='type'>(<tt>String</tt>)</span>
|
||||||
|
|
||||||
|
|
||||||
|
<em class="default">(defaults to: <tt>'0'</tt>)</em>
|
||||||
|
|
||||||
|
|
||||||
|
—
|
||||||
|
<div class='inline'>
|
||||||
|
<p>which minute the scan should start</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<span class='name'>cv_cron_user</span>
|
||||||
|
|
||||||
|
|
||||||
|
<span class='type'>(<tt>String</tt>)</span>
|
||||||
|
|
||||||
|
|
||||||
|
<em class="default">(defaults to: <tt>'root'</tt>)</em>
|
||||||
|
|
||||||
|
|
||||||
|
—
|
||||||
|
<div class='inline'>
|
||||||
|
<p>which user should run the cron job</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<span class='name'>cv_scan_dir</span>
|
||||||
|
|
||||||
|
|
||||||
|
<span class='type'>(<tt>String</tt>)</span>
|
||||||
|
|
||||||
|
|
||||||
|
<em class="default">(defaults to: <tt>'/'</tt>)</em>
|
||||||
|
|
||||||
|
|
||||||
|
—
|
||||||
|
<div class='inline'>
|
||||||
|
<p>which directory should be scanned</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<span class='name'>cv_alert_file</span>
|
||||||
|
|
||||||
|
|
||||||
|
<span class='type'>(<tt>String</tt>)</span>
|
||||||
|
|
||||||
|
|
||||||
|
<em class="default">(defaults to: <tt>'tmp/clamav-alert.txt'</tt>)</em>
|
||||||
|
|
||||||
|
|
||||||
|
—
|
||||||
|
<div class='inline'>
|
||||||
|
<p>location and name of the alert file</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
@@ -388,12 +496,6 @@ inherited by all classes except defines.
|
|||||||
<pre class="lines">
|
<pre class="lines">
|
||||||
|
|
||||||
|
|
||||||
31
|
|
||||||
32
|
|
||||||
33
|
|
||||||
34
|
|
||||||
35
|
|
||||||
36
|
|
||||||
37
|
37
|
||||||
38
|
38
|
||||||
39
|
39
|
||||||
@@ -428,15 +530,30 @@ inherited by all classes except defines.
|
|||||||
68
|
68
|
||||||
69
|
69
|
||||||
70
|
70
|
||||||
71</pre>
|
71
|
||||||
|
72
|
||||||
|
73
|
||||||
|
74
|
||||||
|
75
|
||||||
|
76
|
||||||
|
77
|
||||||
|
78
|
||||||
|
79
|
||||||
|
80
|
||||||
|
81
|
||||||
|
82
|
||||||
|
83
|
||||||
|
84
|
||||||
|
85
|
||||||
|
86</pre>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre class="code"><span class="info file"># File 'manifests/params.pp', line 31</span>
|
<pre class="code"><span class="info file"># File 'manifests/params.pp', line 37</span>
|
||||||
|
|
||||||
class clamav_cd::params (
|
class clamav_cd::params (
|
||||||
|
|
||||||
# installation
|
# installation
|
||||||
Array $reqpackages = ['clamav','clamd'],
|
Array $reqpackages = ['clamav','clamd','s-nail'],
|
||||||
String $pkg_ensure = 'present',
|
String $pkg_ensure = 'present',
|
||||||
|
|
||||||
# clamd
|
# clamd
|
||||||
@@ -453,6 +570,13 @@ class clamav_cd::params (
|
|||||||
String $cv_preludeanalyzername = 'ClamAV',
|
String $cv_preludeanalyzername = 'ClamAV',
|
||||||
String $cv_tcpsocket = '3310',
|
String $cv_tcpsocket = '3310',
|
||||||
String $cv_tcpaddress = 'localhost',
|
String $cv_tcpaddress = 'localhost',
|
||||||
|
String $cv_alert_email = 'you@example.com',
|
||||||
|
String $cv_cron_hour = '2',
|
||||||
|
String $cv_cron_minute = '0',
|
||||||
|
String $cv_cron_user = 'root',
|
||||||
|
String $cv_scan_dir = '/',
|
||||||
|
String $cv_alert_file = 'tmp/clamav-alert.txt',
|
||||||
|
|
||||||
|
|
||||||
) {
|
) {
|
||||||
# service
|
# service
|
||||||
@@ -469,6 +593,8 @@ class clamav_cd::params (
|
|||||||
$cv_freshclam_erb = 'clamav_cd/freshclam_conf.erb'
|
$cv_freshclam_erb = 'clamav_cd/freshclam_conf.erb'
|
||||||
$cv_freshclam_svc = '/usr/lib/systemd/system/freshclam.service'
|
$cv_freshclam_svc = '/usr/lib/systemd/system/freshclam.service'
|
||||||
$cv_freshclam_svc_erb = 'clamav_cd/freshclam_svc.erb'
|
$cv_freshclam_svc_erb = 'clamav_cd/freshclam_svc.erb'
|
||||||
|
$cv_shell_script = "${cv_config_d_dir}/scan.sh"
|
||||||
|
$cv_shell_script_erb = 'clamav_cd/scan.sh.erb'
|
||||||
|
|
||||||
# includes must be last
|
# includes must be last
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ class clamav_cd::main::config (
|
|||||||
|
|
||||||
# create a cron job to run a daily scan
|
# create a cron job to run a daily scan
|
||||||
cron { 'clamscan':
|
cron { 'clamscan':
|
||||||
command => '/bin/clamscan -r / >> /var/log/clamav/daily-scan.log',
|
command => $cv_shell_script,
|
||||||
user => 'root',
|
user => $cv_cron_user,
|
||||||
hour => 2,
|
hour => $cv_cron_hour,
|
||||||
minute => 0,
|
minute => $cv_cron_minute,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,4 +47,17 @@ class clamav_cd::main::files (
|
|||||||
seluser => system_u,
|
seluser => system_u,
|
||||||
content => template($cv_freshclam_svc_erb),
|
content => template($cv_freshclam_svc_erb),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# shell script for scanning and alerting
|
||||||
|
file { $cv_shell_script :
|
||||||
|
ensure => file,
|
||||||
|
owner => 'root',
|
||||||
|
group => 'root',
|
||||||
|
mode => '0750',
|
||||||
|
selrange => s0,
|
||||||
|
selrole => object_r,
|
||||||
|
seltype => etc_t,
|
||||||
|
seluser => system_u,
|
||||||
|
content => template($cv_shell_script_erb),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,11 +27,17 @@
|
|||||||
# prelude-admin.
|
# prelude-admin.
|
||||||
# @param [String] cv_tcpsocket socket port
|
# @param [String] cv_tcpsocket socket port
|
||||||
# @param [String] cv_tcpaddress ip address to listen on
|
# @param [String] cv_tcpaddress ip address to listen on
|
||||||
|
# @param [String] cv_alert_email email address to send alerts
|
||||||
|
# @param [String] cv_cron_hour which hour the scan should start
|
||||||
|
# @param [String] cv_cron_minute which minute the scan should start
|
||||||
|
# @param [String] cv_cron_user which user should run the cron job
|
||||||
|
# @param [String] cv_scan_dir which directory should be scanned
|
||||||
|
# @param [String] cv_alert_file location and name of the alert file
|
||||||
##############################################################################
|
##############################################################################
|
||||||
class clamav_cd::params (
|
class clamav_cd::params (
|
||||||
|
|
||||||
# installation
|
# installation
|
||||||
Array $reqpackages = ['clamav','clamd'],
|
Array $reqpackages = ['clamav','clamd','s-nail'],
|
||||||
String $pkg_ensure = 'present',
|
String $pkg_ensure = 'present',
|
||||||
|
|
||||||
# clamd
|
# clamd
|
||||||
@@ -48,6 +54,13 @@ class clamav_cd::params (
|
|||||||
String $cv_preludeanalyzername = 'ClamAV',
|
String $cv_preludeanalyzername = 'ClamAV',
|
||||||
String $cv_tcpsocket = '3310',
|
String $cv_tcpsocket = '3310',
|
||||||
String $cv_tcpaddress = 'localhost',
|
String $cv_tcpaddress = 'localhost',
|
||||||
|
String $cv_alert_email = 'you@example.com',
|
||||||
|
String $cv_cron_hour = '2',
|
||||||
|
String $cv_cron_minute = '0',
|
||||||
|
String $cv_cron_user = 'root',
|
||||||
|
String $cv_scan_dir = '/',
|
||||||
|
String $cv_alert_file = 'tmp/clamav-alert.txt',
|
||||||
|
|
||||||
|
|
||||||
) {
|
) {
|
||||||
# service
|
# service
|
||||||
@@ -64,6 +77,8 @@ class clamav_cd::params (
|
|||||||
$cv_freshclam_erb = 'clamav_cd/freshclam_conf.erb'
|
$cv_freshclam_erb = 'clamav_cd/freshclam_conf.erb'
|
||||||
$cv_freshclam_svc = '/usr/lib/systemd/system/freshclam.service'
|
$cv_freshclam_svc = '/usr/lib/systemd/system/freshclam.service'
|
||||||
$cv_freshclam_svc_erb = 'clamav_cd/freshclam_svc.erb'
|
$cv_freshclam_svc_erb = 'clamav_cd/freshclam_svc.erb'
|
||||||
|
$cv_shell_script = "${cv_config_d_dir}/scan.sh"
|
||||||
|
$cv_shell_script_erb = 'clamav_cd/scan.sh.erb'
|
||||||
|
|
||||||
# includes must be last
|
# includes must be last
|
||||||
|
|
||||||
|
|||||||
23
templates/scan.sh.erb
Normal file
23
templates/scan.sh.erb
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Set paths
|
||||||
|
SCAN_DIR="<%= @cv_scan_dir %>"
|
||||||
|
LOG_FILE="<%= @cv_logfile %>"
|
||||||
|
TMP_ALERT="<%= @cv_alert_file %>"
|
||||||
|
EMAIL="<%= @cv_alert_email %>"
|
||||||
|
|
||||||
|
# Run clamscan
|
||||||
|
clamscan -r --infected --log="$LOG_FILE" "$SCAN_DIR" > /dev/null
|
||||||
|
|
||||||
|
# Check if infections were found
|
||||||
|
if grep -q "Infected files: [^0]" "$LOG_FILE"; then
|
||||||
|
echo "ClamAV has found infected files on $(hostname)!" > "$TMP_ALERT"
|
||||||
|
echo "" >> "$TMP_ALERT"
|
||||||
|
grep "FOUND" "$LOG_FILE" >> "$TMP_ALERT"
|
||||||
|
|
||||||
|
# Send the alert email
|
||||||
|
mail -s "⚠️ ClamAV Alert on $(hostname)" "$EMAIL" < "$TMP_ALERT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -f "$TMP_ALERT"
|
||||||
Reference in New Issue
Block a user