imbajin commented on code in PR #2952:
URL:
https://github.com/apache/incubator-hugegraph/pull/2952#discussion_r2837674045
##########
hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh:
##########
@@ -15,32 +15,66 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+set -euo pipefail
-# create a folder to save the docker-related file
-DOCKER_FOLDER='./docker'
-mkdir -p $DOCKER_FOLDER
-
+DOCKER_FOLDER="./docker"
INIT_FLAG_FILE="init_complete"
+GRAPH_CONF="./conf/graphs/hugegraph.properties"
+
+mkdir -p "${DOCKER_FOLDER}"
+
+log() { echo "[hugegraph-server-entrypoint] $*"; }
+
+fail_on_deprecated() {
+ local old_name="$1" new_name="$2"
+ if [[ -n "${!old_name:-}" ]]; then
+ echo "ERROR: deprecated env '${old_name}' detected. Use '${new_name}'
instead." >&2
+ exit 2
+ fi
+}
+
+set_prop() {
+ local key="$1" val="$2" file="$3"
Review Comment:
🧹 (Optional)
**`set_prop` currently injects raw values into `sed` — escape replacement
text to avoid malformed properties**
`set_prop` writes `${val}` directly into a `sed` replacement expression. If
the value contains characters such as `#`, `&`, `|`, or `\`, the generated line
can be corrupted.
In this script, key-regex injection is lower risk because keys are fixed
constants (`backend`, `pd.peers`), but value escaping is still important for
correctness and future-proofing.
```suggestion
set_prop() {
local key="$1" val="$2" file="$3"
local esc_key esc_val
# Escape key for regex matching and value for sed replacement.
esc_key=$(printf '%s' "$key" | sed -e 's/[][(){}.^$*+?|\\/]/\\&/g')
esc_val=$(printf '%s' "$val" | sed -e 's/[&|\\]/\\&/g')
if grep -qE "^[[:space:]]*${esc_key}[[:space:]]*=" "${file}"; then
sed -ri "s|^([[:space:]]*${esc_key}[[:space:]]*=).*|\\1${esc_val}|"
"${file}"
else
printf '%s=%s\n' "$key" "$val" >> "${file}"
fi
}
```
This keeps the current behavior while making updates safe for common special
characters in values.
--
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]