Skip to content

Commit

Permalink
fix: Validate numeric inputs in check_interval_elapsed function to pr…
Browse files Browse the repository at this point in the history
…event bash syntax errors
  • Loading branch information
pcfreak30 committed Dec 18, 2024
1 parent 94f582b commit e9812fe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/mysql-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ check_interval_elapsed() {
local last_time=$1
local interval=$2
local current_time=$(get_current_timestamp)
[ $((current_time - last_time)) -ge $interval ]

# Ensure we have numeric values
if ! [[ "$last_time" =~ ^[0-9]+$ ]] || ! [[ "$interval" =~ ^[0-9]+$ ]]; then
return 1
fi

local elapsed=$((current_time - last_time))
[ "$elapsed" -ge "$interval" ]
}

# Update monitor state
Expand Down

0 comments on commit e9812fe

Please sign in to comment.