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
|
#!/bin/bash
set -e
export LC_ALL=C
url="file://$(pwd)"
debsecan="python ../src/debsecan"
# Check that python-apt is installed.
python -c "import apt_pkg"
for testcase in [0-9][0-9][0-9] ; do
for format in summary packages bugs detail report ; do
for suite in sid ; do
if test -e $testcase/$suite ; then
if test -e $testcase/options ; then
options="$(cat $testcase/options)"
else
options=""
fi
if test -e $testcase/whitelist ; then
options="$options --whitelist $testcase/whitelist"
else
options="$options --whitelist ''"
fi
if $debsecan $options \
--config /dev/null \
--suite $suite \
--source "$url/$testcase" \
--history $testcase/history \
--status $testcase/status \
--format $format > $testcase/out.$format 2>&1 ; then
if test $format = summary ; then
sort $testcase/out.$format > $testcase/out.$format.1
mv $testcase/out.$format.1 $testcase/out.$format
fi
diff -u $testcase/exp.$format $testcase/out.$format
else
echo "FAIL: debsecan failed. Output follows:"
cat $testcase/out.$format
exit 1
fi
fi
done
done
done
# Test the whitelist editing functionality.
rm -f whitelist.test
$debsecan --whitelist whitelist.test --add-whitelist CAN-2006-0001
cat > whitelist.exp <<EOF
VERSION 0
CAN-2006-0001,
EOF
diff -u whitelist.test whitelist.exp
$debsecan --whitelist whitelist.test --add-whitelist CAN-2006-0001 CAN-2006-0002
cat > whitelist.exp <<EOF
VERSION 0
CAN-2006-0001,
CAN-2006-0002,
EOF
diff -u whitelist.test whitelist.exp
$debsecan --whitelist whitelist.test --add-whitelist CAN-2006-0001 pkg1 CAN-2006-0003 pkg2 pkg3
cat > whitelist.exp <<EOF
VERSION 0
CAN-2006-0001,
CAN-2006-0002,
CAN-2006-0001,pkg1
CAN-2006-0003,pkg2
CAN-2006-0003,pkg3
EOF
diff -u whitelist.test whitelist.exp
$debsecan --whitelist whitelist.test --remove-whitelist CAN-2006-0003 pkg2
cat > whitelist.exp <<EOF
VERSION 0
CAN-2006-0001,
CAN-2006-0002,
CAN-2006-0001,pkg1
CAN-2006-0003,pkg3
EOF
diff -u whitelist.test whitelist.exp
$debsecan --whitelist whitelist.test --show-whitelist > whitelist.out
cat > whitelist.exp <<EOF
CAN-2006-0001 (all packages)
CAN-2006-0002 (all packages)
CAN-2006-0001 pkg1
CAN-2006-0003 pkg3
EOF
diff -u whitelist.out whitelist.exp
if $debsecan --whitelist whitelist.test \
--remove-whitelist CAN-2006-0003 pkg4 2>whitelist.out ; then
echo "FAILURE: --remove-whitelist on unknown package"
exit 1
else
cat > whitelist.exp <<EOF
error: no matching whitelist entry for CAN-2006-0003 pkg4
EOF
diff -u whitelist.out whitelist.exp
fi
if $debsecan --whitelist whitelist.test \
--remove-whitelist CAN-2006-9999 2>whitelist.out ; then
echo "FAILURE: --remove-whitelist on unknown bug"
exit 1
else
cat > whitelist.exp <<EOF
error: no matching whitelist entry for CAN-2006-9999
EOF
diff -u whitelist.out whitelist.exp
fi
$debsecan --whitelist whitelist.test --remove-whitelist CAN-2006-0003 CAN-2006-0001
cat > whitelist.exp <<EOF
VERSION 0
CAN-2006-0002,
EOF
diff -u whitelist.test whitelist.exp
|