blob: 487b5fd0e73ecae805300b02511b3b88693205d5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
|
#!/bin/sh
####################
# Copyright (C) 2011 by Raphael Geissert <geissert@debian.org>
#
#
# This file is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
####################
set -e
OLDSTABLE=lenny
STABLE=squeeze
TESTING=wheezy
export LANG=C
[ -f doc/DSA.template ] || {
echo "error: call this script from the root of the repository" >&2
exit 1
}
[ $# -ge 2 ] || {
echo "usage: $0 [--save] [DSA] package 'vulnerability desc' [cve(s) [bugnumber]]"
echo " 'DSA' is the DSA number, required when issuing a revision"
echo " 'cve(s)' must be a space separated list in one arg"
exit 1
} >&2
save=false
if [ "$1" = "--save" ]; then
save=true
shift
fi
toupper() {
printf '%s' "$1" | tr '[:lower:]' '[:upper:]'
}
tolower() {
printf '%s' "$1" | tr '[:upper:]' '[:lower:]'
}
split_n_sort() {
printf '%s' "$1" | sed 's/[ ,;]+/ /g' | tr ' ' "\n" | sort -u |
sort -n | tr "\n" ' ' | sed -r 's/\s+/ /g;s/\s$//'
}
warn() {
printf "${YELLOW}warning:${NORMAL} %s\n" "$1"
}
notice() {
printf "${MAGENTA}notice:${NORMAL} %s\n" "$1"
}
error() {
printf "${RED}error:${NORMAL} %s\n" "$1"
}
check_spelling() {
if which aspell >/dev/null && echo test | aspell -l en list 2>/dev/null; then
aspell -l en list
elif which enchant >/dev/null && echo test | enchant -l -d en 2>/dev/null; then
enchant -l -d en
fi
}
cleanup_vulnerability() {
lastw=
add_space=false
for word in $@; do
if [ -n "$lastw" ]; then
add_space=true
fi
case $word in
D[Oo]S)
word="denial of service"
;;
CSRF)
word="cross-site request forgery"
;;
XSS)
word="cross-site scripting"
;;
site)
if [ "$lastw" = cross ]; then
add_space=false
word="-site"
fi
;;
[Nn]ull)
word=NULL
;;
out-of-bound|bound)
word="${word}s"
;;
esac
if $add_space; then
printf ' '
fi
lastw="$word"
printf '%s' "$word"
done
}
setvar() {
local var="$1" value="$2"
if [ -z "$value" ]; then
value="$(eval 'printf "%s" "$'"$var"'"')"
fi
sed -i "s=\$$var=$value=g" "$tmpf"
}
if which tput >/dev/null; then
RED=$(tput setaf 1)
YELLOW=$(tput setaf 3)
MAGENTA=$(tput setaf 5)
NORMAL=$(tput op)
else
RED=''
YELLOW=''
MAGENTA=''
NORMAL=''
fi
DSAID=
if printf '%s' "$1" | grep -Eq '^(DSA-|)[0-9]+(-[0-9]+|)$'; then
DSAID="${1#DSA-}"
shift
fi
PACKAGE="$(tolower "$1")"
VULNERABILITY="$(cleanup_vulnerability "$2")"
CVE="$(toupper "$3")"
BUGNUM="${4#\#}"
REFERENCES=0
TEXT=
CVE="$(split_n_sort "$CVE")"
cve_spacing=
for i in $(seq 0 16); do
cve_spacing="$cve_spacing "
done
sed_cmd='s/((CVE-[0-9-]+[ ]+){4})(.+)$/\1\\n'"$cve_spacing"'\3/g;P;D'
CVE_LIST="$(printf '%s' "$CVE" | sed -r "$sed_cmd")"
for id in $CVE; do
REFERENCES=$(($REFERENCES+1))
grep -wq "^$id" data/CVE/list || {
warn "'$id' is not known" >&2
}
TEXT="$TEXT\n\n$id\n\n Description"
done
if [ $REFERENCES -eq 1 ]; then
TEXT=
fi
if [ -n "$TEXT" ]; then
TEXT="Brief introduction $TEXT"
if ! $save; then
TEXT="The CVE ids will be listed here when --save'ing"
fi
fi
case "$DSAID" in
*-*|'')
:
;;
*)
notice "missing DSA revision number, assuming 1" >&2
DSAID="$DSAID-1"
;;
esac
dsa_exists() {
grep -wq "DSA-$1" data/DSA/list
}
if [ -z "$DSAID" ]; then
latest_dsa="$(sed -nr '/DSA-[0-9]+-1/{s/^.+DSA-([0-9]+).*$/\1/;p;q}' data/DSA/list)"
dsa=$(($latest_dsa+1))
c=0
while dsa_exists "$dsa-1"; do
dsa=$(($dsa+1))
c=$(($c+1))
if [ $c -eq 10 ]; then
error "unable to find an unused DSA id after $c attempts" >&2
error "to workaround specify an id as the first parameter" >&2
exit 1
fi
done
DSAID="$dsa-1"
fi
if dsa_exists "$DSAID"; then
error "DSA-$DSAID has already been used" >&2
exit 1
fi
if echo "$VULNERABILITY" | grep -iq vulnerab; then
warn "redundant vulnerability adjective/noun in vuln. summary" >&2
fi
if [ "$VULNERABILITY" = remote ] || [ "$VULNERABILITY" = local ]; then
error "'$VULNERABILITY' is not a vulnerability summary" >&2
exit 1
fi
echo "$VULNERABILITY" | check_spelling |
while read word; do
# Frequent exceptions:
case $word in
SQL)
continue
;;
esac
warn "possible spelling mistake: $word!" >&2
done
tmpf=$(mktemp)
cat doc/DSA.template > $tmpf
if [ "$VULNERABILITY" = regression ]; then
sed -ri '/^Subject:/s/security update$/regression update/' $tmpf
fi
if [ $REFERENCES -gt 1 ]; then
sed -ri 's/this problem has/these problems have/' $tmpf
fi
name_length=${#DEBFULLNAME}
spacing=$((24-$name_length))
SPACEDDEBFULLNAME="$DEBFULLNAME"
while [ $spacing -gt 0 ]; do
SPACEDDEBFULLNAME=" $SPACEDDEBFULLNAME"
spacing=$((spacing-1))
done
DATE="$(date +"%B %d, %Y")"
date_length=${#DATE}
spacing=$((22-$date_length))
SPACEDDATE="$DATE"
while [ $spacing -gt 0 ]; do
SPACEDDATE="$SPACEDDATE "
spacing=$((spacing-1))
done
setvar DEBEMAIL
setvar DEBFULLNAME
setvar SPACEDDEBFULLNAME
setvar PACKAGE
setvar CVE "$CVE_LIST"
setvar REMLOCAL "${REMLOCAL:-remote}"
setvar DSAID
setvar BUGNUM
setvar VULNERABILITY
setvar DEBIANSPECIFIC "${DEBIANSPECIFIC:-no}"
setvar OLDSTABLE
setvar STABLE
setvar TESTING
setvar SPACEDDATE
setvar DATE
setvar TEXT "${TEXT:-DSA text goes here}"
for dist in $OLDSTABLE $STABLE $TESTING UNSTABLE; do
version="$(eval 'printf "%s" "$'"$dist"_VERSION'"')"
if $save && [ -z "$version" ] && grep -q "${dist}_VERSION" "$tmpf"; then
printf "Enter $dist's version [unset]: "
read version
if [ -n "$version" ]; then
eval "${dist}_VERSION='$version'"
fi
fi
[ -z "$version" ] || setvar "${dist}_VERSION" "$version"
done
if ! $save; then
cat $tmpf
echo
echo " ---- "
echo "Pass --save as the first parameter to save the text to DSA-$DSAID"
echo "(the data/DSA/list entry will also be added)"
rm -f "$tmpf"
exit
else
mv -i $tmpf "DSA-$DSAID" || { rm -f $tmpf; exit; }
dsa_entry=$(mktemp)
cat <<EOF > $dsa_entry
[$(date +"%d %b %Y")] DSA-$DSAID $PACKAGE - $VULNERABILITY
EOF
if [ "$CVE" ]; then
printf "\t{%s}\n" "$CVE" >> $dsa_entry
fi
for dist in $OLDSTABLE $STABLE; do
version="$(eval 'printf "%s" "$'"$dist"_VERSION'"')"
[ -z "$version" ] || \
printf "\t[%s] - %s %s\n" "$dist" "$PACKAGE" "$version" >> $dsa_entry
done
tmp_list="$(mktemp)"
cat $dsa_entry data/DSA/list > $tmp_list
cat $tmp_list > data/DSA/list
rm -f $tmp_list
echo "DSA text written to ./DSA-$DSAID"
fi
|