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
10 changes: 8 additions & 2 deletions .agents/scripts/auto-update-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ get_remote_version() {
#######################################
is_update_running() {
# Check for running setup.sh processes (not our own)
if pgrep -f "setup\.sh" >/dev/null 2>&1; then
# Use full path to avoid matching unrelated projects' setup.sh scripts
if pgrep -f "${INSTALL_DIR}/setup\.sh" >/dev/null 2>&1; then
Comment on lines +172 to +173
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For improved robustness, it's a good practice to escape the INSTALL_DIR variable to handle any potential regex metacharacters it might contain. While it's unlikely to be an issue with the current hardcoded path, this would prevent pgrep from misinterpreting the pattern if the path were to change to include characters like . or * in a username.

Suggested change
# Use full path to avoid matching unrelated projects' setup.sh scripts
if pgrep -f "${INSTALL_DIR}/setup\.sh" >/dev/null 2>&1; then
# Use full path to avoid matching unrelated projects' setup.sh scripts
# Escape INSTALL_DIR for safe use in regex
local escaped_install_dir
escaped_install_dir=$(sed 's/[][.^*+?(){}|$\\]/\\&/g' <<< "$INSTALL_DIR")
if pgrep -f "${escaped_install_dir}/setup\.sh" >/dev/null 2>&1; then

return 0
fi
# Check for running aidevops update
Expand Down Expand Up @@ -237,6 +238,11 @@ check_skill_freshness() {
fi

local freshness_hours="${AIDEVOPS_SKILL_FRESHNESS_HOURS:-$DEFAULT_SKILL_FRESHNESS_HOURS}"
# Validate freshness_hours is a positive integer (non-numeric crashes under set -e)
if ! [[ "$freshness_hours" =~ ^[0-9]+$ ]] || [[ "$freshness_hours" -eq 0 ]]; then
log_warn "AIDEVOPS_SKILL_FRESHNESS_HOURS='${freshness_hours}' is not a positive integer — using default (${DEFAULT_SKILL_FRESHNESS_HOURS}h)"
freshness_hours="$DEFAULT_SKILL_FRESHNESS_HOURS"
fi
local freshness_seconds=$((freshness_hours * 3600))

# Read last skill check timestamp from state file
Expand Down Expand Up @@ -618,7 +624,7 @@ HOW IT WORKS:
5. Skips if another update is already in progress
6. Runs daily skill freshness check (24h gate):
a. Reads last_skill_check from state file
b. If >24h since last check, calls skill-update-helper.sh --auto-update --quiet
b. If >24h since last check, calls skill-update-helper.sh check --auto-update --quiet
c. Updates last_skill_check timestamp in state file
d. Runs on every cmd_check invocation (gate prevents excessive network calls)

Expand Down
Loading