Skip to content
Merged
Show file tree
Hide file tree
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
20 changes: 20 additions & 0 deletions .agents/scripts/supervisor-archived/batch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ cmd_add() {
log_error "--max-retries requires a value"
return 1
}
# GH#3716: Validate max_retries is a non-negative integer before SQL interpolation
if ! [[ "$2" =~ ^[0-9]+$ ]]; then
log_error "--max-retries must be a non-negative integer, got: $2"
return 1
fi
max_retries="$2"
shift 2
;;
Expand Down Expand Up @@ -240,6 +245,11 @@ cmd_batch() {
log_error "--concurrency requires a value"
return 1
}
# GH#3716: Validate concurrency is a positive integer before SQL interpolation
if ! [[ "$2" =~ ^[0-9]+$ ]] || [[ "$2" -eq 0 ]]; then
log_error "--concurrency must be a positive integer, got: $2"
return 1
fi
Comment on lines +249 to +252
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

To enhance defense-in-depth against potential injection attacks when parsing numeric data from untrusted sources, it's crucial to validate numeric fields. You can simplify this positive integer validation by using a single regular expression that excludes zero. This makes the check more concise, readable, and robust.

Suggested change
if ! [[ "$2" =~ ^[0-9]+$ ]] || [[ "$2" -eq 0 ]]; then
log_error "--concurrency must be a positive integer, got: $2"
return 1
fi
if ! [[ "$2" =~ ^[1-9][0-9]*$ ]]; then
log_error "--concurrency must be a positive integer, got: $2"
return 1
fi
References
  1. When parsing delimited data from an untrusted source in a shell script, validate numeric fields before using them in calculations. This provides defense-in-depth against injection attacks that could result from delimiter shifting caused by malicious data.

concurrency="$2"
shift 2
;;
Expand All @@ -248,6 +258,11 @@ cmd_batch() {
log_error "--max-concurrency requires a value"
return 1
}
# GH#3716: Validate max_concurrency is a non-negative integer before SQL interpolation
if ! [[ "$2" =~ ^[0-9]+$ ]]; then
log_error "--max-concurrency must be a non-negative integer, got: $2"
return 1
fi
max_concurrency="$2"
shift 2
;;
Expand All @@ -264,6 +279,11 @@ cmd_batch() {
log_error "--max-load requires a value"
return 1
}
# GH#3716: Validate max_load_factor is a non-negative integer before SQL interpolation
if ! [[ "$2" =~ ^[0-9]+$ ]]; then
log_error "--max-load must be a non-negative integer, got: $2"
return 1
fi
max_load_factor="$2"
shift 2
;;
Expand Down
5 changes: 5 additions & 0 deletions .agents/scripts/supervisor-archived/cron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ cmd_cron() {
log_error "--interval requires a value"
return 1
}
# GH#3716: Validate interval is a positive integer before use in cron/launchd commands
if ! [[ "$2" =~ ^[0-9]+$ ]] || [[ "$2" -eq 0 ]]; then
log_error "--interval must be a positive integer (minutes), got: $2"
return 1
fi
Comment on lines +38 to +41
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

To enhance defense-in-depth against potential injection attacks when parsing numeric data from untrusted sources, it's crucial to validate numeric fields. Similar to the validation for --concurrency, you can simplify this positive integer check by using a single regular expression that matches numbers starting from 1. This improves consistency, makes the validation logic more direct, and enhances robustness.

Suggested change
if ! [[ "$2" =~ ^[0-9]+$ ]] || [[ "$2" -eq 0 ]]; then
log_error "--interval must be a positive integer (minutes), got: $2"
return 1
fi
if ! [[ "$2" =~ ^[1-9][0-9]*$ ]]; then
log_error "--interval must be a positive integer (minutes), got: $2"
return 1
fi
References
  1. When parsing delimited data from an untrusted source in a shell script, validate numeric fields before using them in calculations. This provides defense-in-depth against injection attacks that could result from delimiter shifting caused by malicious data.

interval="$2"
shift 2
;;
Expand Down
4 changes: 2 additions & 2 deletions .agents/scripts/supervisor-archived/database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,10 @@ CREATE TABLE tasks (
);
INSERT INTO tasks (id, repo, description, status, session_id, worktree, branch,
log_file, retries, max_retries, model, error, pr_url, issue_url, diagnostic_of,
created_at, started_at, completed_at, updated_at)
triage_result, created_at, started_at, completed_at, updated_at)
SELECT id, repo, description, status, session_id, worktree, branch,
log_file, retries, max_retries, model, error, pr_url, issue_url, diagnostic_of,
created_at, started_at, completed_at, updated_at
triage_result, created_at, started_at, completed_at, updated_at
FROM tasks_old_t148;
DROP TABLE tasks_old_t148;
CREATE INDEX IF NOT EXISTS idx_tasks_status ON tasks(status);
Expand Down
Loading