-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into build/go-formatter
- Loading branch information
Showing
10 changed files
with
432 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Keep cleaning up even if something fails | ||
set +e | ||
|
||
# Stop all MySQL containers. | ||
|
||
VERSIONS="3.12.14 3.13.2" | ||
|
||
for version in $MYSQL_VERSIONS; do | ||
CONTAINER_NAME="zgrab_amqp091-$version" | ||
echo "amqp091/cleanup: Stopping $CONTAINER_NAME..." | ||
docker stop $CONTAINER_NAME | ||
echo "amqp091/cleanup: ...stopped." | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash -e | ||
|
||
VERSIONS="3.12.14 3.13.2" | ||
|
||
function launch() { | ||
VERSION=$1 | ||
CONTAINER_NAME="zgrab_amqp091-$VERSION" | ||
if docker ps --filter "name=$CONTAINER_NAME" | grep -q $CONTAINER_NAME; then | ||
echo "amqp091/setup: Container $CONTAINER_NAME already running -- skipping launch..." | ||
return | ||
fi | ||
docker run -td --rm --name $CONTAINER_NAME rabbitmq:$VERSION | ||
} | ||
|
||
function waitFor() { | ||
VERSION=$1 | ||
CONTAINER_NAME=zgrab_amqp091-$VERSION | ||
echo "amqp091/setup: Waiting for $CONTAINER_NAME to become ready..." | ||
while ! (docker logs --tail all $CONTAINER_NAME | grep -q "started TCP listener on"); do | ||
echo -n "." | ||
sleep 1 | ||
done | ||
for i in $(seq 1 5); do | ||
echo -n "*" | ||
sleep 1 | ||
done | ||
echo "...ok." | ||
} | ||
|
||
echo "amqp091/setup: Launching docker containers..." | ||
for version in $VERSIONS; do | ||
launch $version | ||
done | ||
|
||
for version in $VERSIONS; do | ||
waitFor $version | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
VERSIONS="3.12.14 3.13.2" | ||
|
||
# Run the AMQP-specific integration tests: | ||
# 1. Run zgrab2 on the container | ||
# 2. Check that data.amqp091.result.server_properties.version matches $MQ_VERSION | ||
|
||
ZGRAB_ROOT=$(git rev-parse --show-toplevel) | ||
ZGRAB_OUTPUT=$ZGRAB_ROOT/zgrab-output | ||
|
||
status=0 | ||
|
||
function doTest() { | ||
MQ_VERSION=$1 | ||
|
||
SUFFIX="" | ||
AUTH_ARGS="" | ||
if [[ -n "$2" ]]; then | ||
AUTH_ARGS=$2 | ||
SUFFIX="-auth" | ||
fi | ||
CONTAINER_NAME="zgrab_amqp091-${MQ_VERSION}" | ||
OUTPUT_FILE="$ZGRAB_OUTPUT/amqp091/${MQ_VERSION}${SUFFIX}.json" | ||
echo "amqp091/test: Testing RabbitMQ Version ${MQ_VERSION}${SUFFIX}..." | ||
CONTAINER_NAME=$CONTAINER_NAME $ZGRAB_ROOT/docker-runner/docker-run.sh amqp091 $AUTH_ARGS --timeout 10s >$OUTPUT_FILE | ||
SERVER_VERSION=$(jp -u data.amqp091.result.server_properties.version <$OUTPUT_FILE) | ||
if [[ "$SERVER_VERSION" == "$MQ_VERSION" ]]; then | ||
echo "amqp091/test: Server version matches expected version: $SERVER_VERSION == $MQ_VERSION" | ||
else | ||
echo "amqp091/test: Server version mismatch: Got $SERVER_VERSION, expected $MQ_VERSION. Full output: [[" | ||
cat $OUTPUT_FILE | ||
echo "]]" | ||
status=1 | ||
fi | ||
|
||
if [[ -n "$AUTH_ARGS" ]]; then | ||
AUTH_SUCCESS=$(jp -u data.amqp091.result.auth_success <$OUTPUT_FILE) | ||
if [[ "$AUTH_SUCCESS" == "true" ]]; then | ||
echo "amqp091/test: Auth test successful" | ||
else | ||
echo "amqp091/test: Auth test failed" | ||
status=1 | ||
fi | ||
fi | ||
|
||
echo "amqp091/test: BEGIN docker+amqp091 logs from $CONTAINER_NAME [{(" | ||
docker logs --tail all $CONTAINER_NAME | ||
echo ")}] END docker+amqp091 logs from $CONTAINER_NAME" | ||
} | ||
|
||
mkdir -p $ZGRAB_OUTPUT/amqp091 | ||
|
||
for version in $VERSIONS; do | ||
doTest $version | ||
doTest $version "--auth-user guest --auth-pass guest" | ||
done | ||
|
||
exit $status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package modules | ||
|
||
import "github.com/zmap/zgrab2/modules/amqp091" | ||
|
||
func init() { | ||
amqp091.RegisterModule() | ||
} |
Oops, something went wrong.