mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-17 20:39:13 +00:00
fix: work through the remaining review findings on the editor and bridge
allow_insecure_mqtt (CWE-319, requested): a password with TLS disabled crosses
the network in cleartext. Refused now rather than merely warned about -- but
refused, not forbidden, because unencrypted MQTT on a trusted LAN is a normal
deliberate setup. allow_insecure_mqtt is the explicit acknowledgement, defaults
false, and is coerced like the other booleans so the string "false" cannot
switch the guard off.
starlark.py:796 -- the supported service runs Flask threaded, so two start
requests could each see running=False, each launch an editor, and the second
state write replace the first PID, orphaning a process that holds the display
down with nothing recording it. The check-launch-write sequence now takes a
module-level lock.
starlark.py:848 -- if the state write failed the route returned success with an
editor running and no PID recorded: status and stop both reported no session
while the display stayed down until the timeout expired. It now terminates the
process group and returns an error.
starlark.py:890 -- SIGKILL gives the script's EXIT trap no chance to run, so
nothing hands the display back, yet the response said "the display is
restarting". After an escalation the display is now restarted explicitly, and a
failure to do so returns an error naming the manual step instead of a success.
pixlet_config_editor.sh:184 -- find_pixlet supports Darwin but macOS ships no
timeout(1); GNU coreutils installs it as gtimeout. Resolved up front so the
failure lands before the display is stopped rather than after.
pixlet_config_editor.sh:154 -- wildcard, loopback and an explicit interface
address are three cases, not two. Collapsing the last two printed a URL saying
"localhost" whenever PIXLET_EDITOR_HOST named a LAN address.
tools.html:1254 -- escHtml does not encode single quotes, and the app id was
interpolated into an inline onclick="startPixletEditor('...')", so a directory
containing an apostrophe could break out of the JS string and run script. The
handler binds with addEventListener and reads the id from dataset, where it is
only ever parsed as an HTML attribute.
Tests: test_mqtt_bridge_config_endpoint.py grows to 23 cases covering the opt-in
in both directions. The tools DOM suite gains three guards asserting the edit
buttons carry no inline onclick and pass the id via dataset -- those need jsdom
and did not run here, so CI verifies them.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -104,6 +104,29 @@ PIXLET_BIN=$(find_pixlet) || {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# find_pixlet supports Darwin, so this script has to as well. macOS ships no
|
||||
# timeout(1); GNU coreutils installs it as gtimeout. Resolve whichever exists
|
||||
# and fail here with instructions rather than at the invocation far below,
|
||||
# where the failure would land after the display has already been stopped.
|
||||
find_timeout() {
|
||||
local candidate
|
||||
for candidate in timeout gtimeout; do
|
||||
if command -v "$candidate" >/dev/null 2>&1; then
|
||||
command -v "$candidate"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
TIMEOUT_BIN=$(find_timeout) || {
|
||||
echo "Neither 'timeout' nor 'gtimeout' was found on PATH."
|
||||
echo "This script needs one to bound the editing session."
|
||||
echo "On macOS, install GNU coreutils:"
|
||||
echo " brew install coreutils"
|
||||
exit 1
|
||||
}
|
||||
|
||||
CONFIG_FILE="$APP_DIR/config.json"
|
||||
if [ -f "$CONFIG_FILE" ]; then
|
||||
cp "$CONFIG_FILE" "$CONFIG_FILE.backup"
|
||||
@@ -148,11 +171,14 @@ if [ "$DISPLAY_WAS_RUNNING" = true ]; then
|
||||
sudo systemctl stop ledmatrix
|
||||
fi
|
||||
|
||||
if [ "$BIND_HOST" = "0.0.0.0" ]; then
|
||||
REACH_HOST="$(hostname).local"
|
||||
else
|
||||
REACH_HOST="localhost"
|
||||
fi
|
||||
# Wildcard, loopback and an explicit interface address are three different
|
||||
# cases. Collapsing the last two into "localhost" printed a URL pointing at the
|
||||
# user's own machine whenever PIXLET_EDITOR_HOST named a LAN address.
|
||||
case "$BIND_HOST" in
|
||||
0.0.0.0|::|"") REACH_HOST="$(hostname).local" ;;
|
||||
127.0.0.1|::1|localhost) REACH_HOST="localhost" ;;
|
||||
*) REACH_HOST="$BIND_HOST" ;;
|
||||
esac
|
||||
|
||||
echo ""
|
||||
echo "Editing: $APP_ID"
|
||||
@@ -181,7 +207,7 @@ cd "$APP_DIR"
|
||||
# --foreground: stay in this script's process group so one signal reaches the
|
||||
# whole session. Backgrounded + `wait` so the EXIT trap can run while the child
|
||||
# is still alive; a foreground child would leave bash waiting on it instead.
|
||||
timeout --foreground "$EDITOR_TIMEOUT" "$PIXLET_BIN" serve "$(basename "$STAR_FILE")" \
|
||||
"$TIMEOUT_BIN" --foreground "$EDITOR_TIMEOUT" "$PIXLET_BIN" serve "$(basename "$STAR_FILE")" \
|
||||
--host "$BIND_HOST" \
|
||||
--port "$PORT" \
|
||||
--no-browser \
|
||||
|
||||
Reference in New Issue
Block a user