From 9126ee28b147b31e8e8c3da5a7df9d6858a0f6ab Mon Sep 17 00:00:00 2001 From: Srikanth Muppandam Date: Mon, 12 Oct 2026 22:25:18 +0530 Subject: [PATCH 1/2] sensors: add CSV parsing and harden shared tool validation Add a pure CSV parser that trims and deduplicates TYPE names while rejecting empty or unsafe fields. Require successful see_workhorse exit and its final PASS marker, and retain timeout failure even when the client exits zero. Keep existing helper call signatures and execution timing. This foundation is usable with the existing runner and supplies sensors_parse_csv for the following integration commit. Signed-off-by: Srikanth Muppandam --- Runner/utils/lib_sensors.sh | 59 ++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/Runner/utils/lib_sensors.sh b/Runner/utils/lib_sensors.sh index cade740cf..c2774551a 100755 --- a/Runner/utils/lib_sensors.sh +++ b/Runner/utils/lib_sensors.sh @@ -8,6 +8,36 @@ SENSORS_ADSP_FW="" SENSORS_ADSP_RPROC_PATH="" SENSORS_ADSP_STATE="" +# sensors_parse_csv CSV +# Validate comma-separated TYPE names, trim surrounding whitespace and deduplicate. +# Output: newline-separated names on stdout only after the entire input is valid. +# Returns 0 on success, 1 for empty fields or unsafe names. No shell-state changes. +sensors_parse_csv() { + printf '%s\n' "$1" | LC_ALL=C awk ' + { input = input $0 "\n" } + END { + count = split(input, fields, ",") + for (item = 1; item <= count; item++) { + name = fields[item] + sub(/^[[:space:]]+/, "", name) + sub(/[[:space:]]+$/, "", name) + if (name !~ /^[[:alnum:]_][[:alnum:]_-]*$/) { + exit 1 + } + if (!seen[name]++) { + names[++total] = name + } + } + if (!total) { + exit 1 + } + for (item = 1; item <= total; item++) { + print names[item] + } + } + ' +} + sensors__trim_ws() { # usage: sensors__trim_ws " abc " -> prints "abc" # shellcheck disable=SC2001 @@ -158,8 +188,10 @@ sensors_select_testable_types() { done } -# Run a command in background, redirect all output to logfile, and print a heartbeat. # sensors_run_cmd_with_progress