-
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
Add Craft CMS fingerprinter #434
Open
OccamsXor
wants to merge
20
commits into
google:master
Choose a base branch
from
OccamsXor:craftfingerprint
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.
+9,903
−0
Open
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
074801c
Add Craft CMS fingerprinter
OccamsXor 55d0d8c
Update google/fingerprinters/web/scripts/updater/community/craftcms/u…
OccamsXor b2cfa48
Update google/fingerprinters/web/scripts/updater/community/craftcms/a…
OccamsXor 0d55b2a
Update google/fingerprinters/web/scripts/updater/community/craftcms/a…
OccamsXor a785386
Update google/fingerprinters/web/scripts/updater/community/craftcms/a…
OccamsXor fa18659
Update google/fingerprinters/web/scripts/updater/community/craftcms/a…
OccamsXor afaf764
Update google/fingerprinters/web/scripts/updater/community/craftcms/a…
OccamsXor 5a149e0
Update google/fingerprinters/web/scripts/updater/community/craftcms/a…
OccamsXor aee5452
Update google/fingerprinters/web/scripts/updater/community/craftcms/u…
OccamsXor 82f6384
Update google/fingerprinters/web/scripts/updater/community/craftcms/u…
OccamsXor fdb9912
Rename .env_3 to env_3
OccamsXor b2c96f3
Rename .env_4 to env_4
OccamsXor ee0dd52
Apply suggestions from code review
OccamsXor 9631183
Create Dockerfile
OccamsXor f8276f2
Update docker-compose.yml
OccamsXor 37de593
Update update.sh
OccamsXor aae12d9
Update update.sh
OccamsXor 0dc3d75
Update and rename versions4.txt to versions.txt
OccamsXor af119e2
Update update.sh
OccamsXor a81d93e
Rename env_4 to env
OccamsXor 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
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
23 changes: 23 additions & 0 deletions
23
google/fingerprinters/web/scripts/updater/community/craftcms/app/.env_3
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 @@ | ||
# The environment Craft is currently running in (dev, staging, production, etc.) | ||
ENVIRONMENT=production | ||
|
||
# The application ID used to to uniquely store session and cache data, mutex locks, and more | ||
APP_ID= | ||
|
||
# The secure key Craft will use for hashing and encrypting data | ||
SECURITY_KEY=root | ||
|
||
# Database Configuration | ||
DB_DRIVER=mysql | ||
DB_SERVER=mysql | ||
DB_PORT=3306 | ||
DB_DATABASE=dev_craftcms | ||
DB_USER=craftcms | ||
DB_PASSWORD=SecretPassword | ||
DB_SCHEMA=public | ||
DB_TABLE_PREFIX= | ||
|
||
# The URI segment that tells Craft to load the control panel | ||
CP_TRIGGER=admin | ||
|
||
PRIMARY_SITE_URL=http://localhost:8080 |
28 changes: 28 additions & 0 deletions
28
google/fingerprinters/web/scripts/updater/community/craftcms/app/.env_4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please rename the file to not be hidden (without the starting dot |
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,28 @@ | ||
# Read about configuration, here: | ||
# https://craftcms.com/docs/4.x/config/ | ||
|
||
# The application ID used to to uniquely store session and cache data, mutex locks, and more | ||
CRAFT_APP_ID= | ||
|
||
# The environment Craft is currently running in (dev, staging, production, etc.) | ||
CRAFT_ENVIRONMENT=production | ||
|
||
# The secure key Craft will use for hashing and encrypting data | ||
CRAFT_SECURITY_KEY=root | ||
|
||
# Database connection settings | ||
CRAFT_DB_DRIVER=mysql | ||
CRAFT_DB_SERVER=mysql | ||
CRAFT_DB_PORT=3306 | ||
CRAFT_DB_DATABASE=dev_craftcms | ||
CRAFT_DB_USER=craftcms | ||
CRAFT_DB_PASSWORD=SecretPassword | ||
CRAFT_DB_SCHEMA=public | ||
CRAFT_DB_TABLE_PREFIX= | ||
|
||
# General settings (see config/general.php) | ||
DEV_MODE=false | ||
ALLOW_ADMIN_CHANGES=false | ||
DISALLOW_ROBOTS=false | ||
|
||
PRIMARY_SITE_URL=http://localhost:8080 |
48 changes: 48 additions & 0 deletions
48
google/fingerprinters/web/scripts/updater/community/craftcms/app/docker-compose.yml
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,48 @@ | ||
version: "3.6" | ||
OccamsXor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
services: | ||
console: | ||
image: craftcms/cli:8.2-dev | ||
env_file: .env | ||
environment: | ||
XDEBUG_CONFIG: client_host=host.docker.internal | ||
depends_on: | ||
redis: | ||
condition: service_healthy | ||
volumes: | ||
- .:/app | ||
command: php craft queue/listen | ||
|
||
OccamsXor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
web: | ||
image: craftcms/nginx:8.2-dev | ||
ports: | ||
- 8080:8080 | ||
env_file: .env | ||
environment: | ||
XDEBUG_CONFIG: client_host=host.docker.internal | ||
OccamsXor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
depends_on: | ||
redis: | ||
condition: service_healthy | ||
OccamsXor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
volumes: | ||
- .:/app | ||
|
||
mysql: | ||
image: mysql:5.7 | ||
ports: | ||
- 3306:3306 | ||
OccamsXor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
environment: | ||
MYSQL_ROOT_PASSWORD: SuperPassword123456! | ||
MYSQL_DATABASE: dev_craftcms | ||
MYSQL_USER: craftcms | ||
MYSQL_PASSWORD: SecretPassword | ||
OccamsXor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
volumes: | ||
- ./mysql/db_data:/var/lib/mysql | ||
OccamsXor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
redis: | ||
image: redis:5-alpine | ||
ports: | ||
- 6379:6379 | ||
OccamsXor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
healthcheck: | ||
test: ["CMD", "redis-cli", "ping"] | ||
|
||
volumes: | ||
db_data: | ||
OccamsXor marked this conversation as resolved.
Show resolved
Hide resolved
|
109 changes: 109 additions & 0 deletions
109
google/fingerprinters/web/scripts/updater/community/craftcms/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,109 @@ | ||
#!/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 | ||
# | ||
# http://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 | ||
APP_PATH="${SCRIPT_PATH}/app" | ||
# Path to the temporary data holder. | ||
TMP_DATA="/tmp/craftcms_fingerprints" | ||
# Path to CraftCMS Releases files | ||
TMP_RELEASE_FILES="${TMP_DATA}/craftcms_instance" | ||
# Path to the local git repository for adminer codebase. | ||
OccamsXor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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" | ||
|
||
mkdir -p "${FINGERPRINTS_PATH}" | ||
mkdir -p "${TMP_RELEASE_FILES}" | ||
|
||
BINPROTO="${PROJECT_ROOT}/src/main/resources/fingerprinters/web/data/community/craftcms.binproto" | ||
|
||
StartCraftCMS() { | ||
pushd "${TMP_RELEASE_FILES}" >/dev/null | ||
docker-compose up -d | ||
docker exec -it craftcms_instance_web_1 php craft install/craft --email [email protected] --username admin --password tsunami --site-name local --site-url http://localhost:8080 --language en-us | ||
OccamsXor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
popd >/dev/null | ||
} | ||
|
||
StopCraftCMS() { | ||
pushd "${TMP_RELEASE_FILES}" >/dev/null | ||
docker-compose down --volumes --remove-orphans | ||
OccamsXor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rm -rf {,.[!.],..?}* | ||
popd >/dev/null | ||
} | ||
|
||
CreateFingerprintForCraftCMS(){ | ||
local version="$1" | ||
local envFile="$2" | ||
echo https://github.com/craftcms/cms/releases/download/"${version}"/CraftCMS-"${version}".zip | ||
curl -L https://github.com/craftcms/cms/releases/download/"${version}"/CraftCMS-"${version}".zip --output "${TMP_RELEASE_FILES}"/CraftCMS.zip | ||
unzip -o "${TMP_RELEASE_FILES}"/CraftCMS.zip -d "${TMP_RELEASE_FILES}" | ||
cp "${APP_PATH}"/"${envFile}" "${TMP_RELEASE_FILES}"/.env | ||
cp "${APP_PATH}"/docker-compose.yml "${TMP_RELEASE_FILES}"/docker-compose.yml | ||
chown -R 82:82 "${TMP_RELEASE_FILES}" | ||
StartCraftCMS | ||
checkOutRepo "${GIT_REPO}" "${version}" | ||
RESOURCES_PATH="${GIT_REPO}" | ||
updateFingerprint \ | ||
"craftcms" \ | ||
"${version}" \ | ||
"${FINGERPRINTS_PATH}" \ | ||
"${RESOURCES_PATH}" \ | ||
"http://localhost:8080" | ||
StopCraftCMS | ||
|
||
} | ||
|
||
# Convert the existing data file to a human-readable json file. | ||
convertFingerprint "${BINPROTO}" "${JSON_DATA}" | ||
|
||
# Fetch Craftcms codebase. | ||
if [[ ! -d "${GIT_REPO}" ]] ; then | ||
git clone https://github.com/craftcms/cms "${GIT_REPO}" | ||
fi | ||
|
||
# Read all released CraftCMS 3 versions to be fingerprinted. | ||
readarray -t ALL_VERSIONS_3 < "${SCRIPT_PATH}/versions3.txt" | ||
|
||
# Read all released CraftCMS 4 versions to be fingerprinted. | ||
readarray -t ALL_VERSIONS_4 < "${SCRIPT_PATH}/versions4.txt" | ||
|
||
# Version 3 uses different .env file format. | ||
for craftcms_version in "${ALL_VERSIONS_3[@]}"; do | ||
CreateFingerprintForCraftCMS "${craftcms_version}" ".env_3" | ||
done | ||
|
||
# Version 4 uses different .env file format. | ||
for craftcms_version in "${ALL_VERSIONS_4[@]}"; do | ||
CreateFingerprintForCraftCMS "${craftcms_version}" ".env_4" | ||
done | ||
|
||
convertFingerprint "${JSON_DATA}" "${BIN_DATA}" | ||
|
||
echo "Fingerprint updated for Craft CMS. Please commit the following file:" | ||
echo " ${BIN_DATA}" | ||
echo "to" | ||
echo " ${BINPROTO}" |
22 changes: 22 additions & 0 deletions
22
google/fingerprinters/web/scripts/updater/community/craftcms/versions3.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,22 @@ | ||
3.9.12 | ||
3.8.10 | ||
3.8.10.2 | ||
3.8.11 | ||
3.8.12 | ||
3.8.13 | ||
3.8.14 | ||
3.8.15 | ||
3.8.16 | ||
3.8.17 | ||
3.8.7 | ||
3.8.8 | ||
3.8.9 | ||
3.9.0 | ||
3.9.1 | ||
3.9.10 | ||
3.9.11 | ||
3.9.2 | ||
3.9.3 | ||
3.9.4 | ||
3.9.5 | ||
3.9.6 |
49 changes: 49 additions & 0 deletions
49
google/fingerprinters/web/scripts/updater/community/craftcms/versions4.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,49 @@ | ||
4.4.10 | ||
4.4.10.1 | ||
4.4.11 | ||
4.4.12 | ||
4.4.13 | ||
4.4.14 | ||
4.4.15 | ||
4.4.16 | ||
4.4.16.1 | ||
4.4.17 | ||
4.4.6 | ||
4.4.7 | ||
4.4.7.1 | ||
4.4.8 | ||
4.4.9 | ||
4.5.0 | ||
4.5.0-beta.1 | ||
4.5.0-beta.2 | ||
4.5.1 | ||
4.5.10 | ||
4.5.11 | ||
4.5.11.1 | ||
4.5.12 | ||
4.5.13 | ||
4.5.14 | ||
4.5.15 | ||
4.5.2 | ||
4.5.3 | ||
4.5.4 | ||
4.5.5 | ||
4.5.6 | ||
4.5.6.1 | ||
4.5.7 | ||
4.5.8 | ||
4.5.9 | ||
4.6.0 | ||
4.6.0-RC1 | ||
4.6.1 | ||
4.7.0 | ||
4.7.1 | ||
4.7.2 | ||
4.7.2.1 | ||
4.7.3 | ||
4.7.4 | ||
4.8.0 | ||
4.8.1 | ||
4.8.2 | ||
4.8.3 | ||
4.8.4 |
Oops, something went wrong.
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 rename the file to not be hidden (without the starting dot
.
)