Compare commits
3 Commits
ce83e4bbab
...
0d26003492
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d26003492 | ||
| 0b24fcdb8e | |||
|
|
b600b953ec |
57
.vscode/settings.json
vendored
57
.vscode/settings.json
vendored
@@ -1,57 +0,0 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"ALLMATCHSCAN",
|
||||
"authenticode",
|
||||
"behaviour",
|
||||
"bofh",
|
||||
"clamav",
|
||||
"clamd",
|
||||
"clamdscan",
|
||||
"clamonacc",
|
||||
"clamscan",
|
||||
"Clamuko",
|
||||
"clamupdate",
|
||||
"Dazuko",
|
||||
"dbname",
|
||||
"epel",
|
||||
"excludepaths",
|
||||
"fanotify",
|
||||
"filesize",
|
||||
"freshclam",
|
||||
"getsebool",
|
||||
"INADDR",
|
||||
"kubelet",
|
||||
"libclamav",
|
||||
"logclean",
|
||||
"logfacility",
|
||||
"logfile",
|
||||
"logfilemaxsize",
|
||||
"logfileunlock",
|
||||
"logrotation",
|
||||
"logsyslog",
|
||||
"logtime",
|
||||
"logverbose",
|
||||
"mypass",
|
||||
"myproxy",
|
||||
"myusername",
|
||||
"NOFILE",
|
||||
"normalisation",
|
||||
"PCRE",
|
||||
"preludeanalyzername",
|
||||
"preludeenable",
|
||||
"recieve",
|
||||
"RLIMIT",
|
||||
"safebrowsing",
|
||||
"setsebool",
|
||||
"subsig",
|
||||
"subsigs",
|
||||
"tcpaddre",
|
||||
"tcpaddress",
|
||||
"tcpsocket",
|
||||
"VIRUSEVENT",
|
||||
"virusgroup",
|
||||
"VIRUSNAME",
|
||||
"XMLDOCS",
|
||||
"xxxyyzzzz"
|
||||
]
|
||||
}
|
||||
128
Jenkinsfile
vendored
128
Jenkinsfile
vendored
@@ -1,128 +0,0 @@
|
||||
pipeline {
|
||||
agent {
|
||||
label 'puppet'
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
deleteDir() /* clean up our workspace */
|
||||
}
|
||||
success {
|
||||
updateGitlabCommitStatus state: 'success'
|
||||
}
|
||||
failure {
|
||||
updateGitlabCommitStatus state: 'failed'
|
||||
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'support@confdroid.com', sendToIndividuals: true])
|
||||
}
|
||||
}
|
||||
|
||||
options {
|
||||
gitLabConnection('gitlab.confdroid.com')
|
||||
}
|
||||
|
||||
stages {
|
||||
|
||||
stage('pull master') {
|
||||
steps {
|
||||
sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) {
|
||||
sh '''
|
||||
git config user.name "Jenkins Server"
|
||||
git config user.email jenkins@confdroid.com
|
||||
# Ensure we're on the development branch (triggered by push)
|
||||
git checkout development
|
||||
# Create jenkins branch from development
|
||||
git checkout -b jenkins-build-$BUILD_NUMBER
|
||||
# Optionally merge master into jenkins to ensure compatibility
|
||||
git merge origin/master --no-ff || { echo "Merge conflict detected"; exit 1; }
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('puppet parser') {
|
||||
steps {
|
||||
sh '''for file in $(find . -iname \'*.pp\'); do
|
||||
/opt/puppetlabs/bin/puppet parser validate --color false --render-as s --modulepath=modules $file || exit 1;
|
||||
done;'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('check templates') {
|
||||
steps{
|
||||
sh '''for file in $(find . -iname \'*.erb\');
|
||||
do erb -P -x -T "-" $file | ruby -c || exit 1;
|
||||
done;'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('puppet-lint') {
|
||||
steps {
|
||||
sh '''/usr/local/bin/puppet-lint . \\
|
||||
--no-variable_scope-check \\
|
||||
|| { echo "Puppet lint failed"; exit 1; }
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('SonarScan') {
|
||||
steps {
|
||||
withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_TOKEN')]) {
|
||||
sh '''
|
||||
/opt/sonar-scanner/bin/sonar-scanner \
|
||||
-Dsonar.projectKey=confdroid_clamav \
|
||||
-Dsonar.sources=. \
|
||||
-Dsonar.host.url=https://sonarqube.confdroid.com \
|
||||
-Dsonar.token=$SONAR_TOKEN
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('create Puppet documentation') {
|
||||
steps {
|
||||
sh '/opt/puppetlabs/bin/puppet strings'
|
||||
}
|
||||
}
|
||||
|
||||
stage('update repo') {
|
||||
steps {
|
||||
sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) {
|
||||
sh '''
|
||||
git config user.name "Jenkins Server"
|
||||
git config user.email jenkins@confdroid.com
|
||||
git rm -r --cached .vscode || echo "No .vscode to remove from git"
|
||||
git add -A && git commit -am "Recommit for updates in build $BUILD_NUMBER" || echo "No changes to commit"
|
||||
git push origin HEAD:master
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Mirror to Gitea') {
|
||||
steps {
|
||||
sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) {
|
||||
withCredentials([usernamePassword(
|
||||
credentialsId: 'Jenkins-gitea',
|
||||
usernameVariable: 'GITEA_USER',
|
||||
passwordVariable: 'GITEA_TOKEN')]) {
|
||||
script {
|
||||
// Checkout from GitLab (already done implicitly)
|
||||
sh '''
|
||||
git checkout master
|
||||
git pull origin master
|
||||
git branch -D development
|
||||
git branch -D jenkins-build-$BUILD_NUMBER
|
||||
git rm -f Jenkinsfile
|
||||
git rm -r --cached .vscode || echo "No .vscode to remove from git"
|
||||
git commit --amend --no-edit --allow-empty
|
||||
git remote add master https://sourcecode.confdroid.com/confdroid/confdroid_clamav.git
|
||||
git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \
|
||||
push master --mirror
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,9 +71,8 @@
|
||||
<p><a href="#features">Features</a></p>
|
||||
</li><li>
|
||||
<p><a href="#dependencies">Dependencies</a></p>
|
||||
<ul><li>
|
||||
</li><li>
|
||||
<p><a href="#deployment">Deployment</a></p>
|
||||
</li></ul>
|
||||
</li><li>
|
||||
<p><a href="#parameters">Parameters</a></p>
|
||||
</li><li>
|
||||
@@ -118,7 +117,7 @@
|
||||
<p><a href="https://sourcecode.confdroid.com/confdroid/confdroid_resources">confdroid_resources</a> for managing yum repo resources.</p>
|
||||
</li></ul>
|
||||
|
||||
<h3 id="label-Deployment">Deployment</h3>
|
||||
<h2 id="label-Deployment">Deployment</h2>
|
||||
<ul><li>
|
||||
<p>native Puppet deployment</p>
|
||||
</li></ul>
|
||||
|
||||
@@ -71,9 +71,8 @@
|
||||
<p><a href="#features">Features</a></p>
|
||||
</li><li>
|
||||
<p><a href="#dependencies">Dependencies</a></p>
|
||||
<ul><li>
|
||||
</li><li>
|
||||
<p><a href="#deployment">Deployment</a></p>
|
||||
</li></ul>
|
||||
</li><li>
|
||||
<p><a href="#parameters">Parameters</a></p>
|
||||
</li><li>
|
||||
@@ -118,7 +117,7 @@
|
||||
<p><a href="https://sourcecode.confdroid.com/confdroid/confdroid_resources">confdroid_resources</a> for managing yum repo resources.</p>
|
||||
</li></ul>
|
||||
|
||||
<h3 id="label-Deployment">Deployment</h3>
|
||||
<h2 id="label-Deployment">Deployment</h2>
|
||||
<ul><li>
|
||||
<p>native Puppet deployment</p>
|
||||
</li></ul>
|
||||
|
||||
@@ -120,8 +120,8 @@ class confdroid_clamav::main::install (
|
||||
) inherits confdroid_clamav::params {
|
||||
require confdroid_resources::main::epel
|
||||
|
||||
package { $reqpackages:
|
||||
ensure => $pkg_ensure,
|
||||
package { $cv_reqpackages:
|
||||
ensure => $cv_pkg_ensure,
|
||||
}
|
||||
}</pre>
|
||||
</td>
|
||||
|
||||
@@ -109,7 +109,7 @@ inherited by all classes except defines.
|
||||
|
||||
<li>
|
||||
|
||||
<span class='name'>reqpackages</span>
|
||||
<span class='name'>cv_reqpackages</span>
|
||||
|
||||
|
||||
<span class='type'>(<tt>Array</tt>)</span>
|
||||
@@ -127,7 +127,7 @@ inherited by all classes except defines.
|
||||
|
||||
<li>
|
||||
|
||||
<span class='name'>pkg_ensure</span>
|
||||
<span class='name'>cv_pkg_ensure</span>
|
||||
|
||||
|
||||
<span class='type'>(<tt>String</tt>)</span>
|
||||
@@ -517,6 +517,24 @@ inherited by all classes except defines.
|
||||
—
|
||||
<div class='inline'>
|
||||
<p>whether to enable the clamd service</p>
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
|
||||
<span class='name'>cv_use_excludepaths</span>
|
||||
|
||||
|
||||
<span class='type'>(<tt>Boolean</tt>)</span>
|
||||
|
||||
|
||||
<em class="default">(defaults to: <tt>true</tt>)</em>
|
||||
|
||||
|
||||
—
|
||||
<div class='inline'>
|
||||
<p>whether to use advanced exclude paths</p>
|
||||
</div>
|
||||
|
||||
</li>
|
||||
@@ -532,7 +550,6 @@ inherited by all classes except defines.
|
||||
<pre class="lines">
|
||||
|
||||
|
||||
39
|
||||
40
|
||||
41
|
||||
42
|
||||
@@ -582,16 +599,18 @@ inherited by all classes except defines.
|
||||
86
|
||||
87
|
||||
88
|
||||
89</pre>
|
||||
89
|
||||
90
|
||||
91</pre>
|
||||
</td>
|
||||
<td>
|
||||
<pre class="code"><span class="info file"># File 'manifests/params.pp', line 39</span>
|
||||
<pre class="code"><span class="info file"># File 'manifests/params.pp', line 40</span>
|
||||
|
||||
class confdroid_clamav::params (
|
||||
|
||||
# installation
|
||||
Array $reqpackages = ['clamav','clamd','s-nail'],
|
||||
String $pkg_ensure = 'present',
|
||||
Array $cv_reqpackages = ['clamav','clamd','s-nail'],
|
||||
String $cv_pkg_ensure = 'present',
|
||||
|
||||
# clamd
|
||||
String $cv_logfile = '/var/log/clamd.scan',
|
||||
@@ -615,6 +634,7 @@ class confdroid_clamav::params (
|
||||
String $cv_alert_file = 'tmp/clamav-alert.txt',
|
||||
Boolean $cv_enable_freshclam = true,
|
||||
Boolean $cv_enable_clamd = true,
|
||||
Boolean $cv_use_excludepaths = true
|
||||
|
||||
) {
|
||||
# service
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# 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
|
||||
# Ensure the log directory exists
|
||||
mkdir -p "$(dirname "$LOG_FILE")"
|
||||
|
||||
# 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"
|
||||
# Preferred: clamdscan with multiscan + fdpass
|
||||
clamdscan --multiscan --fdpass --infected --log="$LOG_FILE" "$SCAN_DIR" > /dev/null || true
|
||||
|
||||
# Check for infections (same logic as before)
|
||||
if grep -q "Infected files: [^0]" "$LOG_FILE" 2>/dev/null; then
|
||||
{
|
||||
echo "ClamAV has found infected files on $(hostname)!"
|
||||
echo ""
|
||||
grep "FOUND" "$LOG_FILE" || true
|
||||
} > "$TMP_ALERT"
|
||||
|
||||
# Send the alert email
|
||||
mail -s "⚠️ ClamAV Alert on $(hostname)" "$EMAIL" < "$TMP_ALERT"
|
||||
fi
|
||||
|
||||
# Clean up
|
||||
rm -f "$TMP_ALERT"
|
||||
rm -f "$TMP_ALERT"
|
||||
Reference in New Issue
Block a user