Debian Codegraph @

dist/packer/scripts/99-img_check.sh

raw symbols SCIP
1 #!/bin/bash
2 #
3 # DigitalOcean Marketplace Image Validation Tool
4 # © 2018 DigitalOcean LLC.
5 # This code is licensed under MIT license (see LICENSE.txt for details)
6 #
7 VERSION="v. 1.5"
8 RUNDATE=$( date )
9
10 # Script should be run with SUDO
11 if [ "$EUID" -ne 0 ]
12 then echo "[Error] - This script must be run with sudo or as the root user."
13 exit 1
14 fi
15
16 STATUS=0
17 PASS=0
18 WARN=0
19 FAIL=0
20
21 # $1 == command to check for
22 # returns: 0 == true, 1 == false
23 cmdExists() {
24 if command -v "$1" > /dev/null 2>&1; then
25 return 0
26 else
27 return 1
28 fi
29 }
30
31 function getDistro {
32 if [ -f /etc/os-release ]; then
33 # freedesktop.org and systemd
34 . /etc/os-release
35 OS=$NAME
36 VER=$VERSION_ID
37 elif type lsb_release >/dev/null 2>&1; then
38 # linuxbase.org
39 OS=$(lsb_release -si)
40 VER=$(lsb_release -sr)
41 elif [ -f /etc/lsb-release ]; then
42 # For some versions of Debian/Ubuntu without lsb_release command
43 . /etc/lsb-release
44 OS=$DISTRIB_ID
45 VER=$DISTRIB_RELEASE
46 elif [ -f /etc/debian_version ]; then
47 # Older Debian/Ubuntu/etc.
48 OS=Debian
49 VER=$(cat /etc/debian_version)
50 elif [ -f /etc/SuSe-release ]; then
51 # Older SuSE/etc.
52 :
53 elif [ -f /etc/redhat-release ]; then
54 # Older Red Hat, CentOS, etc.
55 VER=$( cat /etc/redhat-release | cut -d" " -f3 | cut -d "." -f1)
56 d=$( cat /etc/redhat-release | cut -d" " -f1 | cut -d "." -f1)
57 if [[ $d == "CentOS" ]]; then
58 OS="CentOS Linux"
59 fi
60 else
61 # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
62 OS=$(uname -s)
63 VER=$(uname -r)
64 fi
65 }
66 function loadPasswords {
67 SHADOW=$(cat /etc/shadow)
68 }
69
70 function checkAgent {
71 # Check for the presence of the do-agent in the filesystem
72 if [ -d /var/opt/digitalocean/do-agent ];then
73 echo -en "\e[41m[FAIL]\e[0m DigitalOcean Monitoring Agent detected.\n"
74 ((FAIL++))
75 STATUS=2
76 if [[ $OS == "CentOS Linux" ]]; then
77 echo "The agent can be removed with 'sudo yum remove do-agent' "
78 elif [[ $OS == "Ubuntu" ]]; then
79 echo "The agent can be removed with 'sudo apt-get purge do-agent' "
80 fi
81 else
82 echo -en "\e[32m[PASS]\e[0m DigitalOcean Monitoring agent was not found\n"
83 ((PASS++))
84 fi
85 }
86
87 function checkLogs {
88 cp_ignore="/var/log/cpanel-install.log"
89 echo -en "\nChecking for log files in /var/log\n\n"
90 # Check if there are log archives or log files that have not been recently cleared.
91 for f in /var/log/*-????????; do
92 [[ -e $f ]] || break
93 if [ $f != $cp_ignore ]; then
94 echo -en "\e[93m[WARN]\e[0m Log archive ${f} found\n"
95 ((WARN++))
96 if [[ $STATUS != 2 ]]; then
97 STATUS=1
98 fi
99 fi
100 done
101 for f in /var/log/*.[0-9];do
102 [[ -e $f ]] || break
103 echo -en "\e[93m[WARN]\e[0m Log archive ${f} found\n"
104 ((WARN++))
105 if [[ $STATUS != 2 ]]; then
106 STATUS=1
107 fi
108 done
109 for f in /var/log/*.log; do
110 [[ -e $f ]] || break
111 if [[ "${f}" = '/var/log/lfd.log' && "$( cat "${f}" | egrep -v '/var/log/messages has been reset| Watching /var/log/messages' | wc -c)" -gt 50 ]]; then
112 if [ $f != $cp_ignore ]; then
113 echo -en "\e[93m[WARN]\e[0m un-cleared log file, ${f} found\n"
114 ((WARN++))
115 if [[ $STATUS != 2 ]]; then
116 STATUS=1
117 fi
118 fi
119 elif [[ "${f}" != '/var/log/lfd.log' && "$( cat "${f}" | wc -c)" -gt 50 ]]; then
120 if [ $f != $cp_ignore ]; then
121 echo -en "\e[93m[WARN]\e[0m un-cleared log file, ${f} found\n"
122 ((WARN++))
123 if [[ $STATUS != 2 ]]; then
124 STATUS=1
125 fi
126 fi
127 fi
128 done
129 }
130 function checkTMP {
131 # Check the /tmp directory to ensure it is empty. Warn on any files found.
132 return 1
133 }
134 function checkRoot {
135 user="root"
136 uhome="/root"
137 for usr in $SHADOW
138 do
139 IFS=':' read -r -a u <<< "$usr"
140 if [[ "${u[0]}" == "${user}" ]]; then
141 if [[ ${u[1]} == "!" ]] || [[ ${u[1]} == "!!" ]] || [[ ${u[1]} == "*" ]]; then
142 echo -en "\e[32m[PASS]\e[0m User ${user} has no password set.\n"
143 ((PASS++))
144 else
145 echo -en "\e[41m[FAIL]\e[0m User ${user} has a password set on their account.\n"
146 ((FAIL++))
147 STATUS=2
148 fi
149 fi
150 done
151 if [ -d ${uhome}/ ]; then
152 if [ -d ${uhome}/.ssh/ ]; then
153 if ls ${uhome}/.ssh/*> /dev/null 2>&1; then
154 for key in ${uhome}/.ssh/*
155 do
156 if [ "${key}" == "${uhome}/.ssh/authorized_keys" ]; then
157
158 if [ "$( cat "${key}" | wc -c)" -gt 50 ]; then
159 echo -en "\e[41m[FAIL]\e[0m User \e[1m${user}\e[0m has a populated authorized_keys file in \e[93m${key}\e[0m\n"
160 akey=$(cat ${key})
161 echo "File Contents:"
162 echo $akey
163 echo "--------------"
164 ((FAIL++))
165 STATUS=2
166 fi
167 elif [ "${key}" == "${uhome}/.ssh/id_rsa" ]; then
168 if [ "$( cat "${key}" | wc -c)" -gt 0 ]; then
169 echo -en "\e[41m[FAIL]\e[0m User \e[1m${user}\e[0m has a private key file in \e[93m${key}\e[0m\n"
170 akey=$(cat ${key})
171 echo "File Contents:"
172 echo $akey
173 echo "--------------"
174 ((FAIL++))
175 STATUS=2
176 else
177 echo -en "\e[93m[WARN]\e[0m User \e[1m${user}\e[0m has empty private key file in \e[93m${key}\e[0m\n"
178 ((WARN++))
179 if [[ $STATUS != 2 ]]; then
180 STATUS=1
181 fi
182 fi
183 elif [ "${key}" != "${uhome}/.ssh/known_hosts" ]; then
184 echo -en "\e[93m[WARN]\e[0m User \e[1m${user}\e[0m has a file in their .ssh directory at \e[93m${key}\e[0m\n"
185 ((WARN++))
186 if [[ $STATUS != 2 ]]; then
187 STATUS=1
188 fi
189 else
190 if [ "$( cat "${key}" | wc -c)" -gt 50 ]; then
191 echo -en "\e[93m[WARN]\e[0m User \e[1m${user}\e[0m has a populated known_hosts file in \e[93m${key}\e[0m\n"
192 ((WARN++))
193 if [[ $STATUS != 2 ]]; then
194 STATUS=1
195 fi
196 fi
197 fi
198 done
199 else
200 echo -en "\e[32m[ OK ]\e[0m User \e[1m${user}\e[0m has no SSH keys present\n"
201 fi
202 else
203 echo -en "\e[32m[ OK ]\e[0m User \e[1m${user}\e[0m does not have an .ssh directory\n"
204 fi
205 if [ -f /root/.bash_history ];then
206
207 BH_S=$( cat /root/.bash_history | wc -c)
208
209 if [[ $BH_S -lt 200 ]]; then
210 echo -en "\e[32m[PASS]\e[0m ${user}'s Bash History appears to have been cleared\n"
211 ((PASS++))
212 else
213 echo -en "\e[41m[FAIL]\e[0m ${user}'s Bash History should be cleared to prevent sensitive information from leaking\n"
214 ((FAIL++))
215 STATUS=2
216 fi
217
218 return 1;
219 else
220 echo -en "\e[32m[PASS]\e[0m The Root User's Bash History is not present\n"
221 ((PASS++))
222 fi
223 else
224 echo -en "\e[32m[ OK ]\e[0m User \e[1m${user}\e[0m does not have a directory in /home\n"
225 fi
226 echo -en "\n\n"
227 return 1
228 }
229
230 function checkUsers {
231 # Check each user-created account
232 for user in $(awk -F: '$3 >= 1000 && $1 != "nobody" {print $1}' /etc/passwd;)
233 do
234 # Skip some other non-user system accounts
235 if [[ $user == "centos" ]]; then
236 :
237 elif [[ $user == "nfsnobody" ]]; then
238 :
239 else
240 echo -en "\nChecking user: ${user}...\n"
241 for usr in $SHADOW
242 do
243 IFS=':' read -r -a u <<< "$usr"
244 if [[ "${u[0]}" == "${user}" ]]; then
245 if [[ ${u[1]} == "!" ]] || [[ ${u[1]} == "!!" ]] || [[ ${u[1]} == "*" ]]; then
246 echo -en "\e[32m[PASS]\e[0m User ${user} has no password set.\n"
247 ((PASS++))
248 else
249 echo -en "\e[41m[FAIL]\e[0m User ${user} has a password set on their account. Only system users are allowed on the image.\n"
250 ((FAIL++))
251 STATUS=2
252 fi
253 fi
254 done
255 #echo "User Found: ${user}"
256 uhome="/home/${user}"
257 if [ -d "${uhome}/" ]; then
258 if [ -d "${uhome}/.ssh/" ]; then
259 if ls "${uhome}/.ssh/*"> /dev/null 2>&1; then
260 for key in ${uhome}/.ssh/*
261 do
262 if [ "${key}" == "${uhome}/.ssh/authorized_keys" ]; then
263 if [ "$( cat "${key}" | wc -c)" -gt 50 ]; then
264 echo -en "\e[41m[FAIL]\e[0m User \e[1m${user}\e[0m has a populated authorized_keys file in \e[93m${key}\e[0m\n"
265 akey=$(cat ${key})
266 echo "File Contents:"
267 echo $akey
268 echo "--------------"
269 ((FAIL++))
270 STATUS=2
271 fi
272 elif [ "${key}" == "${uhome}/.ssh/id_rsa" ]; then
273 if [ "$( cat "${key}" | wc -c)" -gt 0 ]; then
274 echo -en "\e[41m[FAIL]\e[0m User \e[1m${user}\e[0m has a private key file in \e[93m${key}\e[0m\n"
275 akey=$(cat ${key})
276 echo "File Contents:"
277 echo $akey
278 echo "--------------"
279 ((FAIL++))
280 STATUS=2
281 else
282 echo -en "\e[93m[WARN]\e[0m User \e[1m${user}\e[0m has empty private key file in \e[93m${key}\e[0m\n"
283 ((WARN++))
284 if [[ $STATUS != 2 ]]; then
285 STATUS=1
286 fi
287 fi
288 elif [ "${key}" != "${uhome}/.ssh/known_hosts" ]; then
289
290 echo -en "\e[93m[WARN]\e[0m User \e[1m${user}\e[0m has a file in their .ssh directory named \e[93m${key}\e[0m\n"
291 ((WARN++))
292 if [[ $STATUS != 2 ]]; then
293 STATUS=1
294 fi
295
296 else
297 if [ "$( cat "${key}" | wc -c)" -gt 50 ]; then
298 echo -en "\e[93m[WARN]\e[0m User \e[1m${user}\e[0m has a known_hosts file in \e[93m${key}\e[0m\n"
299 ((WARN++))
300 if [[ $STATUS != 2 ]]; then
301 STATUS=1
302 fi
303 fi
304 fi
305
306
307 done
308 else
309 echo -en "\e[32m[ OK ]\e[0m User \e[1m${user}\e[0m has no SSH keys present\n"
310 fi
311 else
312 echo -en "\e[32m[ OK ]\e[0m User \e[1m${user}\e[0m does not have an .ssh directory\n"
313 fi
314 else
315 echo -en "\e[32m[ OK ]\e[0m User \e[1m${user}\e[0m does not have a directory in /home\n"
316 fi
317
318 # Check for an uncleared .bash_history for this user
319 if [ -f "${uhome}/.bash_history" ]; then
320 BH_S=$( cat "${uhome}/.bash_history" | wc -c )
321
322 if [[ $BH_S -lt 200 ]]; then
323 echo -en "\e[32m[PASS]\e[0m ${user}'s Bash History appears to have been cleared\n"
324 ((PASS++))
325 else
326 echo -en "\e[41m[FAIL]\e[0m ${user}'s Bash History should be cleared to prevent sensitive information from leaking\n"
327 ((FAIL++))
328 STATUS=2
329
330 fi
331 echo -en "\n\n"
332 fi
333 fi
334 done
335 }
336 function checkFirewall {
337
338 if [[ $OS == "Ubuntu" ]]; then
339 fw="ufw"
340 ufwa=$(ufw status |head -1| sed -e "s/^Status:\ //")
341 if [[ $ufwa == "active" ]]; then
342 FW_VER="\e[32m[PASS]\e[0m Firewall service (${fw}) is active\n"
343 ((PASS++))
344 else
345 FW_VER="\e[93m[WARN]\e[0m No firewall is configured. Ensure ${fw} is installed and configured\n"
346 ((WARN++))
347 fi
348 elif [[ $OS == "CentOS Linux" ]]; then
349 if [ -f /usr/lib/systemd/system/csf.service ]; then
350 fw="csf"
351 if [[ $(systemctl status $fw >/dev/null 2>&1) ]]; then
352
353 FW_VER="\e[32m[PASS]\e[0m Firewall service (${fw}) is active\n"
354 ((PASS++))
355 elif cmdExists "firewall-cmd"; then
356 if [[ $(systemctl is-active firewalld >/dev/null 2>&1 && echo 1 || echo 0) ]]; then
357 FW_VER="\e[32m[PASS]\e[0m Firewall service (${fw}) is active\n"
358 ((PASS++))
359 else
360 FW_VER="\e[93m[WARN]\e[0m No firewall is configured. Ensure ${fw} is installed and configured\n"
361 ((WARN++))
362 fi
363 else
364 FW_VER="\e[93m[WARN]\e[0m No firewall is configured. Ensure ${fw} is installed and configured\n"
365 ((WARN++))
366 fi
367 else
368 fw="firewalld"
369 if [[ $(systemctl is-active firewalld >/dev/null 2>&1 && echo 1 || echo 0) ]]; then
370 FW_VER="\e[32m[PASS]\e[0m Firewall service (${fw}) is active\n"
371 ((PASS++))
372 else
373 FW_VER="\e[93m[WARN]\e[0m No firewall is configured. Ensure ${fw} is installed and configured\n"
374 ((WARN++))
375 fi
376 fi
377 elif [[ "$OS" =~ Debian.* ]]; then
378 # user could be using a number of different services for managing their firewall
379 # we will check some of the most common
380 if cmdExists 'ufw'; then
381 fw="ufw"
382 ufwa=$(ufw status | sed -e "s/^Status:\ //")
383 if [[ $ufwa == "active" ]]; then
384 FW_VER="\e[32m[PASS]\e[0m Firewall service (${fw}) is active\n"
385 ((PASS++))
386 else
387 FW_VER="\e[93m[WARN]\e[0m No firewall is configured. Ensure ${fw} is installed and configured\n"
388 ((WARN++))
389 fi
390 elif cmdExists "firewall-cmd"; then
391 fw="firewalld"
392 if [[ $(systemctl is-active --quiet $fw) ]]; then
393 FW_VER="\e[32m[PASS]\e[0m Firewall service (${fw}) is active\n"
394 ((PASS++))
395 else
396 FW_VER="\e[93m[WARN]\e[0m No firewall is configured. Ensure ${fw} is installed and configured\n"
397 ((WARN++))
398 fi
399 else
400 # user could be using vanilla iptables, check if kernel module is loaded
401 fw="iptables"
402 if [[ $(lsmod | grep -q '^ip_tables' 2>/dev/null) ]]; then
403 FW_VER="\e[32m[PASS]\e[0m Firewall service (${fw}) is active\n"
404 ((PASS++))
405 else
406 FW_VER="\e[93m[WARN]\e[0m No firewall is configured. Ensure ${fw} is installed and configured\n"
407 ((WARN++))
408 fi
409 fi
410 fi
411
412 }
413 function checkUpdates {
414 if [[ $OS == "Ubuntu" ]] || [[ "$OS" =~ Debian.* ]]; then
415 # Ensure /tmp exists and has the proper permissions before
416 # checking for security updates
417 # https://github.com/digitalocean/marketplace-partners/issues/94
418 if [[ ! -d /tmp ]]; then
419 mkdir /tmp
420 fi
421 chmod 1777 /tmp
422
423 echo -en "\nUpdating apt package database to check for security updates, this may take a minute...\n\n"
424 apt-get -y update > /dev/null
425
426 uc=$(apt-get --just-print upgrade | grep -i "security" | wc -l)
427 if [[ $uc -gt 0 ]]; then
428 update_count=$(( ${uc} / 2 ))
429 else
430 update_count=0
431 fi
432
433 if [[ $update_count -gt 0 ]]; then
434 echo -en "\e[41m[FAIL]\e[0m There are ${update_count} security updates available for this image that have not been installed.\n"
435 echo -en
436 echo -en "Here is a list of the security updates that are not installed:\n"
437 sleep 2
438 apt-get --just-print upgrade | grep -i security | awk '{print $2}' | awk '!seen[$0]++'
439 echo -en
440 ((FAIL++))
441 STATUS=2
442 else
443 echo -en "\e[32m[PASS]\e[0m There are no pending security updates for this image.\n\n"
444 fi
445 elif [[ $OS == "CentOS Linux" ]]; then
446 echo -en "\nChecking for available updates with yum, this may take a minute...\n\n"
447
448 update_count=$(yum list updates -q | grep -vc "Updated Packages")
449 if [[ $update_count -gt 0 ]]; then
450 echo -en "\e[41m[FAIL]\e[0m There are ${update_count} updates available for this image that have not been installed.\n"
451 ((FAIL++))
452 STATUS=2
453 else
454 echo -en "\e[32m[PASS]\e[0m There are no pending security updates for this image.\n"
455 ((PASS++))
456 fi
457 else
458 echo "Error encountered"
459 exit 1
460 fi
461
462 return 1;
463 }
464 function checkCloudInit {
465
466 if hash cloud-init 2>/dev/null; then
467 CI="\e[32m[PASS]\e[0m Cloud-init is installed.\n"
468 ((PASS++))
469 else
470 CI="\e[41m[FAIL]\e[0m No valid verison of cloud-init was found.\n"
471 ((FAIL++))
472 STATUS=2
473 fi
474 return 1
475 }
476 function checkMongoDB {
477 # Check if MongoDB is installed
478 # If it is, verify the version is allowed (non-SSPL)
479
480 if [[ $OS == "Ubuntu" ]] || [[ "$OS" =~ Debian.* ]]; then
481
482 if [[ -f "/usr/bin/mongod" ]]; then
483 version=$(/usr/bin/mongod --version --quiet | grep "db version" | sed -e "s/^db\ version\ v//")
484
485 if version_gt $version 4.0.0; then
486 if version_gt $version 4.0.3; then
487 echo -en "\e[41m[FAIL]\e[0m An SSPL version of MongoDB is present, ${version}"
488 ((FAIL++))
489 STATUS=2
490 else
491 echo -en "\e[32m[PASS]\e[0m The version of MongoDB installed, ${version} is not under the SSPL"
492 ((PASS++))
493 fi
494 else
495 if version_gt $version 3.6.8; then
496 echo -en "\e[41m[FAIL]\e[0m An SSPL version of MongoDB is present, ${version}"
497 ((FAIL++))
498 STATUS=2
499 else
500 echo -en "\e[32m[PASS]\e[0m The version of MongoDB installed, ${version} is not under the SSPL"
501 ((PASS++))
502 fi
503 fi
504
505
506 else
507 echo -en "\e[32m[PASS]\e[0m MongoDB is not installed"
508 ((PASS++))
509 fi
510
511 elif [[ $OS == "CentOS Linux" ]]; then
512
513 if [[ -f "/usr/bin/mongod" ]]; then
514 version=$(/usr/bin/mongod --version --quiet | grep "db version" | sed -e "s/^db\ version\ v//")
515
516
517 if version_gt $version 4.0.0; then
518 if version_gt $version 4.0.3; then
519 echo -en "\e[41m[FAIL]\e[0m An SSPL version of MongoDB is present"
520 ((FAIL++))
521 STATUS=2
522 else
523 echo -en "\e[32m[PASS]\e[0m The version of MongoDB installed is not under the SSPL"
524 ((PASS++))
525 fi
526 else
527 if version_gt $version 3.6.8; then
528 echo -en "\e[41m[FAIL]\e[0m An SSPL version of MongoDB is present"
529 ((FAIL++))
530 STATUS=2
531 else
532 echo -en "\e[32m[PASS]\e[0m The version of MongoDB installed is not under the SSPL"
533 ((PASS++))
534 fi
535 fi
536
537
538
539 else
540 echo -en "\e[32m[PASS]\e[0m MongoDB is not installed"
541 ((PASS++))
542 fi
543
544 else
545 echo "ERROR: Unable to identify distribution"
546 ((FAIL++))
547 STATUS 2
548 return 1
549 fi
550
551
552 }
553
554 function version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }
555
556
557 clear
558 echo "DigitalOcean Marketplace Image Validation Tool ${VERSION}"
559 echo "Executed on: ${RUNDATE}"
560 echo "Checking local system for Marketplace compatibility..."
561
562 getDistro
563
564 echo -en "\n\e[1mDistribution:\e[0m ${OS}\n"
565 echo -en "\e[1mVersion:\e[0m ${VER}\n\n"
566
567 ost=0
568 osv=0
569
570 if [[ $OS == "Ubuntu" ]]; then
571 ost=1
572 if [[ $VER == "20.04" ]]; then
573 osv=1
574 elif [[ $VER == "18.04" ]]; then
575 osv=1
576 elif [[ $VER == "16.04" ]]; then
577 osv=1
578 else
579 osv=0
580 fi
581
582 elif [[ "$OS" =~ Debian.* ]]; then
583 ost=1
584 case "$VER" in
585 9)
586 osv=1
587 ;;
588 10)
589 osv=1
590 ;;
591 *)
592 osv=2
593 ;;
594 esac
595
596 elif [[ $OS == "CentOS Linux" ]]; then
597 ost=1
598 if [[ $VER == "8" ]]; then
599 osv=1
600 elif [[ $VER == "7" ]]; then
601 osv=1
602 elif [[ $VER == "6" ]]; then
603 osv=1
604 else
605 osv=2
606 fi
607 else
608 ost=0
609 fi
610
611 if [[ $ost == 1 ]]; then
612 echo -en "\e[32m[PASS]\e[0m Supported Operating System Detected: ${OS}\n"
613 ((PASS++))
614 else
615 echo -en "\e[41m[FAIL]\e[0m ${OS} is not a supported Operating System\n"
616 ((FAIL++))
617 STATUS=2
618 fi
619
620 if [[ $osv == 1 ]]; then
621 echo -en "\e[32m[PASS]\e[0m Supported Release Detected: ${VER}\n"
622 ((PASS++))
623 elif [[ $ost == 1 ]]; then
624 echo -en "\e[41m[FAIL]\e[0m ${OS} ${VER} is not a supported Operating System Version\n"
625 ((FAIL++))
626 STATUS=2
627 else
628 echo "Exiting..."
629 exit 1
630 fi
631
632 checkCloudInit
633
634 echo -en "${CI}"
635
636 checkFirewall
637
638 echo -en "${FW_VER}"
639
640 checkUpdates
641
642 loadPasswords
643
644 checkLogs
645
646 echo -en "\n\nChecking all user-created accounts...\n"
647 checkUsers
648
649 echo -en "\n\nChecking the root account...\n"
650 checkRoot
651
652 checkAgent
653
654 checkMongoDB
655
656
657 # Summary
658 echo -en "\n\n---------------------------------------------------------------------------------------------------\n"
659
660 if [[ $STATUS == 0 ]]; then
661 echo -en "Scan Complete.\n\e[32mAll Tests Passed!\e[0m\n"
662 elif [[ $STATUS == 1 ]]; then
663 echo -en "Scan Complete. \n\e[93mSome non-critical tests failed. Please review these items.\e[0m\e[0m\n"
664 else
665 echo -en "Scan Complete. \n\e[41mOne or more tests failed. Please review these items and re-test.\e[0m\n"
666 fi
667 echo "---------------------------------------------------------------------------------------------------"
668 echo -en "\e[1m${PASS} Tests PASSED\e[0m\n"
669 echo -en "\e[1m${WARN} WARNINGS\e[0m\n"
670 echo -en "\e[1m${FAIL} Tests FAILED\e[0m\n"
671 echo -en "---------------------------------------------------------------------------------------------------\n"
672
673 if [[ $STATUS == 0 ]]; then
674 echo -en "We did not detect any issues with this image. Please be sure to manually ensure that all software installed on the base system is functional, secure and properly configured (or facilities for configuration on first-boot have been created).\n\n"
675 exit 0
676 elif [[ $STATUS == 1 ]]; then
677 echo -en "Please review all [WARN] items above and ensure they are intended or resolved. If you do not have a specific requirement, we recommend resolving these items before image submission\n\n"
678 exit 1
679 else
680 echo -en "Some critical tests failed. These items must be resolved and this scan re-run before you submit your image to the marketplace.\n\n"
681 exit 1
682 fi