#!/usr/bin/env bash # Verification for: docker-security-and-performance-guide # Self-contained. THIS SCRIPT NEVER RUNS DOCKER — there is none on the machine that wrote this # page, and none is assumed on the machine that runs this script. Two kinds of claims: # RUN checks — read-only SHOW VARIABLES against a real MySQL server (yours, via MYSQL_CMD). # CITED checks — re-fetch the primary docs and grep for the exact quoted wording (needs network). # Prints PASS / FAIL / SKIP per claim. Nothing here mutates any database. No EXIT-trap teardown is # needed because nothing scratch is created. set -u PASS=0; FAIL=0; SKIP=0; CONTENT=0 ok() { echo "PASS $*"; PASS=$((PASS+1)); } no() { echo "FAIL $*"; FAIL=$((FAIL+1)); } skip() { echo "SKIP $*"; SKIP=$((SKIP+1)); } content() { echo "CONTENT $*"; CONTENT=$((CONTENT+1)); } MYSQL_CMD="${MYSQL_CMD:-mysql -u root}" echo "=== MySQL-in-Docker guide — claim verification (no Docker used) ===" echo "date: $(date -u '+%Y-%m-%dT%H:%M:%SZ') host: $(uname -srm)" echo # --------------------------------------------------------------------------- # CLAIM 0 (meta): this environment genuinely has no Docker, matching the # article's stated honesty constraint. # --------------------------------------------------------------------------- if command -v docker >/dev/null 2>&1; then skip "C0 docker IS present on this machine — the article's 'no Docker here' framing doesn't apply to your environment; server-side RUN checks below still apply" else ok "C0 no docker binary on PATH — matches the article's stated constraint (nothing Docker-related was executed to verify this page)" fi # --------------------------------------------------------------------------- # RUN CLAIM 1/2: real MySQL server defaults for max_connections and sql_mode. # --------------------------------------------------------------------------- if $MYSQL_CMD -e 'SELECT 1' >/dev/null 2>&1; then VER="$($MYSQL_CMD -N -B -e 'SELECT VERSION()')" echo " server: MySQL $VER" MAXCONN="$($MYSQL_CMD -N -B -e "SHOW VARIABLES LIKE 'max_connections'" | awk '{print $2}')" echo " max_connections=$MAXCONN" if [ "$MAXCONN" = "151" ]; then ok "C1 max_connections default is 151, matching the old page's claimed default" else skip "C1 max_connections is $MAXCONN on this server (not the stock default 151 — may be a customized instance)" fi SQLMODE="$($MYSQL_CMD -N -B -e "SHOW VARIABLES LIKE 'sql_mode'" | awk -F'\t' '{print $2}')" echo " sql_mode=$SQLMODE" if printf '%s' "$SQLMODE" | grep -q 'STRICT_TRANS_TABLES' && printf '%s' "$SQLMODE" | grep -q 'NO_ENGINE_SUBSTITUTION'; then ok "C2 sql_mode already includes STRICT_TRANS_TABLES and NO_ENGINE_SUBSTITUTION by default — the old page's 'add these' advice describes a no-op on this server" else no "C2 expected STRICT_TRANS_TABLES and NO_ENGINE_SUBSTITUTION in the default sql_mode, got: $SQLMODE" fi else skip "C1/C2 cannot connect with: $MYSQL_CMD — MySQL-side checks skipped" fi # --------------------------------------------------------------------------- # CITED CLAIM 3-7: exact wording from Docker Hub / Docker docs / MySQL docs # (needs network). # --------------------------------------------------------------------------- detag() { python3 -c 'import sys,re,html; t=html.unescape(re.sub(r"<[^>]+>"," ",sys.stdin.read())); print(re.sub(r"\s+"," ",t))'; } MYSQL_HUB="$(curl -s --max-time 25 https://hub.docker.com/_/mysql | detag || true)" if [ -z "$MYSQL_HUB" ]; then skip "C3/C4/C5 mysql Docker Hub image wording (needs network)" else if printf '%s' "$MYSQL_HUB" | grep -qi 'alternative to passing sensitive information via environment variables'; then ok "C3 mysql image docs: the _FILE variables exist 'as an alternative to passing sensitive information via environment variables'" else no "C3 could not find the documented _FILE-variable rationale" fi if printf '%s' "$MYSQL_HUB" | grep -qi 'leave your MySQL instance completely unprotected'; then ok "C4 mysql image docs warn MYSQL_ALLOW_EMPTY_PASSWORD=yes will 'leave your MySQL instance completely unprotected'" else no "C4 could not find the documented MYSQL_ALLOW_EMPTY_PASSWORD warning" fi if printf '%s' "$MYSQL_HUB" | grep -qi 'GENERATED ROOT PASSWORD'; then ok "C5 mysql image docs: MYSQL_RANDOM_ROOT_PASSWORD prints 'GENERATED ROOT PASSWORD: .....' to the log" else no "C5 could not find the documented MYSQL_RANDOM_ROOT_PASSWORD log-message wording" fi fi SECRETS_PAGE="$(curl -s --max-time 25 https://docs.docker.com/engine/swarm/secrets/ | detag || true)" if [ -z "$SECRETS_PAGE" ]; then skip "C6 Docker secrets rationale wording (needs network)" elif printf '%s' "$SECRETS_PAGE" | grep -qi 'environment variables can unintentionally be leaked between containers'; then ok "C6 Docker docs: env vars 'can unintentionally be leaked between containers (for instance, if you use --link)'" else no "C6 could not find the documented secrets-vs-env-vars rationale wording" fi DEDICATED_PAGE="$(curl -s --max-time 25 https://dev.mysql.com/doc/refman/8.4/en/innodb-dedicated-server.html | detag || true)" if [ -z "$DEDICATED_PAGE" ]; then skip "C7 innodb_dedicated_server Docker recommendation wording (needs network)" elif printf '%s' "$DEDICATED_PAGE" | grep -qi 'if you run MySQL Server in a Docker container'; then ok "C7 MySQL manual explicitly recommends --innodb-dedicated-server 'if you run MySQL Server in a Docker container or dedicated VM'" else no "C7 could not find the documented Docker recommendation wording for innodb_dedicated_server" fi # --------------------------------------------------------------------------- # CONTENT regression guards. # --------------------------------------------------------------------------- SELF_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ARTICLE="$SELF_DIR/docker-security-and-performance-guide.html" if [ -f "$ARTICLE" ]; then # The article is expected to QUOTE the fabricated 30% figure while explicitly disowning it # (hard rule 5: own prior errors explicitly) — check for the disclosure, not bare absence. if grep -qi 'latency dropped by 30%' "$ARTICLE"; then if grep -qi 'deleted\|invented\|fabricat' "$ARTICLE"; then content "article quotes the fabricated 'latency dropped by 30%' figure only while explicitly disowning it" else no "article contains the 'latency dropped by 30%' figure without clearly disowning it" fi else content "article does not contain the fabricated 30% latency figure at all" fi if grep -qi '75% of system memory' "$ARTICLE" && grep -qi 'deleted\|invented' "$ARTICLE"; then content "article quotes the fabricated 75%-of-memory container rule only while explicitly disowning it" else no "article does not clearly own/disclose the deleted 75%-of-memory container rule" fi grep -q 'MYSQL_ROOT_PASSWORD_FILE' "$ARTICLE" && content "article documents the _FILE alternative to plain MYSQL_ROOT_PASSWORD" || no "article missing MYSQL_ROOT_PASSWORD_FILE guidance" else skip "article HTML not found next to this script — content regression checks skipped (expected when downloaded standalone from /verify/)" fi echo echo "=== summary: PASS=$PASS FAIL=$FAIL SKIP=$SKIP CONTENT=$CONTENT ===" [ "$FAIL" -eq 0 ]