Skip to content

Commit

Permalink
fix: fix Security vulnerability
Browse files Browse the repository at this point in the history
Signed-off-by: Xinwei Xiong (cubxxw) <[email protected]>
  • Loading branch information
cubxxw committed Dec 15, 2023
1 parent 10646f2 commit 080dfb2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions config/templates/config.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions config/templates/env.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 19 additions & 7 deletions scripts/init-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}" || {
Expand All @@ -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}"
Expand All @@ -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}"
Expand Down

0 comments on commit 080dfb2

Please sign in to comment.