Check severity: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
| Zeile 1: | Zeile 1: | ||
*apt install bc | *apt install bc | ||
*cat /usr/local/bin/check_severity | *cat /usr/local/bin/check_severity | ||
| − | < | + | <syntaxhighlight lang=bash> |
#!/bin/bash | #!/bin/bash | ||
#• BSI Schwachstellenampel | #• BSI Schwachstellenampel | ||
| Zeile 34: | Zeile 34: | ||
exit 2 | exit 2 | ||
fi | fi | ||
| − | </ | + | </syntaxhighlight> |
Aktuelle Version vom 25. Juni 2024, 12:32 Uhr
- 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