test_taler_exchange_httpd_afl.sh (2095B)
1 #!/bin/bash 2 # 3 # This file is part of TALER 4 # Copyright (C) 2015, 2020 Taler Systems SA 5 # 6 # TALER is free software; you can redistribute it and/or modify it under the 7 # terms of the GNU Affero General Public License as published by the Free Software 8 # Foundation; either version 3, or (at your option) any later version. 9 # 10 # TALER is distributed in the hope that it will be useful, but WITHOUT ANY 11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. 13 # 14 # You should have received a copy of the GNU Affero General Public License along with 15 # TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> 16 # 17 # 18 # This script uses 'curl' to POST various ill-formed requests to the 19 # taler-exchange-httpd. Basically, the goal is to make sure that the 20 # HTTP server survives (and produces the 'correct' error code). 21 # 22 # We read the JSON snippets from afl-tests/ 23 # 24 # The afl-tests are generated as follows: 25 # 1) Capture all TCP traffic from 'test-auditor.sh' 26 # 2) Use 'tcpflow -e http -r $PCAP -o $OUTPUT' to get the HTTP streams 27 # 3) Remove HTTP streams unrelated to the exchange as well as the replies 28 # 4) Remove duplicated streams (check file size!) 29 # 5) Compile the exchange with AFL instrumentation 30 # 6) Run afl-fuzz -i $OUTPUT/ -o afl-tests/ ~/bin/taler-exchange-httpd \ 31 # -c test_taler_exchange_httpd.conf -t 1 -f @@ 32 33 set -eu 34 35 unset XDG_DATA_HOME 36 unset XDG_CONFIG_HOME 37 PREFIX= 38 # Uncomment this line to run with valgrind... 39 #PREFIX="valgrind --leak-check=yes --track-fds=yes --error-exitcode=1 --log-file=valgrind.%p" 40 # Setup keys. 41 taler-exchange-keyup -c test_taler_exchange_httpd.conf 42 # Setup database 43 taler-exchange-dbinit -c test_taler_exchange_httpd.conf &> /dev/null 44 # Only log hard errors, we expect lots of warnings... 45 export GNUNET_FORCE_LOG=";;;;ERROR" 46 # Run test... 47 for n in afl-tests/* 48 do 49 echo -n "Test $n " 50 $PREFIX taler-exchange-httpd -c test_taler_exchange_httpd.conf -t 1 -f $n -C > /dev/null && echo "OK" || echo "FAIL" 51 done 52 exit 0