Ver código fonte

Merge pull request #726 from mkl262/master

feat: allow to specify obfuscation salt string

Thank you for contributing @mkl262
sstidl 1 dia atrás
pai
commit
4458c69940
2 arquivos alterados com 9 adições e 0 exclusões
  1. 1 0
      doc_docker.md
  2. 8 0
      docker/entrypoint.sh

+ 1 - 0
doc_docker.md

@@ -59,6 +59,7 @@ Here's a list of additional environment variables available in this mode:
 * __`TITLE`__: Title of your speed test. Default value: `LibreSpeed`
 * __`TELEMETRY`__: Whether to enable telemetry or not. If enabled, you maybe want your data to be persisted. See below. Default value: `false`
 * __`ENABLE_ID_OBFUSCATION`__: When set to true with telemetry enabled, test IDs are obfuscated, to avoid exposing the database internal sequential IDs. Default value: `false`
+* __`OBFUSCATION_SALT`__: The salt string that is used to obfuscate the test IDs. The format shoud be a 2 byte hex string (e.g. `0x1234abcd`). If not specified, a random one will be generated.
 * __`REDACT_IP_ADDRESSES`__: When set to true with telemetry enabled, IP addresses and hostnames are redacted from the collected telemetry, for better privacy. Default value: `false`
 * __`DB_TYPE`__: When set to one of the supported DB-Backends it will use this instead of the default sqlite database backend. TELEMETRY has to be set to `true`. Also you have to create the database as described in [doc.md](doc.md#creating-the-database). Supported backend types are:
   * sqlite - no additional settings required

+ 8 - 0
docker/entrypoint.sh

@@ -78,6 +78,14 @@ if [[ "$TELEMETRY" == "true" && ("$MODE" == "frontend" || "$MODE" == "standalone
 
   if [ "$ENABLE_ID_OBFUSCATION" == "true" ]; then
     sed -i s/\$enable_id_obfuscation\ =\ .*\;/\$enable_id_obfuscation\ =\ true\;/g /var/www/html/results/telemetry_settings.php
+    if [ ! -z "$OBFUSCATION_SALT" ]; then
+      if [[ "$OBFUSCATION_SALT" =~ ^0x[0-9a-fA-F]+$ ]]; then
+        echo "<?php" > /var/www/html/results/idObfuscation_salt.php
+        echo "\$OBFUSCATION_SALT = $OBFUSCATION_SALT;" >> /var/www/html/results/idObfuscation_salt.php
+      else
+        echo "WARNING: Invalid OBFUSCATION_SALT format. It must be a hex string (e.g., 0x1234abcd). Using random salt." >&2
+      fi
+    fi
   fi
 
   if [ "$REDACT_IP_ADDRESSES" == "true" ]; then