Harden dev server, fix Pages build, complete runtime deps, remove dead files.#53
Open
ahmaddurrerehman-glitch wants to merge 1 commit into
Conversation
- static.yml: Pages published the raw Vite source tree (./PanTS-Demo) with no build step, so production served unbundled .tsx instead of the compiled app. Add npm ci + npm run build and publish ./PanTS-Demo/dist. - app.py: dev server ran run_simple(hostname='0.0.0.0', use_debugger=True). The Werkzeug debugger console evaluates arbitrary Python, exposing unauthenticated RCE on the LAN. Gate host/debugger behind FLASK_HOST / FLASK_DEBUG, default 127.0.0.1 + debugger off. - app.py: CORS(app) allowed any origin on every route; scope to an ALLOWED_ORIGINS allowlist under /api/* (defaults to the dev origin). - requirements.txt: add scikit-image, trimesh, PyPDF2, SimpleITK, matplotlib, imported by the code but unlisted, so a clean env fails at import. - .env.development: VITE_API_BASE pointed at :8000 (no listener); backend serves :5001. - remove a 3.9 MB committed minified bundle (flask-server/index-Bv-pE24x.js) and four grep-confirmed orphaned files, one with U+2014 em-dashes in its name that breaks some checkouts. CornerstoneNifti2.tsx retained (actively imported).
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.
Ran the stack locally per Prof. Zhou's request and audited current main, after the
codebase-quality-audit merge. Below are the issues that survived that audit, plus a few
that only surface on a clean provision. All fixes verified locally.
Deploy — production served unbuilt source
static.yml uploaded ./PanTS-Demo (the raw Vite tree) as the Pages artifact with no build
step, so the deployed page shipped index.html referencing /src/main.tsx and unbundled TS
modules the browser cannot execute. Added setup-node (npm cache keyed on package-lock),
npm ci, npm run build, and switched the artifact to ./PanTS-Demo/dist.
Security — backend dev server
traceback console evaluates arbitrary Python, so exposing it on all interfaces is an
unauthenticated RCE surface for anyone on the network. Host and debugger are now
env-gated (FLASK_HOST / FLASK_DEBUG), defaulting to loopback with the debugger off.
allowlist scoped to /api/* (defaults to the dev origin).
Fresh-install correctness (surfaced by provisioning from scratch)
SimpleITK, matplotlib, so a clean env raises ModuleNotFoundError at boot. Added.
:5001. Corrected, so the proxy resolves out of the box.
Hygiene
Removed a 3.9 MB committed minified bundle (flask-server/index-Bv-pE24x.js) and four
grep-confirmed unreferenced files, one whose name contains U+2014 em-dashes and breaks
checkout on charset-strict filesystems. CornerstoneNifti2.tsx left intact (imported in
four modules).
Verification
npm run build green (tsc -b + Vite, dist/ emitted). Backend boots on the hardened config
and the frontend round-trips through the Vite proxy: /api/search -> 200 {"items":[],"total":0}.
Follow-ups (not in this PR)
SharedArrayBuffer viewer path; requires making cross-origin assets (Google Fonts)
COEP-compatible or self-hosting them first.
degradation would let the app boot without the dataset.