1
1
#! /bin/bash
2
- #
2
+
3
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.2 "
4
+ # © 2021 DigitalOcean LLC.
5
+ # This code is licensed under Apache 2.0 license (see LICENSE.md for details)
6
+
7
+ VERSION=" v. 1.6 "
8
8
RUNDATE=$( date )
9
9
10
10
# Script should be run with SUDO
@@ -110,18 +110,12 @@ function checkLogs {
110
110
[[ -e $f ]] || break
111
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
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/cloud-init-output.log' ]]; then
120
- if cat ' /var/log/cloud-init-output.log' | grep -q SHA256; then
121
- echo -en " \e[41m[FAIL]\e[0m log containing SHA256 value found in log file ${f} \n"
122
- (( FAIL++ ))
123
- STATUS=1
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
124
117
fi
118
+ fi
125
119
elif [[ " ${f} " != ' /var/log/lfd.log' && " $( cat " ${f} " | wc -c) " -gt 50 ]]; then
126
120
if [ $f != $cp_ignore ]; then
127
121
echo -en " \e[93m[WARN]\e[0m un-cleared log file, ${f} found\n"
@@ -252,7 +246,7 @@ function checkUsers {
252
246
echo -en " \e[32m[PASS]\e[0m User ${user} has no password set.\n"
253
247
(( PASS++ ))
254
248
else
255
- echo -en " \e[41m[FAIL]\e[0m User ${user} has a password set on their account.\n"
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"
256
250
(( FAIL++ ))
257
251
STATUS=2
258
252
fi
@@ -385,7 +379,7 @@ function checkFirewall {
385
379
# we will check some of the most common
386
380
if cmdExists ' ufw' ; then
387
381
fw=" ufw"
388
- ufwa=$( ufw status | sed -e " s/^Status:\ //" )
382
+ ufwa=$( ufw status | head -1 | sed -e " s/^Status:\ //" )
389
383
if [[ $ufwa == " active" ]]; then
390
384
FW_VER=" \e[32m[PASS]\e[0m Firewall service (${fw} ) is active\n"
391
385
(( PASS++ ))
@@ -418,6 +412,14 @@ function checkFirewall {
418
412
}
419
413
function checkUpdates {
420
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
+
421
423
echo -en " \nUpdating apt package database to check for security updates, this may take a minute...\n\n"
422
424
apt-get -y update > /dev/null
423
425
@@ -441,11 +443,11 @@ function checkUpdates {
441
443
echo -en " \e[32m[PASS]\e[0m There are no pending security updates for this image.\n\n"
442
444
fi
443
445
elif [[ $OS == " CentOS Linux" ]]; then
444
- echo -en " \nChecking for available updates with yum , this may take a minute...\n\n"
446
+ echo -en " \nChecking for available security updates , this may take a minute...\n\n"
445
447
446
- update_count=$( yum list updates -q | grep -vc " Updated Packages " )
448
+ update_count=$( yum check-update --security --quiet | wc -l )
447
449
if [[ $update_count -gt 0 ]]; then
448
- echo -en " \e[41m[FAIL]\e[0m There are ${update_count} updates available for this image that have not been installed.\n"
450
+ echo -en " \e[41m[FAIL]\e[0m There are ${update_count} security updates available for this image that have not been installed.\n"
449
451
(( FAIL++ ))
450
452
STATUS=2
451
453
else
@@ -553,11 +555,6 @@ function version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$
553
555
554
556
555
557
clear
556
-
557
- echo " Installing Security Update"
558
- sudo apt-get update
559
- sudo apt-get install libp11-kit0
560
-
561
558
echo " DigitalOcean Marketplace Image Validation Tool ${VERSION} "
562
559
echo " Executed on: ${RUNDATE} "
563
560
echo " Checking local system for Marketplace compatibility..."
@@ -572,7 +569,9 @@ osv=0
572
569
573
570
if [[ $OS == " Ubuntu" ]]; then
574
571
ost=1
575
- if [[ $VER == " 18.04" ]]; then
572
+ if [[ $VER == " 20.04" ]]; then
573
+ osv=1
574
+ elif [[ $VER == " 18.04" ]]; then
576
575
osv=1
577
576
elif [[ $VER == " 16.04" ]]; then
578
577
osv=1
@@ -596,7 +595,9 @@ elif [[ "$OS" =~ Debian.* ]]; then
596
595
597
596
elif [[ $OS == " CentOS Linux" ]]; then
598
597
ost=1
599
- if [[ $VER == " 7" ]]; then
598
+ if [[ $VER == " 8" ]]; then
599
+ osv=1
600
+ elif [[ $VER == " 7" ]]; then
600
601
osv=1
601
602
elif [[ $VER == " 6" ]]; then
602
603
osv=1
@@ -674,8 +675,8 @@ if [[ $STATUS == 0 ]]; then
674
675
exit 0
675
676
elif [[ $STATUS == 1 ]]; then
676
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"
677
- exit 1
678
+ exit 0
678
679
else
679
- 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"
680
+ echo -en " Some critical tests failed. These items must be resolved and this scan re-run before you submit your image to the DigitalOcean Marketplace .\n\n"
680
681
exit 1
681
- fi
682
+ fi
0 commit comments