zgrab2/test_mysql_version.sh
justinbastress a244ec15e6 TLS scan prototype + Travis integration (#25)
* Fix typo

* Actually call init per sender for each goroutine

* split out TLS handling

* Rename tls_handshake; update docs

* fix comments

* format fixes

* merge updates

* fix path

* refactor heartbleed logging (now the same as original zgrab)

* add ScanStatus, update modules to return it

* fix threaded for loop; fix styling of dict literal

* fix compile errors, note un-bubbled handshake error

* initial schema commit

* fix comment

* schema cleanup

* comments

* fix TODOs

* first attempt at docker integration in travis; also add schema validation

* add integration_tests.sh

* need sudo?

* try pip install --user

* revert regression

* add docker service again

* chmod +x integration_tests.sh

* fix path of binary

* Dump output file to stdout

* travis work

* use jp's build-self-contained script

* use go get/go build to get jp

* fix jp path

* switch from bogus regex to wildcard

* do all mysql versions; fix version comparison

* re-enable notifications; fix successful version check log message; comment TryGetScanStatus

* move to conf.d layout for integration tests

* update README

* add missing scripts

* add ./ to path
2017-12-15 09:25:17 -05:00

57 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
if [ "$#" -lt 1 ]; then
echo "Usage:"
echo ""
echo " $0 [version]"
echo ""
echo "[version] should be one of the supported tags listed at https://hub.docker.com/_/mysql/"
echo ""
echo "Example:"
echo ""
echo " $0 5.5"
echo ""
exit 1
fi
SQL_VERSION="$1"
CONTAINER_NAME="testmysql-$SQL_VERSION"
OUTPUT_FILE="out-$SQL_VERSION.json"
shift
echo "Starting the mysql $SQL_VERSION container (forwarding localhost:3306 -> container:3306)..."
set -x
if ! docker run -itd -p 3306:3306 --rm --name $CONTAINER_NAME -e MYSQL_ROOT_PASSWORD=rootPassword mysql:$SQL_VERSION; then
echo "Error running mysql:$SQL_VERSION docker instance: $?"
exit 1
fi
set +x
function cleanup {
echo "Stopping $CONTAINER_NAME..."
docker stop $CONTAINER_NAME
echo "Stopped."
}
trap cleanup EXIT SIGINT
set +e
pushd cmd/zgrab2
go build -o ../../zgrab2
popd
CONTAINER_NAME=$CONTAINER_NAME MYSQLD_PORT=3306 ./wait_for_mysqld.sh
set -x
echo "127.0.0.1" | ./zgrab2 mysql $* > $OUTPUT_FILE
set +x
SERVER_VERSION=$(jp data.mysql.result.handshake.parsed.server_version < $OUTPUT_FILE)
if [[ "$SERVER_VERSION" =~ "$SQL_VERSION\..*" ]]; then
echo "Server version matches expected version: $SERVER_VERSION =~ $SQL_VERSION"
else
echo "Server versiom mismatch: Got $SERVER_VERSION, expected $SQL_VERSION.*"
exit 1
fi