spec-kit icon indicating copy to clipboard operation
spec-kit copied to clipboard

fix(extensions): wire up list --available catalog query + harden add --from path traversal

Open darion-yaphet opened this issue 5 months ago • 5 comments

What

Wires up the long-advertised extension list --available / --all catalog listing, and hardens extension add --from against path traversal. Split out of the PR-7 structural refactor (#3014) so the behavior change is reviewed on its own, with tests.

Depends on #3014. This branch is built on top of refactor/split-init-pr7 because the handler lives in extensions/_commands.py, which that refactor introduces. Until #3014 merges, its structural-move commit will also show in this diff; it disappears once #3014 lands in main.

Why

The --available / --all flags have existed since the original extension system (#1551), and their help text has always advertised "Show available extensions from catalog." But the implementation was a stub — it printed a static specify extension add <name> hint and never queried the catalog, even though ExtensionCatalog already existed. This is a long-standing dead/misleading-flag fix, not a new feature, and it's orthogonal to the refactor — which is why it's pulled out of #3014.

Changes

  • extension list --available / --all: query the catalog and list uninstalled extensions (filtering out installed IDs). --available lists catalog-only; --all lists installed + available; discovery-only entries are marked; a clear error is surfaced and the command exits non-zero when the catalog is unavailable.
  • extension add --from <url>: sanitize the extension label before building the download filename, so ../-style separators can no longer escape the downloads cache dir (path traversal).

Tests

  • test_extension_list_available.py — catalog query, installed-ID filtering, discovery-only entries, empty catalog, catalog-error exit, --all showing both sections.
  • test_extension_add_path_traversal.py — a traversal label is sanitized so the download stays inside the downloads dir.

Both suites verified red against the pre-fix behavior and green after.

darion-yaphet avatar Jun 18 '26 05:06 darion-yaphet

Please address Copilot feedback

mnriem avatar Jun 23 '26 12:06 mnriem

Please address Copilot feedback

mnriem avatar Jun 23 '26 14:06 mnriem

Please address Copilot feedback

mnriem avatar Jun 23 '26 18:06 mnriem

Please address Copilot feedback

mnriem avatar Jul 06 '26 20:07 mnriem

Please address Copilot feedback

mnriem avatar Jul 09 '26 13:07 mnriem

Please address Copilot feedback. And fix test & lint errors. Maybe pull in upstream/main?

mnriem avatar Aug 07 '26 16:08 mnriem