Skip to content

Harden dev server, fix Pages build, complete runtime deps, remove dead files.#53

Open
ahmaddurrerehman-glitch wants to merge 1 commit into
BodyMaps:mainfrom
ahmaddurrerehman-glitch:fix/deploy-cors-debugger-and-deps
Open

Harden dev server, fix Pages build, complete runtime deps, remove dead files.#53
ahmaddurrerehman-glitch wants to merge 1 commit into
BodyMaps:mainfrom
ahmaddurrerehman-glitch:fix/deploy-cors-debugger-and-deps

Conversation

@ahmaddurrerehman-glitch

Copy link
Copy Markdown

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

  • run_simple() bound to 0.0.0.0 with use_debugger=True. The Werkzeug interactive
    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.
  • CORS(app) reflected any origin on every route. Restricted to an ALLOWED_ORIGINS
    allowlist scoped to /api/* (defaults to the dev origin).

Fresh-install correctness (surfaced by provisioning from scratch)

  • requirements.txt omits five imported packages, scikit-image, trimesh, PyPDF2,
    SimpleITK, matplotlib, so a clean env raises ModuleNotFoundError at boot. Added.
  • .env.development set VITE_API_BASE to :8000 with nothing listening; backend serves
    :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)

  • Re-enable cross-origin isolation (COOP: same-origin + COEP) to restore the
    SharedArrayBuffer viewer path; requires making cross-origin assets (Google Fonts)
    COEP-compatible or self-hosting them first.
  • api/utils.py hard-fails at import when PANTS/metadata.xlsx is absent; graceful
    degradation would let the app boot without the dataset.

- 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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant