Skip to content

Commit 8e0eadb

Browse files
OccamsXorcopybara-github
authored andcommitted
Copybara import of the project:
-- 074801c by occamsxor <[email protected]>: Add Craft CMS fingerprinter -- 55d0d8c by OccamsXor <[email protected]>: Update google/fingerprinters/web/scripts/updater/community/craftcms/update.sh Co-authored-by: Savio Sisco <[email protected]> -- b2cfa48 by OccamsXor <[email protected]>: Update google/fingerprinters/web/scripts/updater/community/craftcms/app/docker-compose.yml Co-authored-by: Savio Sisco <[email protected]> -- 0d55b2a by OccamsXor <[email protected]>: Update google/fingerprinters/web/scripts/updater/community/craftcms/app/docker-compose.yml Co-authored-by: Savio Sisco <[email protected]> -- a785386 by OccamsXor <[email protected]>: Update google/fingerprinters/web/scripts/updater/community/craftcms/app/docker-compose.yml Co-authored-by: Savio Sisco <[email protected]> -- fa18659 by OccamsXor <[email protected]>: Update google/fingerprinters/web/scripts/updater/community/craftcms/app/docker-compose.yml Co-authored-by: Savio Sisco <[email protected]> -- afaf764 by OccamsXor <[email protected]>: Update google/fingerprinters/web/scripts/updater/community/craftcms/app/docker-compose.yml Co-authored-by: Savio Sisco <[email protected]> -- 5a149e0 by OccamsXor <[email protected]>: Update google/fingerprinters/web/scripts/updater/community/craftcms/app/docker-compose.yml Co-authored-by: Savio Sisco <[email protected]> -- aee5452 by OccamsXor <[email protected]>: Update google/fingerprinters/web/scripts/updater/community/craftcms/update.sh Co-authored-by: Savio Sisco <[email protected]> -- 82f6384 by OccamsXor <[email protected]>: Update google/fingerprinters/web/scripts/updater/community/craftcms/update.sh Co-authored-by: Savio Sisco <[email protected]> -- fdb9912 by OccamsXor <[email protected]>: Rename .env_3 to env_3 -- b2c96f3 by OccamsXor <[email protected]>: Rename .env_4 to env_4 -- ee0dd52 by OccamsXor <[email protected]>: Apply suggestions from code review Co-authored-by: Savio Sisco <[email protected]> -- 9631183 by OccamsXor <[email protected]>: Create Dockerfile -- f8276f2 by OccamsXor <[email protected]>: Update docker-compose.yml -- 37de593 by OccamsXor <[email protected]>: Update update.sh -- aae12d9 by OccamsXor <[email protected]>: Update update.sh -- 0dc3d75 by OccamsXor <[email protected]>: Update and rename versions4.txt to versions.txt -- af119e2 by OccamsXor <[email protected]>: Update update.sh -- a81d93e by OccamsXor <[email protected]>: Rename env_4 to env -- 353daff by OccamsXor <[email protected]>: Update google/fingerprinters/web/scripts/updater/community/craftcms/app/env Co-authored-by: Savio Sisco <[email protected]> -- b85706f by OccamsXor <[email protected]>: Update google/fingerprinters/web/scripts/updater/community/craftcms/versions.txt Co-authored-by: Savio Sisco <[email protected]> -- e9c1932 by OccamsXor <[email protected]>: Update google/fingerprinters/web/scripts/updater/community/craftcms/update.sh Co-authored-by: Savio Sisco <[email protected]> -- 2c79b70 by OccamsXor <[email protected]>: Update google/fingerprinters/web/scripts/updater/community/craftcms/app/docker-compose.yml Co-authored-by: Savio Sisco <[email protected]> -- 682d831 by OccamsXor <[email protected]>: Update google/fingerprinters/web/scripts/updater/community/craftcms/app/docker-compose.yml Co-authored-by: Savio Sisco <[email protected]> -- 187245d by OccamsXor <[email protected]>: Update google/fingerprinters/web/scripts/updater/community/craftcms/app/Dockerfile Co-authored-by: Savio Sisco <[email protected]> -- 253c644 by OccamsXor <[email protected]>: Update google/fingerprinters/web/scripts/updater/community/craftcms/app/Dockerfile Co-authored-by: Savio Sisco <[email protected]> -- b749145 by OccamsXor <[email protected]>: Delete google/fingerprinters/web/scripts/updater/community/craftcms/app/env_3 -- fad0ee7 by OccamsXor <[email protected]>: Delete google/fingerprinters/web/scripts/updater/community/craftcms/versions3.txt -- a843b9c by tooryx <[email protected]>: Update docker-compose.yml Remove trailing space COPYBARA_INTEGRATE_REVIEW=#434 from OccamsXor:craftfingerprint a843b9c PiperOrigin-RevId: 725243619 Change-Id: I968ad4b37adc0782cc0ace99ede24b7c49be5b97
1 parent 7a36d0d commit 8e0eadb

