diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 00000000..9c24aeb9 --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -0,0 +1,25 @@ +name: Integration Test +on: [push, pull_request] +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18 + + - name: Check out source + uses: actions/checkout@v4 + + - name: Prep test dependencies + run: | + set -e + sudo wget https://github.com/jmespath/jp/releases/download/0.2.1/jp-linux-amd64 -O /usr/local/bin/jp + sudo chmod +x /usr/local/bin/jp + pip install --user zschema + + - name: Run tests + run: | + make integration-test \ No newline at end of file diff --git a/docker-runner/docker-run.sh b/docker-runner/docker-run.sh index 074a8107..a13ed284 100755 --- a/docker-runner/docker-run.sh +++ b/docker-runner/docker-run.sh @@ -7,4 +7,4 @@ : "${CONTAINER_NAME:?}" set -e -docker run --rm --link $CONTAINER_NAME:target -e ZGRAB_TARGET=target zgrab2_runner $@ +echo 'target' | docker run --rm -i --link $CONTAINER_NAME:target zgrab2_runner $@ diff --git a/integration_tests/.template/test.sh b/integration_tests/.template/test.sh index 650cea14..749de495 100755 --- a/integration_tests/.template/test.sh +++ b/integration_tests/.template/test.sh @@ -2,7 +2,7 @@ set -e MODULE_DIR=$(dirname $0) -ZGRAB_ROOT=$MODULE_DIR/../.. +ZGRAB_ROOT=$(git rev-parse --show-toplevel) ZGRAB_OUTPUT=$ZGRAB_ROOT/zgrab-output mkdir -p $ZGRAB_OUTPUT/#{MODULE_NAME} diff --git a/integration_tests/ftp/test.sh b/integration_tests/ftp/test.sh index 2810bef3..daa1088b 100755 --- a/integration_tests/ftp/test.sh +++ b/integration_tests/ftp/test.sh @@ -3,7 +3,7 @@ set -e MODULE_DIR=$(dirname $0) TEST_ROOT=$MODULE_DIR/.. -ZGRAB_ROOT=$MODULE_DIR/../.. +ZGRAB_ROOT=$(git rev-parse --show-toplevel) ZGRAB_OUTPUT=$ZGRAB_ROOT/zgrab-output CONTAINER_NAME="zgrab_ftp" diff --git a/integration_tests/http/test.sh b/integration_tests/http/test.sh index 4604b01b..7915af7f 100755 --- a/integration_tests/http/test.sh +++ b/integration_tests/http/test.sh @@ -3,7 +3,7 @@ set -e MODULE_DIR=$(dirname $0) TEST_ROOT=$MODULE_DIR/.. -ZGRAB_ROOT=$MODULE_DIR/../.. +ZGRAB_ROOT=$(git rev-parse --show-toplevel) ZGRAB_OUTPUT=$ZGRAB_ROOT/zgrab-output OUTPUT_ROOT=$ZGRAB_OUTPUT/http diff --git a/integration_tests/ipp/test.sh b/integration_tests/ipp/test.sh index 5eca45aa..8fac7b66 100755 --- a/integration_tests/ipp/test.sh +++ b/integration_tests/ipp/test.sh @@ -2,7 +2,7 @@ set -e MODULE_DIR=$(dirname $0) -ZGRAB_ROOT=$MODULE_DIR/../.. +ZGRAB_ROOT=$(git rev-parse --show-toplevel) ZGRAB_OUTPUT=$ZGRAB_ROOT/zgrab-output OUTPUT_ROOT=$ZGRAB_OUTPUT/ipp diff --git a/integration_tests/mongodb/test.sh b/integration_tests/mongodb/test.sh index 4552ef55..e784357e 100755 --- a/integration_tests/mongodb/test.sh +++ b/integration_tests/mongodb/test.sh @@ -5,7 +5,7 @@ set -e versions="3.2.20 3.6.6 4.0.1 4.1.2" MODULE_DIR=$(dirname $0) -ZGRAB_ROOT=$MODULE_DIR/../.. +ZGRAB_ROOT=$(git rev-parse --show-toplevel) ZGRAB_OUTPUT=$ZGRAB_ROOT/zgrab-output mkdir -p $ZGRAB_OUTPUT/mongodb diff --git a/integration_tests/mssql/setup.sh b/integration_tests/mssql/setup.sh index 584f4e0d..a4b7a0c8 100755 --- a/integration_tests/mssql/setup.sh +++ b/integration_tests/mssql/setup.sh @@ -2,8 +2,8 @@ echo "mssql/setup: Tests setup for mssql" -CONTAINER_IMAGE="microsoft/mssql-server-linux" -CONTAINER_VERSION="2017-CU3" +CONTAINER_IMAGE="mcr.microsoft.com/mssql/server" +CONTAINER_VERSION="2017-latest" CONTAINER_NAME="zgrab_mssql-2017-linux" # Supported MSSQL_PRODUCT_ID values are Developer, Express, Standard, Enterprise, EnterpriseCore diff --git a/integration_tests/mssql/test.sh b/integration_tests/mssql/test.sh index 521910fa..8571dfaf 100755 --- a/integration_tests/mssql/test.sh +++ b/integration_tests/mssql/test.sh @@ -3,7 +3,7 @@ set -e MODULE_DIR=$(dirname $0) TEST_ROOT=$MODULE_DIR/.. -ZGRAB_ROOT=$MODULE_DIR/../.. +ZGRAB_ROOT=$(git rev-parse --show-toplevel) ZGRAB_OUTPUT=$ZGRAB_ROOT/zgrab-output CONTAINER_NAME="zgrab_mssql-2017-linux" diff --git a/integration_tests/mysql/test.sh b/integration_tests/mysql/test.sh index fe62f468..ecc0ff58 100755 --- a/integration_tests/mysql/test.sh +++ b/integration_tests/mysql/test.sh @@ -9,7 +9,7 @@ versions="5.5 5.6 5.7 8.0" MODULE_DIR=$(dirname $0) TEST_ROOT=$MODULE_DIR/.. -ZGRAB_ROOT=$MODULE_DIR/../.. +ZGRAB_ROOT=$(git rev-parse --show-toplevel) ZGRAB_OUTPUT=$ZGRAB_ROOT/zgrab-output status=0 diff --git a/integration_tests/ntp/test.sh b/integration_tests/ntp/test.sh index bfc1343e..a0c8c635 100755 --- a/integration_tests/ntp/test.sh +++ b/integration_tests/ntp/test.sh @@ -3,7 +3,7 @@ set -e MODULE_DIR=$(dirname $0) TEST_ROOT=$MODULE_DIR/.. -ZGRAB_ROOT=$MODULE_DIR/../.. +ZGRAB_ROOT=$(git rev-parse --show-toplevel) ZGRAB_OUTPUT=$ZGRAB_ROOT/zgrab-output OUTPUT_ROOT=$ZGRAB_OUTPUT/ntp diff --git a/integration_tests/pop3/test.sh b/integration_tests/pop3/test.sh index b28129d0..56ba5f32 100755 --- a/integration_tests/pop3/test.sh +++ b/integration_tests/pop3/test.sh @@ -2,7 +2,7 @@ set -e MODULE_DIR=$(dirname $0) -ZGRAB_ROOT=$MODULE_DIR/../.. +ZGRAB_ROOT=$(git rev-parse --show-toplevel) ZGRAB_OUTPUT=$ZGRAB_ROOT/zgrab-output mkdir -p $ZGRAB_OUTPUT/pop3 diff --git a/integration_tests/postgres/test.sh b/integration_tests/postgres/test.sh index dedb4031..1ee85406 100755 --- a/integration_tests/postgres/test.sh +++ b/integration_tests/postgres/test.sh @@ -5,7 +5,7 @@ set -e versions="9.3 9.4 9.5 9.6 10.1" types="ssl nossl" -ZGRAB_ROOT=$(dirname $0)/../.. +ZGRAB_ROOT=$(git rev-parse --show-toplevel) ZGRAB_OUTPUT=$ZGRAB_ROOT/zgrab-output mkdir -p $ZGRAB_OUTPUT/postgres diff --git a/integration_tests/redis/test.sh b/integration_tests/redis/test.sh index 555575a3..18d41b52 100755 --- a/integration_tests/redis/test.sh +++ b/integration_tests/redis/test.sh @@ -2,7 +2,7 @@ set -e MODULE_DIR=$(dirname $0) -ZGRAB_ROOT=$MODULE_DIR/../.. +ZGRAB_ROOT=$(git rev-parse --show-toplevel) ZGRAB_OUTPUT=$ZGRAB_ROOT/zgrab-output # FIXME: Find a way to mount host to container and have it pass CircleCI tests. diff --git a/integration_tests/setup.sh b/integration_tests/setup.sh index e4be6954..8c140227 100755 --- a/integration_tests/setup.sh +++ b/integration_tests/setup.sh @@ -12,7 +12,7 @@ set -e # Run from root of project TEST_DIR=$(dirname "$0") -ZGRAB_ROOT="$TEST_DIR/.." +ZGRAB_ROOT=$(git rev-parse --show-toplevel) cd "$ZGRAB_ROOT" echo "Setting up integration tests..." diff --git a/integration_tests/smtp/test.sh b/integration_tests/smtp/test.sh index ad08cad8..37dde58e 100755 --- a/integration_tests/smtp/test.sh +++ b/integration_tests/smtp/test.sh @@ -2,7 +2,7 @@ set -e MODULE_DIR=$(dirname $0) -ZGRAB_ROOT=$MODULE_DIR/../.. +ZGRAB_ROOT=$(git rev-parse --show-toplevel) ZGRAB_OUTPUT=$ZGRAB_ROOT/zgrab-output mkdir -p $ZGRAB_OUTPUT/smtp diff --git a/integration_tests/ssh/test.sh b/integration_tests/ssh/test.sh index a974df0e..97abf3e6 100755 --- a/integration_tests/ssh/test.sh +++ b/integration_tests/ssh/test.sh @@ -3,7 +3,7 @@ set -e MODULE_DIR=$(dirname $0) TEST_ROOT=$MODULE_DIR/.. -ZGRAB_ROOT=$MODULE_DIR/../.. +ZGRAB_ROOT=$(git rev-parse --show-toplevel) ZGRAB_OUTPUT=$ZGRAB_ROOT/zgrab-output CONTAINER_NAME="zgrab_ssh" diff --git a/integration_tests/telnet/test.sh b/integration_tests/telnet/test.sh index 153807d2..75c03267 100755 --- a/integration_tests/telnet/test.sh +++ b/integration_tests/telnet/test.sh @@ -2,7 +2,7 @@ set -e MODULE_DIR=$(dirname $0) -ZGRAB_ROOT=$MODULE_DIR/../.. +ZGRAB_ROOT=$(git rev-parse --show-toplevel) ZGRAB_OUTPUT=$ZGRAB_ROOT/zgrab-output mkdir -p $ZGRAB_OUTPUT/telnet diff --git a/integration_tests/test.sh b/integration_tests/test.sh index 2fdea2a9..cee763e9 100755 --- a/integration_tests/test.sh +++ b/integration_tests/test.sh @@ -29,7 +29,7 @@ set -o pipefail # Run from root of project TEST_DIR=$(dirname "$0") -ZGRAB_ROOT="$TEST_DIR/.." +ZGRAB_ROOT=$(git rev-parse --show-toplevel) INTEGRATION_TEST_VENV=".integration_tests.venv" cd "$ZGRAB_ROOT"