Projet

Général

Profil

Révision 75a476c2

ID75a476c2a7164f1f6e172d65f7a53e4ea37c7e67
Parent be789bca
Enfant b2d742b2

Ajouté par Olivier Mehani il y a plus de 8 ans

[debian/debsecan_] Code cleanup

Signed-off-by: Olivier Mehani <>

Voir les différences:

plugins/debian/debsecan_
74 74
case "${MODE}" in
75 75
	'cve')
76 76
		TITLE_ADD="unique "
77
		CUT_FIELD=1
77
		FIELD=1
78 78
		;;
79 79
	'pkg' | *)
80 80
		TITLE_ADD="package "
81
		CUT_FIELD=2
81
		FIELD=2
82 82
		;;
83 83
esac
84 84

  
85 85
if [ "$1" = "config" ] ; then
86 86
  cat <<EOF_
87
graph_title DebSecan : ${TITLE_ADD}vulnerabilities for ${SUITE}
87
graph_title DebSecan: ${TITLE_ADD}vulnerabilities for ${SUITE}
88 88
graph_args -l 0 --base 1000
89 89
graph_vlabel number of CVE
90 90
graph_category system
......
134 134
fi
135 135

  
136 136
ALL=$(debsecan --suite "${SUITE}" 2> /dev/null)
137
REMOTE=$(echo "$ALL" | grep 'remotely')
138
NONREMOTE=$(echo "$ALL" | grep -v 'remotely')
137
REMOTE=$(echo "$ALL" | grep -w 'remotely')
138
NONREMOTE=$(echo "$ALL" | grep -wv 'remotely')
139 139

  
140
HIGH=$(echo "${NONREMOTE}" | grep 'high urgency')
141
MEDIUM=$(echo "${NONREMOTE}" | grep 'medium urgency')
142
LOW=$(echo "${NONREMOTE}" | grep 'low urgency')
143
OTHER=$(echo "${NONREMOTE}" | grep -v 'urgency')
144
FIXED=$(echo "${ALL}" | grep '(fixed')
140
HIGH=$(echo "${NONREMOTE}" | grep -w 'high urgency')
141
MEDIUM=$(echo "${NONREMOTE}" | grep -w 'medium urgency')
142
LOW=$(echo "${NONREMOTE}" | grep -w 'low urgency')
143
OTHER=$(echo "${NONREMOTE}" | grep -wv 'urgency')
144
FIXED=$(echo "${ALL}" | grep -w '(fixed')
145

  
146
# Arguments: Field offset to aggregate by
147
count_entries() {
148
	CUT_FIELD=${1}
149
	cut -f "${CUT_FIELD}" -d " "| sort | uniq -c
150
}
145 151

  
146 152
case "${MODE}" in
147 153
	'cve')
148
		remote_count=$(echo "${REMOTE}" | cut -f "${CUT_FIELD}" -d " "| sort | uniq | wc -l)
149
		high_count=$(echo "${HIGH}" | cut -f "${CUT_FIELD}" -d " "| sort | uniq | wc -l)
150
		medium_count=$(echo "${MEDIUM}" | cut -f "${CUT_FIELD}" -d " "| sort | uniq | wc -l)
151
		low_count=$(echo "${LOW}" | cut -f "${CUT_FIELD}" -d " "| sort | uniq | wc -l)
152
		other_count=$(echo "${OTHER}" | cut -f "${CUT_FIELD}" -d " "| sort | uniq | wc -l)
153
		fixed_count=$(echo "${FIXED}" | cut -f "${CUT_FIELD}" -d " "| sort | uniq | wc -l)
154
		remote_count=$(echo "${REMOTE}" | count_entries ${FIELD} | wc -l)
155
		high_count=$(echo "${HIGH}" | count_entries ${FIELD} | wc -l)
156
		medium_count=$(echo "${MEDIUM}" | count_entries ${FIELD} | wc -l)
157
		low_count=$(echo "${LOW}" | count_entries ${FIELD} | wc -l)
158
		other_count=$(echo "${OTHER}" | count_entries ${FIELD} | wc -l)
159
		fixed_count=$(echo "${FIXED}" | count_entries ${FIELD} | wc -l)
154 160
		;;
155 161
	'pkg' | *)
156 162
		remote_count=$(echo "${REMOTE}" | wc -l)
......
169 175
# The nested $(echo ...)s are needed to yet the newlines
170 176
cat <<EOF
171 177
remote.value $remote_count
172
remote.extinfo $(echo $(echo "${REMOTE}" | cut -f "${CUT_FIELD}" -d " "| sort | uniq -c | sort -nr | sed "${CVECOUNTRE}"))
178
remote.extinfo $(echo $(echo "${REMOTE}" | count_entries ${FIELD} | sort -nr | sed "${CVECOUNTRE}"))
173 179
high.value $high_count
174
high.extinfo $(echo $(echo "${HIGH}" | cut -f "${CUT_FIELD}" -d " " | sort | uniq -c | sort -nr | sed "${CVECOUNTRE}"))
180
high.extinfo $(echo $(echo "${HIGH}" | count_entries ${FIELD} | sort -nr | sed "${CVECOUNTRE}"))
175 181
medium.value $medium_count
176
medium.extinfo $(echo $(echo "${MEDIUM}" | cut -f "${CUT_FIELD}" -d " " | sort | uniq -c | sort -nr | sed "${CVECOUNTRE}"))
182
medium.extinfo $(echo $(echo "${MEDIUM}" | count_entries ${FIELD} | sort -nr | sed "${CVECOUNTRE}"))
177 183
low.value $low_count
178
low.extinfo $(echo $(echo "${LOW}" | cut -f "${CUT_FIELD}" -d " " | sort | uniq -c | sort -nr | sed "${CVECOUNTRE}"))
184
low.extinfo $(echo $(echo "${LOW}" | count_entries ${FIELD} | sort -nr | sed "${CVECOUNTRE}"))
179 185
other.value $other_count
180
other.extinfo $(echo $(echo "${OTHER}" | cut -f "${CUT_FIELD}" -d " " | sort | uniq -c | sort -nr | sed "${CVECOUNTRE}"))
186
other.extinfo $(echo $(echo "${OTHER}" | count_entries ${FIELD} | sort -nr | sed "${CVECOUNTRE}"))
181 187
fixed.value $fixed_count
182
fixed.extinfo $(echo $(echo "${FIXED}" | cut -f "${CUT_FIELD}" -d " " | sort | uniq -c | sort -nr | sed "${CVECOUNTRE}"))
188
fixed.extinfo $(echo $(echo "${FIXED}" | count_entries ${FIELD} | sort -nr | sed "${CVECOUNTRE}"))
183 189
EOF

Formats disponibles : Unified diff