Skip to content

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

Closed
darion-yaphet wants to merge 2 commits into
refactor/split-init-pr7from
fix/extension-list-available
Closed

fix(extensions): wire up list --available catalog query + harden add --from path traversal#2
darion-yaphet wants to merge 2 commits into
refactor/split-init-pr7from
fix/extension-list-available

Conversation

@darion-yaphet

Copy link
Copy Markdown
Owner

What

Splits the user-visible behavior change out of the PR-7 structural refactor (github#3014) into its own reviewable PR, with test coverage.

Stacked on top of refactor/split-init-pr7 (github#3014) — base will retarget to main once github#3014 merges.

Why

The extension list --available / --all flags have existed since the original extension system (github#1551) and their help text has always advertised "Show available extensions from catalog". But the implementation was a stub that only printed a static install hint and never queried the catalog. The ExtensionCatalog infrastructure was already present — the flags were simply never wired to it. This is a long-standing dead/misleading-flag fix, orthogonal to the structural move, so it does not belong silently inside a "no behavior change" refactor PR.

Changes

  • extension list --available / --all: actually query the catalog and list uninstalled extensions (filtering out installed IDs), instead of the static hint that contradicted the CLI help and docs. --available lists catalog-only; --all lists installed + available. Surfaces a clear error and 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 were verified red against the pre-fix behavior and green after.

…ry the catalog

- extension add --from: sanitize the extension label before building the
  download filename so "../" path separators can no longer escape the
  downloads dir and overwrite arbitrary files
- extension list --available/--all: actually query the catalog and list
  uninstalled extensions (filtering out installed IDs), instead of only
  printing a static install hint that contradicted the CLI help and docs
… path traversal

Add regression coverage for the two behaviors wired up in the preceding fix:

- list --available/--all: queries the catalog, filters installed IDs,
  marks discovery-only entries, reports an empty catalog, and exits 1 on
  catalog failure.
- add --from <url>: a label containing path separators is sanitized so the
  download cannot escape the downloads cache dir.

Both suites were verified red against the pre-fix behavior and green after.
@darion-yaphet

Copy link
Copy Markdown
Owner Author

Re-targeting to upstream github/spec-kit; closing this fork-internal PR.

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