Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions controllers/brokerscripts/readiness_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,32 @@ if [ "${BROKER_REDUNDANCY}" = "true" ]; then
rm -f ${FINAL_ACTIVITY_LOGGED_TRACKING_FILE}; exit 1
fi
fi
broker_version=$(/mnt/disks/solace/semp_query.sh -n admin -p ${password} -u http://localhost:8080 \
-q "<rpc><show><version/></show></rpc>" \
-v "/rpc-reply/rpc/show/version/current-load[text()]")
broker_version=`echo ${broker_version} | xmllint -xpath "string(returnInfo/valueSearchResult)" - | cut -d'.' -f2`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security - Command Injection Risk: Properly quote the password variable or use a more secure method to pass credentials, such as reading from a secure file or using environment variables with proper escaping.

Suggested change
broker_version=`echo ${broker_version} | xmllint -xpath "string(returnInfo/valueSearchResult)" - | cut -d'.' -f2`
broker_version=`echo ${broker_version} | xmllint -xpath "string(returnInfo/valueSearchResult)" -`
# Extract major version with robust parsing and validation
if [[ "$broker_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
broker_version=$(echo "$broker_version" | cut -d'.' -f1)
else
echo "$(date) WARNING: Unable to parse broker version format: $broker_version"
broker_version=0
fi

if [[ "${broker_version}" -ge 8 ]]; then
# DMR cluster operation state
cluster_status=$(/mnt/disks/solace/semp_query.sh -n admin -p ${password} -u http://localhost:8080 \
-q "<rpc><show><cluster><cluster-name-pattern>*</cluster-name-pattern></cluster></show></rpc>" \
-v "/rpc-reply/rpc/show/cluster/clusters/cluster/oper-up[text()]")
cluster_status=`echo ${cluster_status} | xmllint -xpath "string(returnInfo/valueSearchResult)" -`
if [ "${cluster_status}" != "true" ] && [ "${cluster_status}" != "" ]; then
echo "$(date) INFO: ${APP}-DMR cluster operational state is down"
exit 1
fi
fi
if [[ "${broker_version}" -ge 11 ]]; then
# DMR sync state
cluster_sync_status=$(/mnt/disks/solace/semp_query.sh -n admin -p ${password} -u http://localhost:8080 \
-q "<rpc><show><cluster><cluster-name-pattern>*</cluster-name-pattern></cluster></show></rpc>" \
-v "/rpc-reply/rpc/show/cluster/clusters/cluster/sync-complete[text()]")
cluster_sync_status=`echo ${cluster_sync_status} | xmllint -xpath "string(returnInfo/valueSearchResult)" -`
if [ "${cluster_sync_status}" != "true" ] && [ "${cluster_sync_status}" != "" ]; then
echo "$(date) INFO: ${APP}-DMR cluster is not in-sync"
exit 1
fi
fi
# Pass readiness check
if [ ! -f ${FINAL_ACTIVITY_LOGGED_TRACKING_FILE} ]; then
echo "$(date) INFO: ${APP}-Redundancy is up and node is Mate Active"
Expand Down
Loading