#!/usr/bin/env bash # test-firebase-google.sh — Run the Phase 9 Firebase & Google API test matrix. # # Consumes the env file produced by find-firebase-config.sh (or accepts the # same variables via --env/CLI flags) and exercises Firebase Auth, Realtime # Database, Firestore, Remote Config, Storage, Dynamic Links, FCM, the Gemini # API, and the billable Maps/AI family. Outputs a structured Markdown report # and machine-readable status lines. # # ONLY use this script on applications you are authorized to test. set -euo pipefail usage() { cat <&2; exit 1 ;; esac done if [[ "$AUTHORIZED" != true ]]; then echo "Error: refusing live Firebase/Google probes without explicit authorization." >&2 echo " Re-run with --authorized only after the specific project/service is confirmed in scope." >&2 exit 1 fi if [[ -n "$ENV_FILE" ]]; then if [[ ! -f "$ENV_FILE" ]]; then echo "Error: --env file not found: $ENV_FILE" >&2; exit 1 fi # shellcheck disable=SC1090 source "$ENV_FILE" fi if [[ -z "$API_KEY" ]]; then echo "Error: API_KEY is empty. Pass --api-key, or an --env file produced by find-firebase-config.sh." >&2 exit 3 fi REPORT_FILE="${REPORT_FILE:-$PWD/firebase-google-report.md}" # Section enablement -- default: all on, then restrict if --only supplied. RUN_AUTH=true RUN_RTDB=true RUN_FIRESTORE=true RUN_REMOTECONFIG=true RUN_STORAGE=true RUN_DYNAMICLINKS=true RUN_FCM=true RUN_GEMINI=true RUN_BILLABLE=true if [[ -n "$ONLY" ]]; then RUN_AUTH=false; RUN_RTDB=false; RUN_FIRESTORE=false; RUN_REMOTECONFIG=false RUN_STORAGE=false; RUN_DYNAMICLINKS=false; RUN_FCM=false; RUN_GEMINI=false RUN_BILLABLE=false IFS=',' read -ra parts <<< "$ONLY" for p in "${parts[@]}"; do case "$p" in auth) RUN_AUTH=true ;; rtdb) RUN_RTDB=true ;; firestore) RUN_FIRESTORE=true ;; remoteconfig) RUN_REMOTECONFIG=true ;; storage) RUN_STORAGE=true ;; dynamiclinks) RUN_DYNAMICLINKS=true ;; fcm) RUN_FCM=true ;; gemini) RUN_GEMINI=true ;; billable) RUN_BILLABLE=true ;; *) echo "Error: unknown --only section: $p" >&2; exit 1 ;; esac done fi [[ "$SKIP_BILLABLE" == true ]] && RUN_BILLABLE=false # --- Report & test plumbing ------------------------------------------------- VULN_COUNT=0 PROBE_COUNT=0 REPORT_BUF="" # Append a header line to the buffer. rep_section() { REPORT_BUF+=$'\n'"## $1"$'\n\n'; } # Run a curl probe and record result. # Usage: run_probe "