root / plugins / debian / debsecan_ @ 3abb60e3
Historique | Voir | Annoter | Télécharger (5,62 ko)
| 1 |
#!/bin/sh |
|---|---|
| 2 |
|
| 3 |
: << =cut |
| 4 |
|
| 5 |
=head1 NAME |
| 6 |
|
| 7 |
debsecan - Plugin to monitor the number of CVE vulnerabilities present on a Debian-ish |
| 8 |
system (using debsecan). This plugin can either report the sum of vulnerabilities present in each packages ('pkg' mode, default), or the number of unique CVEs affecting the system ('cve' mode).
|
| 9 |
|
| 10 |
The 'cve' mode is a better indication of the risk level of the system (as |
| 11 |
multiple packages with the same vulnerable source get counted repeatedly), but |
| 12 |
the 'pkg' provides valuable information to identify packages with high number |
| 13 |
of vulnerabilities that should be considered for deletion. |
| 14 |
|
| 15 |
Simply symlink this plugin into your Munin plugins directory as |
| 16 |
- debsecan_pkg (the extra_info will list the number of CVE affecting each package) |
| 17 |
- debsecan_cve (the extra_info will list the number of packages affected by each CVE) |
| 18 |
|
| 19 |
For backward compatibility, a symlink without a mode will default to 'pkg'. |
| 20 |
|
| 21 |
=head1 CONFIGURATION |
| 22 |
|
| 23 |
The default configuration is as follows. |
| 24 |
|
| 25 |
[debsecan] |
| 26 |
env.suite jessie |
| 27 |
env.fixed_warning 1 |
| 28 |
env.fixed_critical 1000 |
| 29 |
env.remote_warning 1 |
| 30 |
env.remote_critical 10 |
| 31 |
|
| 32 |
The name of the group needs to match the name of the symlink to be applied. |
| 33 |
Shell globbing patterns are allowed. |
| 34 |
|
| 35 |
=head1 AUTHORS |
| 36 |
|
| 37 |
* Nicolas BOUTHORS <nbouthors@nbi.fr> http://nbi.fr/, Inspiration of the moment 10/10/2007 |
| 38 |
* Olivier Mehani <shtrom+munin@ssji.net>, 2016 |
| 39 |
|
| 40 |
=head1 LICENSE |
| 41 |
|
| 42 |
Public Domain |
| 43 |
|
| 44 |
=head1 MAGIC MARKERS |
| 45 |
|
| 46 |
%# family=auto |
| 47 |
%# capabilities=autoconf |
| 48 |
|
| 49 |
=cut |
| 50 |
|
| 51 |
# Auto enable if we have debsecan only |
| 52 |
if [ "$1" = "autoconf" ] ; then |
| 53 |
if [ -x /usr/bin/debsecan ]; then |
| 54 |
echo yes |
| 55 |
else |
| 56 |
echo 'no (/usr/bin/debsecan not found)' |
| 57 |
fi |
| 58 |
exit 0 |
| 59 |
fi |
| 60 |
|
| 61 |
# Fail if we don't have debsecan |
| 62 |
if [ ! -x /usr/bin/debsecan ]; then |
| 63 |
echo 'error: /usr/bin/debsecan not found' >&2 |
| 64 |
exit 1 |
| 65 |
fi |
| 66 |
|
| 67 |
SUITE=${suite:-sid}
|
| 68 |
FIXEDWARN=${fixed_warning:-1}
|
| 69 |
FIXEDCRIT=${fixed_critical:-1000}
|
| 70 |
REMOTEWARN=${remote_warning:-1}
|
| 71 |
REMOTECRIT=${remote_critical:-10}
|
| 72 |
|
| 73 |
MODE=$(echo "$0" | sed 's/.*_//') |
| 74 |
case "${MODE}" in
|
| 75 |
'cve') |
| 76 |
TITLE_ADD="unique " |
| 77 |
FIELD=1 |
| 78 |
;; |
| 79 |
'pkg' | *) |
| 80 |
TITLE_ADD="package " |
| 81 |
FIELD=2 |
| 82 |
;; |
| 83 |
esac |
| 84 |
|
| 85 |
if [ "$1" = "config" ] ; then |
| 86 |
cat <<EOF_ |
| 87 |
graph_title DebSecan: ${TITLE_ADD}vulnerabilities
|
| 88 |
graph_info ${TITLE_ADD}vulnerabilities for ${SUITE}
|
| 89 |
graph_args -l 0 --base 1000 |
| 90 |
graph_vlabel number of CVE |
| 91 |
graph_category system |
| 92 |
graph_period second |
| 93 |
graph_info This graph show the number of known ${TITLE_ADD}vulnerabilities present on your system. Use debsecan to see details.
|
| 94 |
remote.label remote |
| 95 |
remote.colour FF0000 |
| 96 |
remote.type GAUGE |
| 97 |
remote.draw AREASTACK |
| 98 |
remote.min 0 |
| 99 |
remote.info The number of ${TITLE_ADD}remotely exploitable CVEs with any priority
|
| 100 |
remote.warning ${REMOTEWARN}
|
| 101 |
remote.critical ${REMOTECRIT}
|
| 102 |
high.label high |
| 103 |
high.colour DD2200 |
| 104 |
high.type GAUGE |
| 105 |
high.draw AREASTACK |
| 106 |
high.min 0 |
| 107 |
high.info The number of ${TITLE_ADD}CVEs marked high priority
|
| 108 |
medium.label medium |
| 109 |
medium.colour FFAA00 |
| 110 |
medium.type GAUGE |
| 111 |
medium.draw AREASTACK |
| 112 |
medium.min 0 |
| 113 |
medium.info The number of ${TITLE_ADD}CVEs marked medium priority
|
| 114 |
low.label low |
| 115 |
low.colour 0000FF |
| 116 |
low.type GAUGE |
| 117 |
low.draw AREASTACK |
| 118 |
low.min 0 |
| 119 |
low.info The number of ${TITLE_ADD}CVEs marked low priority
|
| 120 |
other.label other |
| 121 |
other.colour 00AAFF |
| 122 |
other.type GAUGE |
| 123 |
other.draw AREASTACK |
| 124 |
other.min 0 |
| 125 |
other.info The number of ${TITLE_ADD}CVEs with unspecified priority
|
| 126 |
fixed.label fixed |
| 127 |
fixed.type GAUGE |
| 128 |
fixed.draw LINE2 |
| 129 |
fixed.min 0 |
| 130 |
fixed.info The number of ${TITLE_ADD}CVEs fixed by available updates
|
| 131 |
fixed.warning ${FIXEDWARN}
|
| 132 |
fixed.critical ${FIXEDCRIT}
|
| 133 |
EOF_ |
| 134 |
exit 0 |
| 135 |
fi |
| 136 |
|
| 137 |
ALL=$(debsecan --suite "${SUITE}" 2> /dev/null)
|
| 138 |
REMOTE=$(echo "$ALL" | grep -w 'remotely') |
| 139 |
NONREMOTE=$(echo "$ALL" | grep -wv 'remotely') |
| 140 |
|
| 141 |
HIGH=$(echo "${NONREMOTE}" | grep -w 'high urgency')
|
| 142 |
MEDIUM=$(echo "${NONREMOTE}" | grep -w 'medium urgency')
|
| 143 |
LOW=$(echo "${NONREMOTE}" | grep -w 'low urgency')
|
| 144 |
OTHER=$(echo "${NONREMOTE}" | grep -wv 'urgency')
|
| 145 |
FIXED=$(echo "${ALL}" | grep -w '(fixed')
|
| 146 |
|
| 147 |
# Arguments: Field offset to aggregate by |
| 148 |
count_entries() {
|
| 149 |
CUT_FIELD="${1}"
|
| 150 |
cut -f "${CUT_FIELD}" -d " "| sort | uniq -c
|
| 151 |
} |
| 152 |
|
| 153 |
case "${MODE}" in
|
| 154 |
'cve') |
| 155 |
remote_count=$(echo "${REMOTE}" | count_entries "${FIELD}" | wc -l)
|
| 156 |
high_count=$(echo "${HIGH}" | count_entries "${FIELD}" | wc -l)
|
| 157 |
medium_count=$(echo "${MEDIUM}" | count_entries "${FIELD}" | wc -l)
|
| 158 |
low_count=$(echo "${LOW}" | count_entries "${FIELD}" | wc -l)
|
| 159 |
other_count=$(echo "${OTHER}" | count_entries "${FIELD}" | wc -l)
|
| 160 |
fixed_count=$(echo "${FIXED}" | count_entries "${FIELD}" | wc -l)
|
| 161 |
;; |
| 162 |
'pkg' | *) |
| 163 |
remote_count=$(echo "${REMOTE}" | wc -l)
|
| 164 |
high_count=$(echo "${HIGH}" | wc -l)
|
| 165 |
medium_count=$(echo "${MEDIUM}" | wc -l)
|
| 166 |
low_count=$(echo "${LOW}" | wc -l)
|
| 167 |
other_count=$(echo "${OTHER}" | wc -l)
|
| 168 |
fixed_count=$(echo "${FIXED}" | wc -l)
|
| 169 |
;; |
| 170 |
esac |
| 171 |
|
| 172 |
# Reformat the output of the cut|sort|uniq... to a more human-friendly "item (count)" format |
| 173 |
CVECOUNTRE='s/^ *\([0-9]\+\) \+\([^ ]\+\)/\2 (\1)/' |
| 174 |
|
| 175 |
# shellcheck disable=SC2005 disable=SC2046 |
| 176 |
# The nested $(echo ...)s are needed to yet the newlines |
| 177 |
cat <<EOF |
| 178 |
remote.value $remote_count |
| 179 |
remote.extinfo $(echo $(echo "${REMOTE}" | count_entries "${FIELD}" | sort -nr | sed "${CVECOUNTRE}"))
|
| 180 |
high.value $high_count |
| 181 |
high.extinfo $(echo $(echo "${HIGH}" | count_entries "${FIELD}" | sort -nr | sed "${CVECOUNTRE}"))
|
| 182 |
medium.value $medium_count |
| 183 |
medium.extinfo $(echo $(echo "${MEDIUM}" | count_entries "${FIELD}" | sort -nr | sed "${CVECOUNTRE}"))
|
| 184 |
low.value $low_count |
| 185 |
low.extinfo $(echo $(echo "${LOW}" | count_entries "${FIELD}" | sort -nr | sed "${CVECOUNTRE}"))
|
| 186 |
other.value $other_count |
| 187 |
other.extinfo $(echo $(echo "${OTHER}" | count_entries "${FIELD}" | sort -nr | sed "${CVECOUNTRE}"))
|
| 188 |
fixed.value $fixed_count |
| 189 |
fixed.extinfo $(echo $(echo "${FIXED}" | count_entries "${FIELD}" | sort -nr | sed "${CVECOUNTRE}"))
|
| 190 |
EOF |
