Repository navigation
Conversation
core/dashboard.py imports textual and rich, but pyproject.toml declared no runtime dependencies, so `weft dashboard` (and even `import core.dashboard`) hard-failed with ModuleNotFoundError on a clean install. Declare the two libraries as an optional `dashboard` extra (`pip install weft[dashboard]`), keeping the core engine stdlib-only per CONTRIBUTING. Guard the imports so the module still loads without them, and have the dashboard entrypoint exit with an actionable `pip install weft[dashboard]` message instead of a traceback. Tests: packaging (extra declared, core deps stay empty), frame (module imports with deps absent), functional (import guard fires with helpful message). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
load_template/save_template interpolated the caller-supplied name straight into `<dir>/<name>.json`, so a name like `../../evil` escaped the templates directory on both read and write. Validate names to a single safe stem via a new `_safe_name` helper (rejects path separators, `..`, absolute paths and leading dots). Legitimate names behave exactly as before. The `weft start` / `preview` CLI paths catch the ValueError and exit cleanly instead of surfacing a traceback. Tests: unit (`_safe_name` accept/reject), security (load/save reject traversal + absolute paths, nothing escapes the sandbox), functional (legit names + roundtrip unaffected), integration (CLI start/preview reject a bad name cleanly). Co-Authored-By: Claude Opus 4.8 <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.
What
Two focused bug fixes, each with regression tests.
1. Undeclared dashboard runtime dependencies (packaging)
core/dashboard.pyimportstextualandrich, butpyproject.tomldeclareddependencies = []. On a clean install,weft dashboard— and evenimport core.dashboard— hard-failed withModuleNotFoundError.pip install weft[dashboard]. This keeps the core engine stdlib-only (perCONTRIBUTING.md: "The Python core is stdlib only"), confining the only third-party deps to the one feature that needs them.TYPE_CHECKINGblock so type checkers still see the real symbols).pip install weft[dashboard]) instead of a traceback when the extra is missing.textual>=0.40,rich>=13.0.2. Template-name path traversal (security)
templates.load_template/save_templateinterpolated the caller-suppliednamestraight intod / f"{name}.json"with no sanitization, so a name like../../evilescaped the templates directory on both read and write._safe_namehelper that rejects anything that isn't a single safe stem (path separators,.., absolute paths, leading dots). Legitimate names (generic,feature-workflow, …) behave exactly as before.weft start/previewCLI paths catch the resultingValueErrorand exit cleanly rather than surfacing a traceback.Why
Both are reachable on a normal clean install / with normal CLI input: the dashboard is simply unusable without its deps declared, and the template name is attacker-influenced input that could read or clobber files outside the intended directory.
Tests
Added 23 tests across the project's pytest style, labelled by category:
_safe_nameaccept/reject table.weft start/weft previewreject a bad name with a clean exit (no traceback).dashboardextra is declared withtextual+rich; coredependenciesstays empty;core.dashboardimports even when the deps are absent.Test plan / results
pytest -q— baseline 270 passed before changes; 293 passed after (23 new).tomllibdependency there).pyrighton the changed files:core/templates.pyclean;core/dashboard.pyreduced from 53 errors (my first fallback approach) to the same 4 pre-existingreportMissingImportsthe file already had whentextualisn't installed (fully clean oncetextualis present);core/cli.pyunchanged error count (2 pre-existing, unrelated).🤖 Generated with Claude Code