|
| 1 | +#!/bin/bash |
| 2 | +# Copyright 2020 Google LLC |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +set -eu |
| 17 | + |
| 18 | +WD="${HOME}/tsunami" |
| 19 | +REPOS="${WD}/repos" |
| 20 | +PLUGINS="${WD}/plugins" |
| 21 | + |
| 22 | +mkdir -p "${REPOS}" |
| 23 | +mkdir -p "${PLUGINS}" |
| 24 | + |
| 25 | +# Clone repos. |
| 26 | +pushd "${REPOS}" >/dev/null |
| 27 | + |
| 28 | +printf "\nFetching source code for Tsunami scanner ...\n" |
| 29 | +if [[ ! -d "tsunami-security-scanner" ]] ; then |
| 30 | + git clone https://github.com/google/tsunami-security-scanner |
| 31 | +fi |
| 32 | +printf "\nFetching source code for Tsunami scanner plugins ...\n" |
| 33 | +if [[ ! -d "tsunami-security-scanner-plugins" ]] ; then |
| 34 | + git clone https://github.com/google/tsunami-security-scanner-plugins |
| 35 | +fi |
| 36 | +popd >/dev/null |
| 37 | + |
| 38 | +# Build all plugins. |
| 39 | +pushd "${REPOS}/tsunami-security-scanner-plugins/google" >/dev/null |
| 40 | +printf "\nBuilding all Google plugins ...\n" |
| 41 | +./build_all.sh |
| 42 | +cp build/plugins/*.jar "${PLUGINS}" |
| 43 | +popd >/dev/null |
| 44 | + |
| 45 | +# Build the scanner. |
| 46 | +pushd "${REPOS}/tsunami-security-scanner" >/dev/null |
| 47 | +printf "\nBuilding Tsunami scanner jar file ...\n" |
| 48 | +./gradlew shadowJar |
| 49 | +JAR=$(find "${REPOS}/tsunami-security-scanner" -name 'tsunami-main-*-cli.jar') |
| 50 | +JAR_FILENAME=$(basename -- "${JAR}") |
| 51 | +cp "${JAR}" "${WD}" |
| 52 | +cp "${REPOS}/tsunami-security-scanner/tsunami.yaml" "${WD}" |
| 53 | +popd >/dev/null |
| 54 | + |
| 55 | +printf "\nBuild successful, execute the following command to scan 127.0.0.1:\n" |
| 56 | +printf "\ncd ${WD} && \\\\\n" |
| 57 | +printf "java -cp \"${JAR_FILENAME}:${WD}/plugins/*\" \\\\\n" |
| 58 | +printf " -Dtsunami-config.location=${WD}/tsunami.yaml \\\\\n" |
| 59 | +printf " com.google.tsunami.main.cli.TsunamiCli \\\\\n" |
| 60 | +printf " --ip-v4-target=127.0.0.1 \\\\\n" |
| 61 | +printf " --scan-results-local-output-format=JSON \\\\\n" |
| 62 | +printf " --scan-results-local-output-filename=/tmp/tsunami-output.json\n" |
0 commit comments