File tree

7 files changed

+9882
-0
lines changed

7 files changed

+9882
-0
lines changed

google/fingerprinters/web/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Application
1111
[Apache Zeppelin](https://zeppelin.apache.org/) | [apache_zeppelin.binproto](https://github.com/google/tsunami-security-scanner-plugins/blob/master/google/fingerprinters/web/src/main/resources/fingerprinters/web/data/apache_zeppelin.binproto) | 0.7.2 - 0.9.0
1212
[Argo Workflows](https://argoproj.github.io/projects/argo) | [argo-workflows.binproto](https://github.com/google/tsunami-security-scanner-plugins/blob/master/google/fingerprinters/web/src/main/resources/fingerprinters/web/data/argo-workflows.binproto) | 2.6.0 - 2.11.8
1313
[Drupal](https://www.drupal.org/) | [drupal.binproto](https://github.com/google/tsunami-security-scanner-plugins/blob/master/google/fingerprinters/web/src/main/resources/fingerprinters/web/data/drupal.binproto) | 7.36 - 9.0.6
14+
[Craft CMS](https://craftcms.com/) | [craftcms.binproto](https://github.com/google/tsunami-security-scanner-plugins/blob/master/google/fingerprinters/web/src/main/resources/fingerprinters/web/data/craftcms.binproto) | 3.8.7 - 4.8.4
1415
[Gitlab](https://gitlab.com/gitlab-org/gitlab) | [gitlab.binproto](https://github.com/google/tsunami-security-scanner-plugins/blob/master/google/fingerprinters/web/src/main/resources/fingerprinters/web/data/gitlab.binproto) | 10.0.0 - 13.4.1
1516
[GoCD](https://www.gocd.org/) | [gocd.binproto](https://github.com/google/tsunami-security-scanner-plugins/blob/master/google/fingerprinters/web/src/main/resources/fingerprinters/web/data/gocd.binproto) | 17.3.0 - 21.1.0
1617
[Grafana](https://grafana.com/) | [grafana.binproto](https://github.com/google/tsunami-security-scanner-plugins/blob/master/google/fingerprinters/web/src/main/resources/fingerprinters/web/data/grafana.binproto) | 5.0.0 - 7.3.4
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM craftcms/nginx:8.2
2+
3+
ARG CRAFT_VERSION
4+
5+
USER root
6+
RUN mkdir -p /app
7+
WORKDIR /app
8+
RUN wget "https://github.com/craftcms/cms/releases/download/${CRAFT_VERSION}/CraftCMS-${CRAFT_VERSION}.zip" -O CraftCMS.zip
9+
RUN unzip -o CraftCMS.zip
10+
COPY env /app/.env
11+
RUN chown -R www-data.www-data /app
12+
USER www-data
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: craftcms
2+
services:
3+
web:
4+
build:
5+
context: .
6+
args:
7+
CRAFT_VERSION: "${CRAFT_VERSION}"
8+
ports:
9+
- 8080:8080
10+
env_file: env
11+
depends_on:
12+
redis:
13+
condition: service_healthy
14+
mysql:
15+
condition: service_healthy
16+
healthcheck:
17+
test: ["CMD", "nc" ,"-z", "127.0.0.1", "8080"]
18+
timeout: 20s
19+
retries: 10
20+
21+
mysql:
22+
image: mysql:5.7
23+
environment:
24+
MYSQL_ROOT_PASSWORD: SuperPassword123456!
25+
MYSQL_DATABASE: dev_craftcms
26+
MYSQL_USER: craftcms
27+
MYSQL_PASSWORD: SecretPassword
28+
healthcheck:
29+
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "-pSuperPassword123456!"]
30+
timeout: 20s
31+
retries: 10
32+
33+
redis:
34+
image: redis:5-alpine
35+
healthcheck:
36+
test: ["CMD", "redis-cli", "ping"]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Read about configuration, here:
2+
# https://craftcms.com/docs/4.x/config/
3+
4+
# The application ID used to to uniquely store session and cache data, mutex locks, and more
5+
CRAFT_APP_ID=
6+
APP_ID=
7+
8+
# The environment Craft is currently running in (dev, staging, production, etc.)
9+
CRAFT_ENVIRONMENT=production
10+
ENVIRONMENT=production
11+
12+
# The secure key Craft will use for hashing and encrypting data
13+
CRAFT_SECURITY_KEY=root
14+
SECURITY_KEY=root
15+
16+
# Database connection settings
17+
CRAFT_DB_DRIVER=mysql
18+
DB_DRIVER=mysql
19+
CRAFT_DB_SERVER=mysql
20+
DB_SERVER=mysql
21+
CRAFT_DB_PORT=3306
22+
DB_PORT=3306
23+
CRAFT_DB_DATABASE=dev_craftcms
24+
DB_DATABASE=dev_craftcms
25+
CRAFT_DB_USER=craftcms
26+
DB_USER=craftcms
27+
CRAFT_DB_PASSWORD=SecretPassword
28+
DB_PASSWORD=SecretPassword
29+
CRAFT_DB_SCHEMA=public
30+
DB_SCHEMA=public
31+
CRAFT_DB_TABLE_PREFIX=
32+
DB_TABLE_PREFIX=
33+
34+
# General settings (see config/general.php)
35+
DEV_MODE=false
36+
ALLOW_ADMIN_CHANGES=false
37+
DISALLOW_ROBOTS=false
38+
39+
CP_TRIGGER=admin
40+
41+
PRIMARY_SITE_URL=http://localhost:8080
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2024 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
19+
source ../../common.sh
20+
21+
SCRIPT_PATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)"
22+
# Root path to the web fingerprinter plugin.
23+
PROJECT_ROOT="$(cd -- "${SCRIPT_PATH}/../../../.." >/dev/null 2>&1 ; pwd -P)"
24+
# Path to the configurations
25+
APP_PATH="${SCRIPT_PATH}/app"
26+
# Path to the temporary data holder.
27+
TMP_DATA="/tmp/craftcms_fingerprints"
28+
# Path to CraftCMS Releases files
29+
TMP_RELEASE_FILES="${TMP_DATA}/craftcms_instance"
30+
# Path to the local git repository for Craft CMS codebase.
31+
GIT_REPO="${TMP_DATA}/repo"
32+
# Path to the directory of all the updated fingerprints data.
33+
FINGERPRINTS_PATH="${TMP_DATA}/fingerprints"
34+
# Json data of the final result.
35+
JSON_DATA="${FINGERPRINTS_PATH}/fingerprint.json"
36+
# Binary proto data of the final result.
37+
BIN_DATA="${FINGERPRINTS_PATH}/fingerprint.binproto"
38+
39+
mkdir -p "${FINGERPRINTS_PATH}"
40+
mkdir -p "${TMP_RELEASE_FILES}"
41+
42+
BINPROTO="${PROJECT_ROOT}/src/main/resources/fingerprinters/web/data/community/craftcms.binproto"
43+
44+
StartCraftCMS() {
45+
local version="$1"
46+
pushd "${APP_PATH}" >/dev/null
47+
CRAFT_VERSION="$version" docker compose up --build --wait -d
48+
docker exec -it craftcms-web-1 php craft install/craft --email [email protected] --username admin --password tsunami --site-name local --site-url http://localhost:8080 --language en-us
49+
popd >/dev/null
50+
}
51+
52+
StopCraftCMS() {
53+
pushd "${APP_PATH}" >/dev/null
54+
docker compose down --volumes --remove-orphans
55+
popd >/dev/null
56+
}
57+
58+
CreateFingerprintForCraftCMS(){
59+
local version="$1"
60+
StartCraftCMS "$version"
61+
checkOutRepo "${GIT_REPO}" "${version}"
62+
RESOURCES_PATH="${GIT_REPO}"
63+
updateFingerprint \
64+
"craftcms" \
65+
"${version}" \
66+
"${FINGERPRINTS_PATH}" \
67+
"${RESOURCES_PATH}" \
68+
"http://localhost:8080"
69+
StopCraftCMS
70+
}
71+
72+
# Convert the existing data file to a human-readable json file.
73+
convertFingerprint "${BINPROTO}" "${JSON_DATA}"
74+
75+
# Fetch Craftcms codebase.
76+
if [[ ! -d "${GIT_REPO}" ]] ; then
77+
git clone https://github.com/craftcms/cms "${GIT_REPO}"
78+
fi
79+
80+
# Read all released CraftCMS versions to be fingerprinted.
81+
readarray -t ALL_VERSIONS < "${SCRIPT_PATH}/versions.txt"
82+
83+
for craftcms_version in "${ALL_VERSIONS[@]}"; do
84+
CreateFingerprintForCraftCMS "${craftcms_version}" "env"
85+
done
86+
87+
convertFingerprint "${JSON_DATA}" "${BIN_DATA}"
88+
89+
echo "Fingerprint updated for Craft CMS. Please commit the following file:"
90+
echo " ${BIN_DATA}"
91+
echo "to"
92+
echo " ${BINPROTO}"

0 commit comments

Comments
 (0)