fix(framework/tools): eval injection, broken JSON, tmpfile leak (#548)
F-01 (HIGH): issue-edit.sh and issue-assign.sh used string interpolation + eval to build CLI commands. Replace all eval sites with Bash arrays so user-supplied values (title, body, labels) are never shell-expanded. For the Gitea path, replace get_gitea_repo_args() (which emits %q-escaped strings designed for eval) with get_repo_slug() + get_gitea_login() so repo/login are passed as properly-quoted array elements. F-07 (MED): milestone-create.sh built the GitHub API JSON payload by string interpolation — a title containing " or $ broke the JSON. Rebuild with jq -n --arg so all values are safely serialised. Optional description key is omitted when empty, preserving existing behaviour. F-13 (LOW): pr-metadata.sh created a mktemp tmpfile inside curl_gitea_pull() but only removed it in success paths. Add trap 'rm -f "$body_file"' EXIT immediately after mktemp so early-exit paths (set -e, SIGINT) also clean up. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kt2D8TsnDwhtzEAPijsNmR
This commit is contained in:
@@ -99,10 +99,15 @@ fi
|
||||
case "$PLATFORM" in
|
||||
github)
|
||||
# GitHub uses the API for milestone creation
|
||||
JSON_PAYLOAD="{\"title\":\"$TITLE\""
|
||||
[[ -n "$DESCRIPTION" ]] && JSON_PAYLOAD="$JSON_PAYLOAD,\"description\":\"$DESCRIPTION\""
|
||||
[[ -n "$DUE_DATE" ]] && JSON_PAYLOAD="$JSON_PAYLOAD,\"due_on\":\"${DUE_DATE}T00:00:00Z\""
|
||||
JSON_PAYLOAD="$JSON_PAYLOAD}"
|
||||
# Use jq to safely construct JSON so titles/descriptions containing
|
||||
# quotes or special characters do not corrupt the payload (F-07).
|
||||
JSON_PAYLOAD=$(jq -n \
|
||||
--arg t "$TITLE" \
|
||||
--arg d "$DESCRIPTION" \
|
||||
--arg due "${DUE_DATE}" \
|
||||
'{"title": $t}
|
||||
+ (if $d != "" then {"description": $d} else {} end)
|
||||
+ (if $due != "" then {"due_on": ($due + "T00:00:00Z")} else {} end)')
|
||||
|
||||
gh api repos/:owner/:repo/milestones --method POST --input - <<< "$JSON_PAYLOAD"
|
||||
echo "Milestone '$TITLE' created successfully"
|
||||
|
||||
Reference in New Issue
Block a user