Copilot commented on code in PR #4252:
URL: https://github.com/apache/hertzbeat/pull/4252#discussion_r3658989291


##########
script/docker-compose/hertzbeat-postgresql-victoria-metrics/.env.example:
##########
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+# Copy this file to .env and set your own strong password before running 
docker compose up
+POSTGRES_USER=root
+POSTGRES_PASSWORD=please_change_this_password

Review Comment:
   `.env.example` sets a non-empty, predictable placeholder password 
(`please_change_this_password`). If users copy it verbatim (as instructed), the 
stack will start with a known weak password again. Prefer leaving 
`POSTGRES_PASSWORD` empty (so `${POSTGRES_PASSWORD:?...}` fails until a real 
password is set), or omit the value entirely and keep only an instruction 
comment.



##########
script/docker-compose/hertzbeat-postgresql-victoria-metrics/docker-compose.yaml:
##########
@@ -34,8 +34,8 @@ services:
     ports:
       - '15432:5432'
     environment:
-      POSTGRES_USER: root
-      POSTGRES_PASSWORD: 123456
+      POSTGRES_USER: ${POSTGRES_USER:-root}
+      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Please set POSTGRES_PASSWORD in 
your .env file}

Review Comment:
   The error message is misleading because `POSTGRES_PASSWORD` can be provided 
via shell env, CI secrets, or `docker compose --env-file`, not only via `.env`. 
Consider rewording to something like: `Please set POSTGRES_PASSWORD (e.g., in 
.env or your environment)` so failures are actionable in more setups.



##########
script/docker-compose/hertzbeat-postgresql-victoria-metrics/docker-compose.yaml:
##########
@@ -73,6 +73,8 @@ services:
       HERTZBEAT_COLLECTOR_MYSQL_QUERY_ENGINE: auto
       TZ: Asia/Shanghai
       LANG: zh_CN.UTF-8
+      SPRING_DATASOURCE_USERNAME: ${POSTGRES_USER:-root}

Review Comment:
   Defaulting the DB superuser to `root` is a risky convention and diverges 
from the official Postgres image defaults (`postgres`). Consider either 
defaulting to `postgres` or requiring `POSTGRES_USER` to be explicitly set 
(similar to the password), which also nudges users toward a non-root, 
least-privilege account.



##########
script/docker-compose/hertzbeat-postgresql-victoria-metrics/docker-compose.yaml:
##########
@@ -73,6 +73,8 @@ services:
       HERTZBEAT_COLLECTOR_MYSQL_QUERY_ENGINE: auto
       TZ: Asia/Shanghai
       LANG: zh_CN.UTF-8
+      SPRING_DATASOURCE_USERNAME: ${POSTGRES_USER:-root}
+      SPRING_DATASOURCE_PASSWORD: ${POSTGRES_PASSWORD:?Please set 
POSTGRES_PASSWORD in your .env file}

Review Comment:
   The error message is misleading because `POSTGRES_PASSWORD` can be provided 
via shell env, CI secrets, or `docker compose --env-file`, not only via `.env`. 
Consider rewording to something like: `Please set POSTGRES_PASSWORD (e.g., in 
.env or your environment)` so failures are actionable in more setups.



##########
script/docker-compose/hertzbeat-postgresql-victoria-metrics/docker-compose.yaml:
##########
@@ -34,8 +34,8 @@ services:
     ports:
       - '15432:5432'
     environment:
-      POSTGRES_USER: root
-      POSTGRES_PASSWORD: 123456
+      POSTGRES_USER: ${POSTGRES_USER:-root}

Review Comment:
   Defaulting the DB superuser to `root` is a risky convention and diverges 
from the official Postgres image defaults (`postgres`). Consider either 
defaulting to `postgres` or requiring `POSTGRES_USER` to be explicitly set 
(similar to the password), which also nudges users toward a non-root, 
least-privilege account.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to