This commit is contained in:
@@ -99,7 +99,7 @@ prompt_if_empty() {
|
||||
|
||||
if [[ $NON_INTERACTIVE -eq 1 ]]; then
|
||||
if [[ -n "$default_value" ]]; then
|
||||
eval "$var_name=\"$default_value\""
|
||||
printf -v "$var_name" %s "$default_value"
|
||||
return
|
||||
fi
|
||||
echo "[mosaic-init] ERROR: --$var_name is required in non-interactive mode" >&2
|
||||
@@ -115,7 +115,7 @@ prompt_if_empty() {
|
||||
if [[ -z "$value" && -n "$default_value" ]]; then
|
||||
value="$default_value"
|
||||
fi
|
||||
eval "$var_name=\"$value\""
|
||||
printf -v "$var_name" %s "$value"
|
||||
}
|
||||
|
||||
prompt_multiline() {
|
||||
@@ -129,7 +129,7 @@ prompt_multiline() {
|
||||
fi
|
||||
|
||||
if [[ $NON_INTERACTIVE -eq 1 ]]; then
|
||||
eval "$var_name=\"$default_value\""
|
||||
printf -v "$var_name" %s "$default_value"
|
||||
return
|
||||
fi
|
||||
|
||||
@@ -139,7 +139,7 @@ prompt_multiline() {
|
||||
if [[ -z "$value" ]]; then
|
||||
value="$default_value"
|
||||
fi
|
||||
eval "$var_name=\"$value\""
|
||||
printf -v "$var_name" %s "$value"
|
||||
}
|
||||
|
||||
# ── Existing file detection ────────────────────────────────────
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Source only the prompt helpers; executing mosaic-init itself requires templates.
|
||||
source <(head -n 144 "$(dirname "$0")/mosaic-init")
|
||||
|
||||
rm -f /tmp/pwned
|
||||
payload='literal "$(touch /tmp/pwned)"'
|
||||
AGENT_NAME=""
|
||||
prompt_if_empty AGENT_NAME "Agent name" <<<"$payload"
|
||||
|
||||
[[ "$AGENT_NAME" == "$payload" ]] || {
|
||||
echo "FAIL: prompt answer did not round-trip literally" >&2
|
||||
exit 1
|
||||
}
|
||||
[[ ! -e /tmp/pwned ]] || {
|
||||
echo "FAIL: prompt answer executed code" >&2
|
||||
rm -f /tmp/pwned
|
||||
exit 1
|
||||
}
|
||||
echo "mosaic-init RCE regression: PASS"
|
||||
Reference in New Issue
Block a user