fix(webui): security hardening + launch theme crash; add CI - #249
fix(webui): security hardening + launch theme crash; add CI#249WODE25500 wants to merge 6 commits into
Conversation
- Default bind 127.0.0.1 (was 0.0.0.0); warn to stderr on a non-localhost bind. - Move gradio theme onto gr.Blocks (fixes a launch crash: launch() has no theme param). - Guard empty out_dir in scan_outputs. - Add .github/workflows/ci.yml (test py 3.10/3.11/3.12 + docs mkdocs --strict).
|
Thanks — the localhost default, empty-output guard, and CI setup are useful. One supported-version compatibility issue blocks this as written.
Please either make theme placement runtime-compatible with each supported Gradio API ( |
Address maintainer review on microsoft#249: - Place the gradio theme on Blocks for Gradio <=5 and on launch() for Gradio 6, detected via the installed major, so the WebUI works on any supported version without an ignored-argument warning or a TypeError. - Add a real Gradio build/launch smoke test (skips without the webui extra) asserting the theme is actually applied and no error is raised.
Verified against real Gradio 4.44, 5.50, and 6.25 (built sequentially to avoid conflicting pins): - build_ui() succeeds on all three; theme is placed on Blocks for <6 and on launch() for >=6 (no TypeError / ignored-arg warning). - The launch smoke skips cleanly when a headless/sandboxed environment blocks localhost (not a compatibility bug), and asserts theme application when it launches.
|
Yifan Yang (@Yif-Yang) — thank you for the thorough review and guidance! I've addressed the feedback:
Thanks again for the detailed review! |
|
Thanks — the version-dependent implementation works in local checks, but the requested CI coverage is still not actually exercising that compatibility path. The workflow installs only Please add a reproducible Gradio 4/5/6 WebUI matrix that installs the relevant extra, exercises the production launch-kwargs path, and asserts that |
- Narrow webui extra to gradio>=5,<7 (gradio 4.44 needs huggingface_hub<1, but 6 needs >=1.16; one bound can't satisfy both, so drop the untested major 4 and keep the two the CI matrix validates). - Extract build_launch_kwargs() so tests exercise the production main() path instead of injecting their own theme. - Assert the Soft theme specifically (isinstance/name) rather than is not None (gradio 6 assigns a default theme when none is passed). - Add a CI webui job that installs gradio across majors (5/6) and runs the gradio tests, which the main job's [dev] install silently skipped.
|
Already addressed the review feedback and updated this branch (#249):
|
|
done, please re-review. One note on the dependency choice: I took the "narrow the range" option - webui is now gradio>=5,<7 - because gradio 4/5 need huggingface_hub<1 while gradio 6 needs >=1.16; a single bound cannot satisfy both, so I dropped the untested major 4. |
|
Thanks — the production theme path and Gradio 5/6 CI coverage now address the previous review. One supported-version issue remains: |
- The declared floor gradio>=5.0.0 advertised gradio 5.0-5.49, which either still import HfFolder (removed in modern huggingface_hub) or don't apply the Blocks theme the same way, so a clean install can fail at import. - Raise the webui extra to gradio>=5.50.0,<7 (verified: Blocks theme is Soft, the webui tests pass) and test that actual floor in the CI matrix (5.50 + 6.26).
|
Thanks for the re-review. Addressed the remaining item: the declared floor is now gradio>=5.50.0,<7 (earlier 5.0-5.49 either import HfFolder or don't apply the Blocks theme the same way), and the CI webui matrix tests that actual floor (5.50 + 6.26). Commit d549c86. |
Security/robustness hardening for the Gradio WebUI, plus a first CI workflow.
Note: the pre-existing WebUI scan_outputs path traversal (arbitrary typed path) is intentionally left as-is; the localhost default is the mitigation.