[Secure-testing-commits] r17262 - bin
Raphael Geissert
geissert at alioth.debian.org
Mon Sep 19 23:46:28 UTC 2011
Author: geissert
Date: 2011-09-19 23:46:28 +0000 (Mon, 19 Sep 2011)
New Revision: 17262
Modified:
bin/gen-DSA
Log:
Automatically find a suitable DSA id
Usage: bin/gen-DSA package vuln ...
Modified: bin/gen-DSA
===================================================================
--- bin/gen-DSA 2011-09-19 22:40:30 UTC (rev 17261)
+++ bin/gen-DSA 2011-09-19 23:46:28 UTC (rev 17262)
@@ -31,8 +31,8 @@
exit 1
}
-[ $# -ge 3 ] || {
- echo "usage: $0 [--save] DSA package vulnerability [cve(s) [bugnumber]]" >&2
+[ $# -ge 2 ] || {
+ echo "usage: $0 [--save] [DSA] package vulnerability [cve(s) [bugnumber]]" >&2
exit 1
}
@@ -42,12 +42,17 @@
shift
fi
-DSAID="$1"
-PACKAGE="$(printf '%s' "$2" | tr "[:upper:]" "[:lower:]")"
-VULNERABILITY="$3"
-CVE="$(printf '%s' "$4" | tr "[:lower:]" "[:upper:]")"
-BUGNUM="$5"
+DSAID=
+if printf '%s' "$1" | grep -Eq '^[0-9]+(-[0-9]+|)$'; then
+ DSAID="$1"
+ shift
+fi
+PACKAGE="$(printf '%s' "$1" | tr "[:upper:]" "[:lower:]")"
+VULNERABILITY="$2"
+CVE="$(printf '%s' "$3" | tr "[:lower:]" "[:upper:]")"
+BUGNUM="$4"
+
CVE="$(printf '%s' "$CVE" | sed 's/[ ,;]+/ /g' | tr ' ' "\n" | sort -n | tr "\n" ' ')"
cve_spacing=
@@ -58,7 +63,7 @@
CVE_LIST="$(printf '%s' "$CVE" | sed -r "$sed_cmd")"
case "$DSAID" in
- *-*)
+ *-*|'')
:
;;
*)
@@ -67,7 +72,27 @@
;;
esac
-if grep -wq "DSA-$DSAID" data/DSA/list; then
+dsa_exists() {
+ grep -wq "DSA-$1" data/DSA/list
+}
+
+if [ -z "$DSAID" ]; then
+ latest_dsa="$(sed -r '/DSA-/{s/^.+DSA-([0-9]+).*$/\1/;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
+ echo "error: unable to find an unused DSA id after $c attempts" >&2
+ echo "to workaround specify an id as the first parameter" >&2
+ exit 1
+ fi
+ done
+ DSAID="$dsa-1"
+fi
+
+if dsa_exists "$DSAID"; then
echo "error: DSA-$DSAID has already been used" >&2
exit 1
fi
More information about the Secure-testing-commits
mailing list