Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web application fingerprint for TeamCity #401

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
teamcity:
container_name: teamcity
image: "jetbrains/teamcity-server:${APP_VERSION}"
restart: always
ports:
- "8080:8111"
101 changes: 101 additions & 0 deletions google/fingerprinters/web/scripts/updater/community/teamcity/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/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 the service.
APP_PATH="${SCRIPT_PATH}/app"
# Path to the temporary data holder.
TMP_DATA="/root/teamcity_fingerprints"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the folder to /tmp/teamcity_fingerprints

# Path to the local code repository.
CODE_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 "${CODE_REPO}"
mkdir -p "${FINGERPRINTS_PATH}"

startService() {
local version="$1"
pushd "${APP_PATH}" >/dev/null
# set COMPOSE_HTTP_TIMEOUT to avoid timeout errors with docker-compose operations
APP_VERSION="${version}" COMPOSE_HTTP_TIMEOUT=200 docker-compose up -d
popd >/dev/null
}

stopService() {
local version="$1"
pushd "${APP_PATH}" >/dev/null
APP_VERSION="${version}" COMPOSE_HTTP_TIMEOUT=200 docker-compose down --volumes --remove-orphans
popd >/dev/null
}

downloadCode() {
local code_repo="$1"
local version="$2"
pushd "${code_repo}" >/dev/null
mkdir -p "${version}"
pushd "${version}" >/dev/null
curl "https://download.jetbrains.com/teamcity/TeamCity-${version}.tar.gz" -L -o - | tar -xzf -
popd >/dev/null
popd >/dev/null
}

# Convert the existing data file to a human-readable json file.
convertFingerprint \
"${PROJECT_ROOT}/src/main/resources/fingerprinters/web/data/community/teamcity.binproto" \
"${JSON_DATA}"

# Update for all the versions listed in versions.txt file.
for APP_VERSION in "${ALL_VERSIONS[@]}"; do
echo "Fingerprinting TeamCity version ${APP_VERSION} ..."
# Start a live instance of TeamCity.
startService "${APP_VERSION}"

# Checkout the repository to the correct tag.
downloadCode "${CODE_REPO}" "${APP_VERSION}"
RESOURCES_PATH="${CODE_REPO}/${APP_VERSION}/TeamCity/webapps/ROOT"

# Arbitrarily chosen so that TeamCity is up and running.
echo "Waiting for TeamCity ${APP_VERSION} to be ready ..."
sleep 90
# Finish the installation process.

updateFingerprint \
"teamcity" \
"${APP_VERSION}" \
"${FINGERPRINTS_PATH}" \
"${RESOURCES_PATH}" \
"http://localhost:8080"

# Stop the live instance of TeamCity.
stopService "${APP_VERSION}"
done

convertFingerprint "${JSON_DATA}" "${BIN_DATA}"

echo "Fingerprint updated for TeamCity. Please commit the following file:"
echo " ${BIN_DATA}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
2023.11.3
2023.11.2
2023.11.1
2023.11
2023.05.4
2023.05.3
2023.05.2
2023.05.1
2022.04.5
2022.10.4
2023.05
2022.10.3
2022.10.2
2022.10.1
2022.10
2022.04.4
2022.04.3
2022.04.2
2022.04.1
2022.04
2021.2.3
2021.2.2
2021.2.1
Loading