diff --git a/google/fingerprinters/web/scripts/updater/community/grafana/app/docker-compose.yaml b/google/fingerprinters/web/scripts/updater/community/grafana/app/docker-compose.yaml new file mode 100644 index 000000000..646fe3f81 --- /dev/null +++ b/google/fingerprinters/web/scripts/updater/community/grafana/app/docker-compose.yaml @@ -0,0 +1,11 @@ +services: + grafana: + image: "grafana/grafana:${GRAFANA_VERSION}" + container_name: grafana + restart: unless-stopped + ports: + - '3000:3000' + volumes: + - grafana-storage:/var/lib/grafana +volumes: + grafana-storage: {} diff --git a/google/fingerprinters/web/scripts/updater/community/grafana/update.sh b/google/fingerprinters/web/scripts/updater/community/grafana/update.sh new file mode 100755 index 000000000..fb35b8627 --- /dev/null +++ b/google/fingerprinters/web/scripts/updater/community/grafana/update.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env bash + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +source ../../common.sh + +SCRIPT_PATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)" +# Root path to the web fingerprinter plugin. +PROJECT_ROOT="$(cd -- "${SCRIPT_PATH}/../../../.." >/dev/null 2>&1 ; pwd -P)" +# Path to the configurations for starting a live instance of Grafana. +APP_PATH="${SCRIPT_PATH}/app" +# Path to the temporary data holder. +TMP_DATA="/tmp/grafana_fingerprints" +# Path to the local git repository for Grafana codebase. +GIT_REPO="${TMP_DATA}/repo" +# Path to the directory of all the updated fingerprints data. +FINGERPRINTS_PATH="${TMP_DATA}/fingerprints" +# Json data of the final result. +JSON_DATA="${FINGERPRINTS_PATH}/fingerprint.json" +# Binary proto data of the final result. +BIN_DATA="${FINGERPRINTS_PATH}/fingerprint.binproto" +# Read all the versions to be fingerprinted. +readarray -t ALL_VERSIONS < "${SCRIPT_PATH}/versions.txt" +mkdir -p "${FINGERPRINTS_PATH}" + +BINPROTO="${PROJECT_ROOT}/src/main/resources/fingerprinters/web/data/community/grafana.binproto" +startGrafana() { + local version="$1" + pushd "${APP_PATH}" >/dev/null + # add COMPOSE_HTTP_TIMEOUT to avoid docker-compose errors + GRAFANA_VERSION="${version}" COMPOSE_HTTP_TIMEOUT=200 docker compose up --wait -d + popd >/dev/null +} + +stopGrafana() { + local version="$1" + pushd "${APP_PATH}" >/dev/null + GRAFANA_VERSION="${version}" COMPOSE_HTTP_TIMEOUT=200 docker compose down --volumes --remove-orphans + popd >/dev/null +} + +# Convert the existing data file to a human-readable json file. +convertFingerprint "${BINPROTO}" "${JSON_DATA}" + +# Fetch Grafana codebase. +if [[ ! -d "${GIT_REPO}" ]] ; then + git clone https://github.com/grafana/grafana.git "${GIT_REPO}" +fi + +# Update for all the versions listed in versions.txt file. +for git_version in "${ALL_VERSIONS[@]}"; do + version=${git_version#v} + echo "Fingerprinting Grafana version ${version} ..." + + # Start a live instance of Grafana. + echo "Waiting for Grafana ${version} to be ready ..." + startGrafana "${version}" + # No need to do other installation process for Grafana. + + # Checkout the repository to the correct tag. + checkOutRepo "${GIT_REPO}" "${git_version}" + + updateFingerprint \ + "grafana" \ + "${version}" \ + "${FINGERPRINTS_PATH}" \ + "${GIT_REPO}" \ + "http://localhost:3000" + + # Stop the live instance of Grafana. + stopGrafana "${version}" +done + +convertFingerprint "${JSON_DATA}" "${BIN_DATA}" + +echo "Fingerprint updated for Grafana. Please commit the following file:" +echo " ${BIN_DATA}" + diff --git a/google/fingerprinters/web/scripts/updater/community/grafana/versions.txt b/google/fingerprinters/web/scripts/updater/community/grafana/versions.txt new file mode 100644 index 000000000..e6233b2f3 --- /dev/null +++ b/google/fingerprinters/web/scripts/updater/community/grafana/versions.txt @@ -0,0 +1,348 @@ +v11.3.0 +v11.2.3 +v11.1.8 +v11.0.7 +v10.4.11 +v10.3.12 +v11.2.2 +v11.1.7 +v11.0.6 +v10.4.10 +v10.3.11 +v11.2.1 +v11.1.6 +v11.0.5 +v10.4.9 +v10.3.10 +v11.2.0 +v11.1.5 +v11.0.4 +v10.4.8 +v10.3.9 +v11.1.4 +v11.0.3 +v10.4.7 +v11.1.1 +v11.1.2 +v9.5.21 +v10.2.9 +v10.4.6 +v11.0.2 +v11.1.3 +v10.0.0 +v9.5.20 +v10.2.8 +v10.3.7 +v10.4.5 +v11.0.1 +v11.1.0 +v10.4.4 +v11.0.0 +v10.1.10 +v9.5.19 +v10.2.7 +v10.3.6 +v10.4.3 +v10.4.2 +v10.1.9 +v10.2.6 +v9.5.18 +v10.0.13 +v10.3.5 +v10.4.1 +v10.0.12 +v10.3.4 +v10.2.5 +v10.1.8 +v9.5.17 +v10.4.0 +v10.2.4 +v10.1.7 +v10.3.3 +v10.0.11 +v9.5.16 +v10.3.1 +v10.3.0 +v9.5.15 +v10.0.10 +v10.1.6 +v10.2.3 +v10.2.2 +v9.5.14 +v10.2.1 +v10.2.0 +v10.1.5 +v10.0.9 +v9.5.13 +v9.4.17 +v9.5.12 +v10.0.8 +v10.1.4 +v10.1.2 +v10.0.6 +v9.5.10 +v9.4.15 +v9.4.14 +v9.5.9 +v10.0.5 +v10.1.1 +v10.1.0 +v10.0.4 +v9.5.8 +v10.0.3 +v9.5.7 +v9.5.6 +v10.0.2 +v10.0.1 +v9.5.5 +v9.4.13 +v9.3.16 +v9.2.20 +v8.5.27 +v9.5.3 +v9.4.12 +v9.3.15 +v9.2.19 +v8.5.26 +v9.5.2 +v9.3.14 +v9.4.10 +v9.2.18 +v9.5.1 +v8.5.24 +v9.2.17 +v9.3.13 +v9.4.9 +v9.5.0 +v8.5.22 +v9.2.15 +v9.4.7 +v9.3.11 +v9.4.0 +v9.4.3 +v9.4.2 +v9.2.13 +v8.5.21 +v9.3.8 +v9.4.1 +v9.3.6 +v8.5.16 +v9.3.4 +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v7.1.4 +v7.1.3 +v7.1.2 +v7.1.1 +v7.1.0 +v7.0.6 +v7.0.5 +v7.0.4 +v7.0.3 +v6.7.4 +v7.0.2 +v7.0.1 +v7.0.0 +v6.7.3 +v6.7.2 +v6.7.1 +v6.7.0 +v6.6.2 +v6.6.1 +v6.6.0 +v6.5.3 +v6.5.2 +v6.5.1 +v6.5.0 +v6.4.5 +v6.3.7 +v6.4.4 +v6.4.3 +v6.4.2 +v6.4.1 +v6.4.0 +v6.3.6 +v6.3.5 +v5.4.5 +v6.3.4 +v6.3.3 +v6.3.2 +v6.3.1 +v6.3.0 +v6.2.5 +v6.2.4 +v6.2.2 +v6.2.1 +v6.2.0 +v6.1.6 +v5.4.4 +v6.1.4 +v6.1.3 +v6.1.2 +v6.1.1 +v6.1.0 +v6.0.2 +v6.0.1 +v6.0.0 +v5.4.3 +v5.4.2 +v5.4.1 +v5.4.0 +v4.6.5 +v5.3.4 +v5.3.3 +v5.3.2 +v5.3.1 +v5.3.0 +v5.2.4 +v4.6.4 +v5.2.3 +v5.2.2 +v5.2.1 +v5.1.5 +v5.2.0 +v5.1.4 +v5.1.3 +v5.1.2 +v5.1.1 +v5.1.0 +v4.1.2 +v4.1.1 +v4.1.0 +v4.0.2 +v4.0.1 +v4.0.0 +v3.1.0 +v2.6.0 +v2.0.2 +v2.1.1 +v2.1.0 +v2.0.1 +v2.5.0 +v2.1.3 diff --git a/google/fingerprinters/web/src/main/resources/fingerprinters/web/data/community/.gitattributes b/google/fingerprinters/web/src/main/resources/fingerprinters/web/data/community/.gitattributes new file mode 100644 index 000000000..e69de29bb