fix: offline auto-refresh, graceful shutdown, healthcheck port, page/auth hardening#2
Merged
bin101 merged 1 commit intoJul 9, 2026
Conversation
…k port, and public-page/auth hardening Full-app review turned up five issues, all fixed here: - The offline placeholder promised auto-updates but had no refresh mechanism, so a viewer opening the link before a session starts never saw it appear. - SIGTERM didn't actually stop waitress (serve() installs no signal handling of its own), so containers only stopped via Docker's SIGKILL, skipping the monitor's clean IMAP logout. Now uses create_server()+close(), with the expected shutdown-induced OSError from waitress's interrupted select loop handled explicitly rather than raising. - The Dockerfile HEALTHCHECK hard-coded port 8080 while WEB_PORT is configurable, silently breaking health checks for anyone changing it. - The public page interpolated the link into HTML attributes and inline JS without escaping; only the email-extraction regex made this safe in practice, and admin-set links bypassed it entirely. Now escaped per context, and /admin/link rejects anything not shaped like a LiveTrack URL. - Basic-Auth credential comparison used `==` instead of a constant-time compare. Verified end-to-end: docker build (embedded test stage), and a real docker run + docker stop timing test confirming shutdown now exits 0 in <1s instead of hitting the SIGKILL grace period, plus a WEB_PORT override actually reporting healthy. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Full-app review turned up five issues, all fixed here (see full findings in commit message / review):
<meta refresh>so a viewer who opens the link before a session starts actually sees it appear.waitress.serve()installs no signal handling, so the old handler only stopped the monitor and left the process running until Docker's SIGKILL. Switched tocreate_server()+.close(), with the expected shutdown-inducedOSErrorhandled explicitly.WEB_PORTis configurable — now readsWEB_PORTat check time.</>/&further escaped for the<script>context), and/admin/linknow rejects anything not shaped like alivetrack.garmin.comsession URL (400).==instead of a constant-time compare — switched tosecrets.compare_digest.Test plan
pytest -q— 49 passed (44 existing + 5 new, covering offline refresh, HTML/JS escaping against a crafted malicious link, and admin link validation)docker build— embedded test stage passesdocker run+docker stop -t 30: shutdown now exits0in ~0.15s (previously would traceback/hang), with the monitor's shutdown log line presentWEB_PORT=9091override now reportshealthyviadocker inspect(previously would stayunhealthyforever)/with no link served the offline page with the new refresh meta tag🤖 Generated with Claude Code