From 080dfb222aee9d2bb1219696f63d64a8f2503fc3 Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong (cubxxw)" <3293172751nss@gmail.com> Date: Fri, 15 Dec 2023 21:09:41 +0800 Subject: [PATCH] fix: fix Security vulnerability Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> --- Dockerfile | 2 +- config/templates/config.yaml.template | 6 +++--- config/templates/env.template | 4 ++-- scripts/init-config.sh | 26 +++++++++++++++++++------- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5f93ac53c2..32639af7a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ ENV GOPROXY=$GOPROXY # Set up the working directory WORKDIR /openim/openim-server -COPY go.mod go.sum ./dd +COPY go.mod go.sum ./ RUN go mod download # Copy all files to the container diff --git a/config/templates/config.yaml.template b/config/templates/config.yaml.template index fd51a2e318..64a274b56b 100644 --- a/config/templates/config.yaml.template +++ b/config/templates/config.yaml.template @@ -122,14 +122,14 @@ api: # minio.signEndpoint is minio public network address object: enable: "minio" - apiURL: "http://14.155.64.202:10002" + apiURL: "http://172.28.0.1:10002" minio: bucket: "openim" endpoint: "http://172.28.0.1:10005" accessKeyID: "root" secretAccessKey: "openIM123" sessionToken: '' - signEndpoint: "http://14.155.64.202:10005" + signEndpoint: "http://172.28.0.1:10005" publicRead: false cos: bucketURL: https://temp-1252357374.cos.ap-chengdu.myqcloud.com @@ -193,7 +193,7 @@ rpcRegisterName: # Whether to output in json format # Whether to include stack trace in logs log: - storageLocation: /data/workspaces/open-im-server/logs/ + storageLocation: ../logs/ rotationTime: 24 remainRotationCount: 2 remainLogLevel: 6 diff --git a/config/templates/env.template b/config/templates/env.template index 94b5dca067..f3ca987cef 100644 --- a/config/templates/env.template +++ b/config/templates/env.template @@ -26,11 +26,11 @@ PASSWORD=openIM123 # Base URL for the application programming interface (API). # Default: API_URL=http://172.28.0.1:10002 -API_URL=http://14.155.64.202:10002 +API_URL=http://172.28.0.1:10002 # Directory path for storing data files or related information. # Default: DATA_DIR=./ -DATA_DIR=/data/workspaces/open-im-server +DATA_DIR=./ # Choose the appropriate image address, the default is GITHUB image, # you can choose docker hub, for Chinese users can choose Ali Cloud diff --git a/scripts/init-config.sh b/scripts/init-config.sh index 90118cc1a9..8dba7312a2 100755 --- a/scripts/init-config.sh +++ b/scripts/init-config.sh @@ -111,6 +111,7 @@ generate_example_files() { local example_file="${COPY_EXAMPLES[$template]}" process_file "$template" "$example_file" false done + } # Function to process a single file, either by generating or copying @@ -146,10 +147,17 @@ process_file() { openim::log::error "genconfig.sh script not found" exit 1 fi - "${OPENIM_ROOT}/scripts/genconfig.sh" "${ENV_FILE}" "${template}" > "${output_file}" || { - openim::log::error "Error processing template file ${template}" - exit 1 - } + if [[ -n "${env_cmd}" ]]; then + eval "$env_cmd ${OPENIM_ROOT}/scripts/genconfig.sh '${ENV_FILE}' '${template}' > '${output_file}'" || { + openim::log::error "Error processing template file ${template}" + exit 1 + } + else + "${OPENIM_ROOT}/scripts/genconfig.sh" "${ENV_FILE}" "${template}" > "${output_file}" || { + openim::log::error "Error processing template file ${template}" + exit 1 + } + fi else openim::log::info "๐Ÿ“‹ Copying ${template} to ${output_file}..." cp "${template}" "${output_file}" || { @@ -167,9 +175,10 @@ declare -A env_vars=( ["LOG_STORAGE_LOCATION"]="../logs/" ) -# Function to clean configuration files clean_config_files() { - for output_file in "${TEMPLATES[@]}"; do + local all_templates=("${TEMPLATES[@]}" "${COPY_TEMPLATES[@]}") + + for output_file in "${all_templates[@]}"; do if [[ -f "${output_file}" ]]; then rm -f "${output_file}" openim::log::info "Removed configuration file: ${output_file}" @@ -179,7 +188,10 @@ clean_config_files() { # Function to clean example files clean_example_files() { - for example_file in "${EXAMPLES[@]}"; do + # ๅˆๅนถ EXAMPLES ๅ’Œ COPY_EXAMPLES ๆ•ฐ็ป„ + local all_examples=("${EXAMPLES[@]}" "${COPY_EXAMPLES[@]}") + + for example_file in "${all_examples[@]}"; do if [[ -f "${example_file}" ]]; then rm -f "${example_file}" openim::log::info "Removed example file: ${example_file}"