-
Notifications
You must be signed in to change notification settings - Fork 180
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
quanyang
wants to merge
1
commit into
google:master
Choose a base branch
from
quanyang:teamcity_fingerprint
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
google/fingerprinters/web/scripts/updater/community/teamcity/app/docker-compose.yaml
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 @@ | ||
services: | ||
teamcity: | ||
container_name: teamcity | ||
image: "jetbrains/teamcity-server:${APP_VERSION}" | ||
restart: always | ||
ports: | ||
- "8080:8111" |
101 changes: 101 additions & 0 deletions
101
google/fingerprinters/web/scripts/updater/community/teamcity/update.sh
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,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" | ||
# 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}" |
23 changes: 23 additions & 0 deletions
23
google/fingerprinters/web/scripts/updater/community/teamcity/versions.txt
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,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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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