-
Notifications
You must be signed in to change notification settings - Fork 6
fix(supervisor): add missing $SUPERVISOR_DB arg, remove PATH guard (t147.1) #450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6a3b621
cc7db3c
52e2c7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,12 +62,12 @@ set -euo pipefail | |
|
|
||
| # Ensure common tool paths are available (cron has minimal PATH: /usr/bin:/bin) | ||
| # Without this, gh, opencode, node, etc. are unreachable from cron-triggered pulses | ||
| if [[ -z "${HOMEBREW_PREFIX:-}" ]]; then | ||
| for _p in /opt/homebrew/bin /usr/local/bin "$HOME/.local/bin" "$HOME/.cargo/bin"; do | ||
| [[ -d "$_p" && ":$PATH:" != *":$_p:"* ]] && export PATH="$_p:$PATH" | ||
| done | ||
| unset _p | ||
| fi | ||
| # No HOMEBREW_PREFIX guard: the idempotent ":$PATH:" check prevents duplicates, | ||
| # and cron may have HOMEBREW_PREFIX set without all tool paths present | ||
| for _p in /opt/homebrew/bin /usr/local/bin "$HOME/.local/bin" "$HOME/.cargo/bin"; do | ||
| [[ -d "$_p" && ":$PATH:" != *":$_p:"* ]] && export PATH="$_p:$PATH" | ||
| done | ||
| unset _p | ||
|
|
||
| # Configuration - resolve relative to this script's location | ||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" || exit | ||
|
|
@@ -3163,9 +3163,8 @@ cmd_pr_lifecycle() { | |
| ;; | ||
| no_pr) | ||
| # Track consecutive no_pr failures to avoid infinite retry loop | ||
| local no_pr_key="no_pr_retries_${task_id}" | ||
| local no_pr_count | ||
| no_pr_count=$(db "SELECT COALESCE( | ||
| no_pr_count=$(db "$SUPERVISOR_DB" "SELECT COALESCE( | ||
| (SELECT CAST(json_extract(error, '$.no_pr_retries') AS INTEGER) | ||
| FROM tasks WHERE id='$task_id'), 0);" 2>/dev/null || echo "0") | ||
| no_pr_count=$((no_pr_count + 1)) | ||
|
|
@@ -3183,7 +3182,7 @@ cmd_pr_lifecycle() { | |
|
|
||
| log_warn "No PR found for $task_id (attempt $no_pr_count/5)" | ||
| # Store retry count in error field as JSON | ||
| db "UPDATE tasks SET error = json_set(COALESCE(error, '{}'), '$.no_pr_retries', $no_pr_count), updated_at = strftime('%Y-%m-%dT%H:%M:%SZ','now') WHERE id='$task_id';" 2>/dev/null || true | ||
| db "$SUPERVISOR_DB" "UPDATE tasks SET error = json_set(COALESCE(error, '{}'), '$.no_pr_retries', $no_pr_count), updated_at = strftime('%Y-%m-%dT%H:%M:%SZ','now') WHERE id='$task_id';" 2>/dev/null || true | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the Please apply the same validation for |
||
| return 0 | ||
| ;; | ||
| esac | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This query appears to be vulnerable to SQL injection. The
$task_idvariable is interpolated directly into the SQL string. If this variable can be influenced by an external source, it could be manipulated to alter the query's logic, potentially affecting unintended rows or exposing data.To mitigate this, I recommend validating the
$task_idto ensure it conforms to an expected format before it's used in the query. For example:This validation should be performed before the database call.