Check severity
Zur Navigation springen
Zur Suche springen
- apt install bc
- cat /usr/local/bin/check_severity
#!/bin/bash
#• BSI Schwachstellenampel
#– 7.0 – 10.0: Rot
#– 4.0 – 6.9: Gelb
#– 0.0 – 3.9: Grün
file=$1
path="/var/www/scans/severity/"
if [[ ! -f $path$file ]]
then
echo "Status Warning - File $file not found"
exit 1
fi
severity=$(cat $path$file)
#Wichtig bc liefert den Rückgabewert 0 wenn unwahr, so wie in allen Programmiersprachen ausser der Shell
if [ $(echo "$severity>4" | bc) -eq 0 ]
then
echo "Status OK - Severity: $severity"
exit 0
elif [ $(echo "$severity>7" | bc) -eq 0 ]
then
echo "Status Warning - Severity: $severity"
exit 1
elif [ $(echo "$severity>10" | bc) -eq 0 ]
then
echo "Status Critical - Severity: $severity"
exit 2
fi