Skip to content

RDKEMW-13061: Include utility indepenent of T2 for telemetry upload - #443

Merged
shibu-kv merged 1 commit into
support/4.2.1from
hotfix/RDKEMW-13061
Feb 4, 2026
Merged

RDKEMW-13061: Include utility indepenent of T2 for telemetry upload#443
shibu-kv merged 1 commit into
support/4.2.1from
hotfix/RDKEMW-13061

Conversation

@shibu-kv

@shibu-kv shibu-kv commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

Reason for change :
1] Adding utility that DS manager can use for critical deep sleep event notification to telemetry cloud 2] This provides a short circuited path only to be used for time critical eventing which is constrained
by scenarios like the CPU going to hibernate modes.

Reason for change :
1] Adding utility that DS manager can use for critical deep sleep event notification to telemetry cloud
2] This provides a short circuited path only to be used for time critical eventing which is constrained
     by scenarios like the CPU going to hibernate modes.
@shibu-kv
shibu-kv requested a review from a team as a code owner February 3, 2026 21:10
Copilot AI review requested due to automatic review settings February 3, 2026 21:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new utility script alertSystem.sh to provide direct telemetry uploads independent of T2, specifically designed for time-critical event notifications from the Deep Sleep Manager when the CPU is about to enter hibernate mode.

Changes:

  • Adds a new alertSystem.sh script for immediate telemetry event notification
  • Implements direct curl-based upload to telemetry cloud using mTLS
  • Provides a short-circuited path for critical deep sleep events before system hibernation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/rdk/alertSystem.sh
fi

# Configuration Files
VERSION=1

Copilot AI Feb 3, 2026

Copy link

Choose a reason for hiding this comment

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

The VERSION variable is defined but never used in the script. Consider removing it if it's not needed, or include it in the telemetry payload if version tracking is required.

Suggested change
VERSION=1

Copilot uses AI. Check for mistakes.
Comment thread lib/rdk/alertSystem.sh
Comment on lines +102 to +103
# Message data is actual metadata header in case of trigger from deepSleep manager process
# This change is needed since there are data clouds in different deployment which are not flexible to accomodate any deviations in data format

Copilot AI Feb 3, 2026

Copy link

Choose a reason for hiding this comment

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

The comment describes this as a "Message data is actual metadata header" but it's not clear what this means. The logic constructs different JSON structures for deepSleepMgrMain vs other processes, where MSG_DATA is used as a key name in one case and as a value in another. This dual interpretation could be confusing. Consider clarifying the comment to explain that for deepSleepMgrMain, MSG_DATA contains a marker name that becomes the JSON key, while for other processes it's a log entry message.

Copilot uses AI. Check for mistakes.
Comment thread lib/rdk/alertSystem.sh
Comment on lines +104 to +106
strjson="{\"searchResult\":[{\"Time\":\"$currentTime\"},{\"process_name\":\"$PROCESS_NAME\"},{\"mac\":\"$estb_mac\"},{\"Version\":\"$software_version\"},{\"PartnerId\":\"$partnerId\"},{\"$MSG_DATA\":\"1\"}]}"
else
strjson="{\"searchResult\":[{\"process_name\":\"$PROCESS_NAME\"},{\"mac\":\"$estb_mac\"},{\"Version\":\"$software_version\"},{\"msgTime\":\"$currentTime\"},{\"PartnerId\":\"$partnerId\"},{\"logEntry\":\"$MSG_DATA\"}]}"

Copilot AI Feb 3, 2026

Copy link

Choose a reason for hiding this comment

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

The MSG_DATA variable is directly embedded into JSON without any escaping or validation. If MSG_DATA contains special characters like quotes, backslashes, or newlines, it could break the JSON structure or potentially lead to injection issues. Consider sanitizing or escaping the input before including it in the JSON payload, especially since this data is being sent to an external telemetry endpoint.

Copilot uses AI. Check for mistakes.
Comment thread lib/rdk/alertSystem.sh
Comment on lines +110 to +112
CURL_INPUT=" -w '%{http_code}\n' -H \"Accept: application/json\" -H \"Content-type: application/json\" -X POST -d '$strjson' -o \"$HTTP_FILENAME\" \"$UPLOAD_END_POINT\" --cert-status --connect-timeout 30 -m 30 "
else
CURL_INPUT=" -w '%{http_code}\n' -H \"Accept: application/json\" -H \"Content-type: application/json\" -X POST -d '$strjson' -o \"$HTTP_FILENAME\" \"$UPLOAD_END_POINT\" --connect-timeout 30 -m 30 "

