2007-10-15 08:14:42 +02:00
|
|
|
#!/bin/sh
|
2016-09-07 06:58:52 +02:00
|
|
|
|
|
|
|
: << =cut
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
debsecan - Plugin to monitor the number of CVE vulnerabilities present on a Debian
|
|
|
|
system (using debsecan). Might work on other distib, who knows...
|
|
|
|
|
|
|
|
=head1 CONFIGURATION
|
|
|
|
|
|
|
|
[debsecan]
|
|
|
|
env.suite jessie
|
|
|
|
env.fixed_warn 1
|
|
|
|
env.fixed_critical 1000
|
2017-01-04 02:12:16 +01:00
|
|
|
env.remote_warn 1
|
|
|
|
env.remote_critical 10
|
2016-09-07 06:58:52 +02:00
|
|
|
|
|
|
|
=head1 AUTHORS
|
|
|
|
|
|
|
|
* Nicolas BOUTHORS <nbouthors@nbi.fr> http://nbi.fr/, Inspiration of the moment 10/10/2007
|
|
|
|
* Olivier Mehani <shtrom+munin@ssji.net>, 2016
|
|
|
|
|
|
|
|
=head1 LICENSE
|
|
|
|
|
|
|
|
Public Domain
|
|
|
|
|
|
|
|
=head1 MAGIC MARKERS
|
|
|
|
|
|
|
|
%# family=auto
|
|
|
|
%# capabilities=autoconf
|
|
|
|
|
|
|
|
=cut
|
2007-10-15 08:14:42 +02:00
|
|
|
|
|
|
|
# Auto enable if we have debsecan only
|
2016-09-01 03:23:47 +02:00
|
|
|
if [ "$1" = "autoconf" ] ; then
|
2007-10-15 08:14:42 +02:00
|
|
|
if [ -x /usr/bin/debsecan ]; then
|
|
|
|
echo yes
|
|
|
|
else
|
2017-01-05 03:57:56 +01:00
|
|
|
echo 'no (/usr/bin/debsecan not found)'
|
2007-10-15 08:14:42 +02:00
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2016-09-01 03:23:47 +02:00
|
|
|
# Fail if we don't have debsecan
|
2007-10-15 08:14:42 +02:00
|
|
|
if [ ! -x /usr/bin/debsecan ]; then
|
2017-01-05 03:57:56 +01:00
|
|
|
echo 'error: /usr/bin/debsecan not found' >&2
|
2007-10-15 08:14:42 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-09-07 06:58:52 +02:00
|
|
|
# Determine suite from filename...
|
2017-01-04 02:48:25 +01:00
|
|
|
SUITE=$(echo "$0" | sed 's/.*_//')
|
|
|
|
if [ "${SUITE}" = "${0}" ]; then
|
2016-09-07 06:58:52 +02:00
|
|
|
# ...or fall back onto configuration in environment
|
|
|
|
SUITE=${suite:-sid}
|
|
|
|
fi
|
|
|
|
FIXEDWARN=${fixed_warning:-1}
|
|
|
|
FIXEDCRIT=${fixed_critical:-1000}
|
2017-01-04 02:12:16 +01:00
|
|
|
REMOTEWARN=${remote_warning:-1}
|
|
|
|
REMOTECRIT=${remote_critical:-10}
|
2016-09-07 06:58:52 +02:00
|
|
|
|
2007-10-15 08:14:42 +02:00
|
|
|
if [ "$1" = "config" ] ; then
|
|
|
|
cat <<EOF_
|
2016-09-07 06:58:52 +02:00
|
|
|
graph_title DebSecan : vulnerabilities for ${SUITE}
|
2007-10-15 08:14:42 +02:00
|
|
|
graph_args -l 0 --base 1000
|
|
|
|
graph_vlabel number of CVE
|
|
|
|
graph_category system
|
|
|
|
graph_period second
|
2016-09-01 02:49:19 +02:00
|
|
|
graph_info This graph show the number of known vulnerabilities present on your system. Use debsecan to see details.
|
2017-01-04 02:12:16 +01:00
|
|
|
remote.label remote
|
|
|
|
remote.colour FF0000
|
|
|
|
remote.type GAUGE
|
|
|
|
remote.draw AREASTACK
|
|
|
|
remote.min 0
|
|
|
|
remote.info The number of remotely exploitable CVEs with any priority
|
|
|
|
remote.warning ${REMOTEWARN}
|
|
|
|
remote.critical ${REMOTECRIT}
|
2007-10-15 08:14:42 +02:00
|
|
|
high.label high
|
2017-01-04 06:19:44 +01:00
|
|
|
high.colour DD2200
|
2007-10-15 08:14:42 +02:00
|
|
|
high.type GAUGE
|
2016-09-01 02:50:19 +02:00
|
|
|
high.draw AREASTACK
|
2007-10-15 08:14:42 +02:00
|
|
|
high.min 0
|
2016-09-01 02:49:19 +02:00
|
|
|
high.info The number of CVEs marked high priority
|
2007-10-15 08:14:42 +02:00
|
|
|
medium.label medium
|
2017-01-04 06:19:44 +01:00
|
|
|
medium.colour FFAA00
|
2007-10-15 08:14:42 +02:00
|
|
|
medium.type GAUGE
|
2016-09-01 02:50:19 +02:00
|
|
|
medium.draw AREASTACK
|
2007-10-15 08:14:42 +02:00
|
|
|
medium.min 0
|
2016-09-01 02:49:19 +02:00
|
|
|
medium.info The number of CVEs marked medium priority
|
2007-10-15 08:14:42 +02:00
|
|
|
low.label low
|
2016-09-01 02:50:19 +02:00
|
|
|
low.colour 0000FF
|
2007-10-15 08:14:42 +02:00
|
|
|
low.type GAUGE
|
2016-09-01 02:50:19 +02:00
|
|
|
low.draw AREASTACK
|
2007-10-15 08:14:42 +02:00
|
|
|
low.min 0
|
2016-09-01 02:49:19 +02:00
|
|
|
low.info The number of CVEs marked low priority
|
2007-10-15 08:14:42 +02:00
|
|
|
other.label other
|
2017-01-04 06:19:44 +01:00
|
|
|
other.colour 00AAFF
|
2007-10-15 08:14:42 +02:00
|
|
|
other.type GAUGE
|
2016-09-01 02:50:19 +02:00
|
|
|
other.draw AREASTACK
|
2007-10-15 08:14:42 +02:00
|
|
|
other.min 0
|
2016-09-01 02:49:19 +02:00
|
|
|
other.info The number of CVEs with unspecified priority
|
2016-09-07 06:58:52 +02:00
|
|
|
fixed.label fixed
|
|
|
|
fixed.type GAUGE
|
|
|
|
fixed.draw LINE2
|
|
|
|
fixed.min 0
|
|
|
|
fixed.info The number of CVEs fixed by available updates
|
|
|
|
fixed.warning ${FIXEDWARN}
|
|
|
|
fixed.critical ${FIXEDCRIT}
|
2007-10-15 08:14:42 +02:00
|
|
|
EOF_
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2017-01-04 02:48:25 +01:00
|
|
|
ALL=$(debsecan --suite "${SUITE}" 2> /dev/null)
|
|
|
|
REMOTE=$(echo "$ALL" | grep 'remotely')
|
|
|
|
NONREMOTE=$(echo "$ALL" | grep -v 'remotely')
|
|
|
|
|
|
|
|
HIGH=$(echo "${NONREMOTE}" | grep 'high urgency')
|
|
|
|
MEDIUM=$(echo "${NONREMOTE}" | grep 'medium urgency')
|
|
|
|
LOW=$(echo "${NONREMOTE}" | grep 'low urgency')
|
|
|
|
OTHER=$(echo "${NONREMOTE}" | grep -v 'urgency')
|
|
|
|
FIXED=$(echo "${ALL}" | grep '(fixed')
|
2016-09-01 03:17:47 +02:00
|
|
|
|
2017-01-04 02:48:25 +01:00
|
|
|
remote_count=$(echo "${REMOTE}" | wc -l)
|
|
|
|
high_count=$(echo "${HIGH}" | wc -l)
|
|
|
|
medium_count=$(echo "${MEDIUM}" | wc -l)
|
|
|
|
low_count=$(echo "${LOW}" | wc -l)
|
|
|
|
other_count=$(echo "${OTHER}" | wc -l)
|
|
|
|
fixed_count=$(echo "${FIXED}" | wc -l)
|
|
|
|
|
|
|
|
CVECOUNTRE="s/^ *\([0-9]\+\) \+\([^ ]\+\)/\2 (\1)/"
|
2016-09-01 12:33:10 +02:00
|
|
|
|
2017-01-04 02:48:25 +01:00
|
|
|
# shellcheck disable=SC2005 disable=SC2046
|
|
|
|
# The nested $(echo ...)s are needed to yet the newlines
|
2016-09-01 12:33:10 +02:00
|
|
|
cat <<EOF
|
2017-01-04 02:48:25 +01:00
|
|
|
remote.value $remote_count
|
|
|
|
remote.extinfo $(echo $(echo "${REMOTE}" | cut -f 2 -d " "| uniq -c | sort -nr | sed "${CVECOUNTRE}"))
|
|
|
|
high.value $high_count
|
|
|
|
high.extinfo $(echo $(echo "${HIGH}" | cut -f 2 -d " " | uniq -c | sort -nr | sed "${CVECOUNTRE}"))
|
|
|
|
medium.value $medium_count
|
|
|
|
medium.extinfo $(echo $(echo "${MEDIUM}" | cut -f 2 -d " " | uniq -c | sort -nr | sed "${CVECOUNTRE}"))
|
|
|
|
low.value $low_count
|
|
|
|
low.extinfo $(echo $(echo "${LOW}" | cut -f 2 -d " " | uniq -c | sort -nr | sed "${CVECOUNTRE}"))
|
|
|
|
other.value $other_count
|
|
|
|
other.extinfo $(echo $(echo "${OTHER}" | cut -f 2 -d " " | uniq -c | sort -nr | sed "${CVECOUNTRE}"))
|
|
|
|
fixed.value $fixed_count
|
|
|
|
fixed.extinfo $(echo $(echo "${FIXED}" | cut -f 2 -d " " | uniq -c | sort -nr | sed "${CVECOUNTRE}"))
|
2016-09-01 03:19:27 +02:00
|
|
|
EOF
|