Harden extension add --from flow and align --dev/--from semantics#2640
Draft
Copilot wants to merge 3 commits into
Draft
Harden extension add --from flow and align --dev/--from semantics#2640Copilot wants to merge 3 commits into
extension add --from flow and align --dev/--from semantics#2640Copilot wants to merge 3 commits into
Conversation
Copilot
AI
changed the title
[WIP] Fix code based on review comments
Harden May 20, 2026
extension add --from flow and align --dev/--from semantics
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the specify extension add --from <url> installation path while aligning CLI option semantics so --dev and --from are treated as mutually exclusive, and refactors ExtensionManager to support ZIP installs from in-memory bytes.
Changes:
- Reject
specify extension add ... --dev --from ...as an invalid flag combination. - Add
ExtensionManager.install_from_zip_bytes(...)and route--fromURL installs through the bytes-based path (no temp ZIP staging file). - Add targeted CLI tests covering the
--dev+--fromrejection and ensuring--frominstalls call the bytes-based install API.
Show a summary per file
| File | Description |
|---|---|
tests/test_extensions.py |
Adds CLI regression tests for --dev/--from exclusivity and for using the in-memory ZIP install path. |
src/specify_cli/extensions.py |
Introduces install_from_zip_bytes(...) and refactors install_from_zip(...) to delegate via bytes. |
src/specify_cli/__init__.py |
Enforces --dev/--from mutual exclusion and switches URL installs to call install_from_zip_bytes(...). |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 2
Comment on lines
+1228
to
+1232
| try: | ||
| with zip_path.open("rb") as zip_file: | ||
| return self.install_from_zip_bytes(zip_file.read(), speckit_version, priority=priority) | ||
| except OSError as e: | ||
| raise ValidationError(f"Failed to read ZIP file {zip_path}: {e}") from e |
Comment on lines
3649
to
+3655
| from specify_cli.authentication.http import open_url as _open_url | ||
|
|
||
| with _open_url(from_url, timeout=60) as response: | ||
| zip_data = response.read() | ||
| zip_path.write_bytes(zip_data) | ||
| zip_bytes = response.read() | ||
|
|
||
| # Install from downloaded ZIP | ||
| manifest = manager.install_from_zip(zip_path, speckit_version, priority=priority) | ||
| manifest = manager.install_from_zip_bytes(zip_bytes, speckit_version, priority=priority) |
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.
This PR addresses all actionable comments in review thread
pullrequestreview-4301684579for PR #2582. The goal is to keep the path-traversal hardening while removing regressions in CLI behavior and URL-install handling.CLI option semantics
specify extension add ... --dev --from ...as mutually exclusive instead of letting--fromside effects run on a code path where--devtakes precedence.URL install path hardening
--frominstalls.Extension manager API refinement
ExtensionManager.install_from_zip_bytes(...).install_from_zip(path)into a thin file-read wrapper delegating to the bytes-based implementation.Focused regression coverage
--dev+--fromrejection.--fromusing in-memory ZIP bytes install path.