Copilot AI Feb 3, 2026

Copy link

Choose a reason for hiding this comment

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

The strjson variable containing user-provided data is embedded in single quotes within the CURL_INPUT string. If MSG_DATA or PROCESS_NAME contains single quotes, it could break out of the quoting and potentially cause command injection or curl execution failures. Consider using proper escaping or an alternative approach to pass the JSON data securely to curl.

Copilot uses AI. Check for mistakes.
Comment thread lib/rdk/alertSystem.sh
# Extract upload end point from DCM processed telemetry profile
if [ -f $TELEMETRY_PROFILE_DEFAULT_PATH ]; then
UPLOAD_END_POINT=`grep '"uploadRepository:URL":"' $TELEMETRY_PROFILE_DEFAULT_PATH | awk -F 'uploadRepository:URL":' '{print $NF}' | awk -F '",' '{print $1}' | sed 's/"//g' | sed 's/}//g'`
if [ ! -z "$UPLOAD_END_POINT" ]; then

Copilot AI Feb 3, 2026

Copy link

Choose a reason for hiding this comment

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

Using '! -z' is a double negative that reduces readability. Use '-n' to test if a string is non-empty for better clarity. This is consistent with better shell scripting practices.

Copilot uses AI. Check for mistakes.
Comment thread lib/rdk/alertSystem.sh
exit 1
fi

# Argument Assigment

Copilot AI Feb 3, 2026

Copy link

Choose a reason for hiding this comment

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

Corrected spelling of 'Assigment' to 'Assignment'

Suggested change
# Argument Assigment
# Argument Assignment

Copilot uses AI. Check for mistakes.
Comment thread lib/rdk/alertSystem.sh
. /lib/rdk/getPartnerId.sh
fi

if [ -f $RDK_PATH/exec_curl_mtls.sh ]; then

Copilot AI Feb 3, 2026

Copy link

Choose a reason for hiding this comment

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

The variable RDK_PATH is used without checking if /etc/device.properties was successfully sourced or if RDK_PATH is defined. If device.properties doesn't exist or doesn't define RDK_PATH, the script will fail with unclear error messages. Add a check to ensure RDK_PATH is defined after sourcing device.properties, similar to how other scripts in the codebase handle this dependency (e.g., uploadSTBLogs.sh sources device.properties before using RDK_PATH).

Copilot uses AI. Check for mistakes.
Comment thread lib/rdk/alertSystem.sh
partnerId=$(getPartnerId)
echo "$SCRIPT_NAME: $currentTime"

# Loggging should be handled by the caller

Copilot AI Feb 3, 2026

Copy link

Choose a reason for hiding this comment

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

Corrected spelling of 'Loggging' to 'Logging'

Suggested change
# Loggging should be handled by the caller
# Logging should be handled by the caller

Copilot uses AI. Check for mistakes.
Comment thread lib/rdk/alertSystem.sh
software_version=`grep ^imagename: /version.txt | cut -d ':' -f2`


if [ "x$PROCESS_NAME" == "xdeepSleepMgrMain" ]; then

Copilot AI Feb 3, 2026

Copy link

Choose a reason for hiding this comment

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

Using '==' for string comparison in shell test is Bash-specific. The shebang uses '#!/bin/sh' which may not be bash on all systems. For POSIX compliance, use single '=' for string comparison. This pattern is used throughout the codebase (see NM_Dispatcher.sh:56, cdlSupport.sh:225).

Copilot uses AI. Check for mistakes.
Comment thread lib/rdk/alertSystem.sh
else
CURL_INPUT=" -w '%{http_code}\n' -H \"Accept: application/json\" -H \"Content-type: application/json\" -X POST -d '$strjson' -o \"$HTTP_FILENAME\" \"$UPLOAD_END_POINT\" --connect-timeout 30 -m 30 "
fi
alertLog "$SCRIPT_NAME: CURL_INPUT : $CURL_INPUT"

Copilot AI Feb 3, 2026

Copy link

Choose a reason for hiding this comment

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

The CURL_INPUT is logged including the complete JSON payload which may contain sensitive data. Consider whether the alert message content should be logged, or if it should be redacted for security/privacy reasons.

Suggested change
alertLog "$SCRIPT_NAME: CURL_INPUT : $CURL_INPUT"
alertLog "$SCRIPT_NAME: CURL request prepared for endpoint $UPLOAD_END_POINT (payload redacted)"

Copilot uses AI. Check for mistakes.
@shibu-kv
shibu-kv merged commit 00f2da8 into support/4.2.1 Feb 4, 2026
10 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants