specify-cli 1.3.2__py3-none-any.whl → 1.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- specify_cli/_file_handles.py +202 -0
- specify_cli/_version.py +8 -1
- specify_cli/_windows_abi.py +41 -0
- specify_cli/authentication/http.py +50 -6
- specify_cli/bundles/adapters.py +6 -8
- specify_cli/bundles/catalog_config.py +4 -6
- specify_cli/bundles/component_catalog.py +2 -2
- specify_cli/bundles/primitives.py +36 -2
- specify_cli/catalogs.py +3 -5
- specify_cli/core_pack/bundles/catalog.community.json +24 -1
- specify_cli/core_pack/scripts/bash/create-new-feature.sh +2 -1
- specify_cli/extensions/command_info.py +2 -2
- specify_cli/extensions/command_search.py +2 -2
- specify_cli/file_helper.py +127 -11
- specify_cli/integrations/__init__.py +6 -1
- specify_cli/integrations/_file_changes.py +112 -1
- specify_cli/integrations/base.py +297 -0
- specify_cli/integrations/catalog/command_add.py +1 -4
- specify_cli/integrations/claude/__init__.py +66 -1
- specify_cli/integrations/codex/__init__.py +41 -1
- specify_cli/integrations/copilot/__init__.py +83 -1
- specify_cli/integrations/omp/__init__.py +119 -2
- specify_cli/presets/_catalog.py +12 -10
- specify_cli/presets/_manager_skills.py +14 -13
- specify_cli/presets/catalog/command_remove.py +2 -1
- specify_cli/presets/command_info.py +1 -1
- specify_cli/workflows/__init__.py +44 -27
- specify_cli/workflows/_archive_install.py +233 -0
- specify_cli/workflows/_catalog_cache.py +1 -58
- specify_cli/workflows/_commands.py +30 -1
- specify_cli/workflows/_execution.py +2 -0
- specify_cli/workflows/_mcp.py +36 -2
- specify_cli/workflows/_package_install.py +887 -0
- specify_cli/workflows/_package_registry.py +199 -0
- specify_cli/workflows/base.py +6 -0
- specify_cli/workflows/catalog/_domain.py +19 -20
- specify_cli/workflows/command_add.py +1 -3
- specify_cli/workflows/command_resume.py +4 -3
- specify_cli/workflows/command_run.py +2 -3
- specify_cli/workflows/command_update.py +1 -2
- specify_cli/workflows/engine.py +18 -0
- specify_cli/workflows/expressions/__init__.py +15 -1
- specify_cli/workflows/expressions/engine.py +24 -30
- specify_cli/workflows/expressions/filters.py +116 -37
- specify_cli/workflows/expressions/operators.py +25 -6
- specify_cli/workflows/function/__init__.py +38 -0
- specify_cli/workflows/function/_domain.py +151 -0
- specify_cli/workflows/function/command_add.py +60 -0
- specify_cli/workflows/function/command_list.py +67 -0
- specify_cli/workflows/function/command_remove.py +38 -0
- specify_cli/workflows/function/installer.py +232 -0
- specify_cli/workflows/function/loader.py +144 -0
- specify_cli/workflows/overlay/schema.py +1 -1
- specify_cli/workflows/step/_dispatch_settings.py +129 -0
- specify_cli/workflows/step/catalog/_domain.py +31 -180
- specify_cli/workflows/step/command/__init__.py +41 -1
- specify_cli/workflows/step/command_add.py +14 -200
- specify_cli/workflows/step/command_remove.py +41 -90
- specify_cli/workflows/step/installer.py +122 -521
- specify_cli/workflows/step/prompt/__init__.py +55 -11
- specify_cli/workflows/step/shell/__init__.py +6 -2
- {specify_cli-1.3.2.dist-info → specify_cli-1.4.0.dist-info}/METADATA +2 -1
- {specify_cli-1.3.2.dist-info → specify_cli-1.4.0.dist-info}/RECORD +66 -53
- {specify_cli-1.3.2.dist-info → specify_cli-1.4.0.dist-info}/WHEEL +0 -0
- {specify_cli-1.3.2.dist-info → specify_cli-1.4.0.dist-info}/entry_points.txt +0 -0
- {specify_cli-1.3.2.dist-info → specify_cli-1.4.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"""Private platform handles for confined filesystem operations."""
|
|
2
|
+
|
|
3
|
+
from collections.abc import Iterator
|
|
4
|
+
from contextlib import contextmanager
|
|
5
|
+
import errno
|
|
6
|
+
import os
|
|
7
|
+
import secrets
|
|
8
|
+
import stat
|
|
9
|
+
import tempfile
|
|
10
|
+
from pathlib import Path, PureWindowsPath
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _open_windows_child(parent: int, name: str, *, directory: bool, access: int, sharing: int) -> int:
|
|
14
|
+
"""Open one component relative to an already validated directory handle."""
|
|
15
|
+
if PureWindowsPath(name).parts != (name,) or PureWindowsPath(name).anchor or name == ".." or "\0" in name:
|
|
16
|
+
raise ValueError(f"Expected a single relative Windows path component: {name!r}")
|
|
17
|
+
encoded_length = len(name.encode("utf-16-le", errors="surrogatepass"))
|
|
18
|
+
if encoded_length > 65532:
|
|
19
|
+
raise OSError(errno.ENAMETOOLONG, "Windows path component is too long", name)
|
|
20
|
+
|
|
21
|
+
import ctypes
|
|
22
|
+
from ctypes import wintypes
|
|
23
|
+
from . import _windows_abi as abi
|
|
24
|
+
|
|
25
|
+
native = ctypes.WinDLL("ntdll")
|
|
26
|
+
create = native.NtCreateFile
|
|
27
|
+
create.argtypes = [
|
|
28
|
+
ctypes.POINTER(wintypes.HANDLE), ctypes.c_uint32,
|
|
29
|
+
abi._ObjectAttributesPointer, abi._IoStatusBlockPointer,
|
|
30
|
+
wintypes.LPVOID, ctypes.c_uint32, ctypes.c_uint32, ctypes.c_uint32,
|
|
31
|
+
ctypes.c_uint32, wintypes.LPVOID, ctypes.c_uint32,
|
|
32
|
+
]
|
|
33
|
+
create.restype = ctypes.c_int32
|
|
34
|
+
dos_error = native.RtlNtStatusToDosError
|
|
35
|
+
dos_error.argtypes = [ctypes.c_int32]
|
|
36
|
+
dos_error.restype = ctypes.c_uint32
|
|
37
|
+
buffer = ctypes.create_unicode_buffer(name)
|
|
38
|
+
unicode_name = abi._UnicodeString(
|
|
39
|
+
encoded_length, encoded_length + 2, ctypes.cast(buffer, wintypes.LPWSTR)
|
|
40
|
+
)
|
|
41
|
+
# OBJ_DONT_REPARSE and FILE_OPEN_REPARSE_POINT keep resolution on this handle.
|
|
42
|
+
attributes = abi._ObjectAttributes(
|
|
43
|
+
ctypes.sizeof(abi._ObjectAttributes), parent, ctypes.pointer(unicode_name),
|
|
44
|
+
0x40 | 0x1000, None, None,
|
|
45
|
+
)
|
|
46
|
+
handle = wintypes.HANDLE()
|
|
47
|
+
status = abi._IoStatusBlock()
|
|
48
|
+
options = 0x00200000 | (0x1 if directory else 0x40 | 0x20)
|
|
49
|
+
result = create(
|
|
50
|
+
ctypes.byref(handle), access | (0 if directory else 0x100000),
|
|
51
|
+
ctypes.byref(attributes), ctypes.byref(status), None, 0,
|
|
52
|
+
sharing, 1, options, None, 0,
|
|
53
|
+
)
|
|
54
|
+
if result < 0:
|
|
55
|
+
raise ctypes.WinError(dos_error(result))
|
|
56
|
+
if not handle.value:
|
|
57
|
+
raise OSError(errno.EBADF, "Native child open returned no handle", name)
|
|
58
|
+
return handle.value
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _windows_api():
|
|
62
|
+
import ctypes
|
|
63
|
+
from ctypes import wintypes
|
|
64
|
+
|
|
65
|
+
kernel = ctypes.WinDLL("kernel32", use_last_error=True)
|
|
66
|
+
kernel.CreateFileW.argtypes = [
|
|
67
|
+
wintypes.LPCWSTR,
|
|
68
|
+
wintypes.DWORD,
|
|
69
|
+
wintypes.DWORD,
|
|
70
|
+
wintypes.LPVOID,
|
|
71
|
+
wintypes.DWORD,
|
|
72
|
+
wintypes.DWORD,
|
|
73
|
+
wintypes.HANDLE,
|
|
74
|
+
]
|
|
75
|
+
kernel.CreateFileW.restype = wintypes.HANDLE
|
|
76
|
+
kernel.GetFileInformationByHandleEx.argtypes = [
|
|
77
|
+
wintypes.HANDLE, ctypes.c_int, wintypes.LPVOID, wintypes.DWORD
|
|
78
|
+
]
|
|
79
|
+
kernel.GetFileInformationByHandleEx.restype = wintypes.BOOL
|
|
80
|
+
kernel.CloseHandle.argtypes = [wintypes.HANDLE]
|
|
81
|
+
kernel.CloseHandle.restype = wintypes.BOOL
|
|
82
|
+
return kernel
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _open_windows_handle(
|
|
86
|
+
path: Path, *, directory: bool, overwrite: bool = False,
|
|
87
|
+
create_attributes: int | None = None, parent: int | None = None, traverse: bool = False,
|
|
88
|
+
) -> int:
|
|
89
|
+
if parent is not None and (overwrite or create_attributes is not None):
|
|
90
|
+
raise ValueError("Relative Windows handle opens do not support creation or overwrite")
|
|
91
|
+
import ctypes
|
|
92
|
+
from ctypes import wintypes
|
|
93
|
+
|
|
94
|
+
class AttributeTagInfo(ctypes.Structure):
|
|
95
|
+
_fields_ = [("attributes", wintypes.DWORD), ("tag", wintypes.DWORD)]
|
|
96
|
+
|
|
97
|
+
kernel = _windows_api()
|
|
98
|
+
access = (0x80 | (0x20 if traverse else 0x1)) if directory else 0x80000000
|
|
99
|
+
if overwrite:
|
|
100
|
+
access = 0x40000000 | 0x80
|
|
101
|
+
if parent is None:
|
|
102
|
+
# FILE_TRAVERSE participates in sharing checks without requiring enumeration.
|
|
103
|
+
handle = kernel.CreateFileW(
|
|
104
|
+
str(path), access, 0x3, None,
|
|
105
|
+
3 if create_attributes is None else 1, # OPEN_EXISTING or CREATE_NEW.
|
|
106
|
+
0x00200000 | 0x02000000 | (create_attributes or 0), None,
|
|
107
|
+
)
|
|
108
|
+
if handle == wintypes.HANDLE(-1).value:
|
|
109
|
+
raise ctypes.WinError(ctypes.get_last_error())
|
|
110
|
+
else:
|
|
111
|
+
handle = _open_windows_child(parent, str(path), directory=directory, access=access, sharing=0x3)
|
|
112
|
+
try:
|
|
113
|
+
attributes = AttributeTagInfo()
|
|
114
|
+
if not kernel.GetFileInformationByHandleEx(
|
|
115
|
+
handle, 9, ctypes.byref(attributes), ctypes.sizeof(attributes)
|
|
116
|
+
):
|
|
117
|
+
raise ctypes.WinError(ctypes.get_last_error())
|
|
118
|
+
if attributes.attributes & 0x400:
|
|
119
|
+
raise OSError(errno.ELOOP, "Refusing a reparse-point filesystem path", str(path))
|
|
120
|
+
if bool(attributes.attributes & 0x10) != directory:
|
|
121
|
+
raise OSError(errno.EINVAL, "Unexpected filesystem object type", str(path))
|
|
122
|
+
return handle
|
|
123
|
+
except BaseException:
|
|
124
|
+
kernel.CloseHandle(handle)
|
|
125
|
+
raise
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
@contextmanager
|
|
129
|
+
def _windows_handle(
|
|
130
|
+
path: Path, *, directory: bool, parent: int | None = None, traverse: bool = False,
|
|
131
|
+
) -> Iterator[int]:
|
|
132
|
+
"""Pin a non-reparse path by withholding Windows delete sharing."""
|
|
133
|
+
if parent is None and not traverse:
|
|
134
|
+
handle = _open_windows_handle(path, directory=directory)
|
|
135
|
+
else:
|
|
136
|
+
handle = _open_windows_handle(path, directory=directory, parent=parent, traverse=traverse)
|
|
137
|
+
try:
|
|
138
|
+
yield handle
|
|
139
|
+
finally:
|
|
140
|
+
_windows_api().CloseHandle(handle)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
@contextmanager
|
|
144
|
+
def windows_read_fd(handle: int) -> Iterator[int]:
|
|
145
|
+
"""Read the validated object through an independently owned duplicate."""
|
|
146
|
+
import _winapi
|
|
147
|
+
import msvcrt
|
|
148
|
+
|
|
149
|
+
process = _winapi.GetCurrentProcess()
|
|
150
|
+
duplicate = _winapi.DuplicateHandle(
|
|
151
|
+
process, handle, process, 0, False, _winapi.DUPLICATE_SAME_ACCESS
|
|
152
|
+
)
|
|
153
|
+
try:
|
|
154
|
+
fd = msvcrt.open_osfhandle(duplicate, os.O_RDONLY | os.O_BINARY)
|
|
155
|
+
except BaseException:
|
|
156
|
+
_winapi.CloseHandle(duplicate)
|
|
157
|
+
raise
|
|
158
|
+
try:
|
|
159
|
+
yield fd
|
|
160
|
+
finally:
|
|
161
|
+
os.close(fd)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
@contextmanager
|
|
165
|
+
def _windows_overwrite_fd(path: Path) -> Iterator[int]:
|
|
166
|
+
"""Open/create without following a new leaf or changing the CRT mask."""
|
|
167
|
+
try:
|
|
168
|
+
handle = _open_windows_handle(path, directory=False, overwrite=True)
|
|
169
|
+
except FileNotFoundError:
|
|
170
|
+
attributes = _windows_creation_attributes()
|
|
171
|
+
handle = _open_windows_handle(
|
|
172
|
+
path, directory=False, overwrite=True, create_attributes=attributes
|
|
173
|
+
)
|
|
174
|
+
try:
|
|
175
|
+
import msvcrt
|
|
176
|
+
|
|
177
|
+
fd = msvcrt.open_osfhandle(handle, os.O_WRONLY | os.O_BINARY)
|
|
178
|
+
except BaseException:
|
|
179
|
+
_windows_api().CloseHandle(handle)
|
|
180
|
+
raise
|
|
181
|
+
try:
|
|
182
|
+
yield fd
|
|
183
|
+
finally:
|
|
184
|
+
os.close(fd)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def _windows_creation_attributes() -> int:
|
|
188
|
+
"""Capture CRT-masked permissions in independent runtime-owned storage."""
|
|
189
|
+
with tempfile.TemporaryDirectory(prefix="specify-mode-") as directory:
|
|
190
|
+
parent = Path(directory)
|
|
191
|
+
with _windows_handle(parent, directory=True):
|
|
192
|
+
probe = parent / f".specify-mode-{secrets.token_hex(16)}.tmp"
|
|
193
|
+
fd = os.open(probe, os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_BINARY, 0o666)
|
|
194
|
+
try:
|
|
195
|
+
readonly = not os.fstat(fd).st_mode & stat.S_IWRITE
|
|
196
|
+
finally:
|
|
197
|
+
try:
|
|
198
|
+
os.chmod(probe, 0o600)
|
|
199
|
+
finally:
|
|
200
|
+
os.close(fd)
|
|
201
|
+
os.unlink(probe)
|
|
202
|
+
return 0x1 if readonly else 0
|
specify_cli/_version.py
CHANGED
|
@@ -168,7 +168,14 @@ def _stable_release_tag_for_version(version_text: str) -> str | None:
|
|
|
168
168
|
parsed = _parse_version_text(version_text)
|
|
169
169
|
if parsed is None:
|
|
170
170
|
return None
|
|
171
|
-
|
|
171
|
+
# `post` and `dev` are ints, so `.post0`/`.dev0` are 0 and falsy: compare
|
|
172
|
+
# against None instead of relying on truthiness.
|
|
173
|
+
if (
|
|
174
|
+
parsed.pre is not None
|
|
175
|
+
or parsed.post is not None
|
|
176
|
+
or parsed.dev is not None
|
|
177
|
+
or parsed.local is not None
|
|
178
|
+
):
|
|
172
179
|
return None
|
|
173
180
|
release = parsed.release
|
|
174
181
|
if len(release) != 3:
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""Windows ABI metadata, initialized once through lazy module imports."""
|
|
2
|
+
|
|
3
|
+
import ctypes
|
|
4
|
+
from ctypes import wintypes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# Older Python versions retain POINTER types globally; reuse these ABI classes.
|
|
8
|
+
class _UnicodeString(ctypes.Structure):
|
|
9
|
+
_fields_ = [
|
|
10
|
+
("Length", ctypes.c_uint16),
|
|
11
|
+
("MaximumLength", ctypes.c_uint16),
|
|
12
|
+
("Buffer", wintypes.LPWSTR),
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
_UnicodeStringPointer = ctypes.POINTER(_UnicodeString)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class _ObjectAttributes(ctypes.Structure):
|
|
20
|
+
_fields_ = [
|
|
21
|
+
("Length", ctypes.c_uint32),
|
|
22
|
+
("RootDirectory", wintypes.HANDLE),
|
|
23
|
+
("ObjectName", _UnicodeStringPointer),
|
|
24
|
+
("Attributes", ctypes.c_uint32),
|
|
25
|
+
("SecurityDescriptor", wintypes.LPVOID),
|
|
26
|
+
("SecurityQualityOfService", wintypes.LPVOID),
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
_ObjectAttributesPointer = ctypes.POINTER(_ObjectAttributes)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class _StatusValue(ctypes.Union):
|
|
34
|
+
_fields_ = [("Status", ctypes.c_int32), ("Pointer", wintypes.LPVOID)]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class _IoStatusBlock(ctypes.Structure):
|
|
38
|
+
_fields_ = [("Value", _StatusValue), ("Information", ctypes.c_size_t)]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
_IoStatusBlockPointer = ctypes.POINTER(_IoStatusBlock)
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
No credentials are sent unless the user has created ``auth.json``.
|
|
4
4
|
For each outbound URL the helper matches the hostname against
|
|
5
5
|
configured entries, resolves the token via the appropriate provider
|
|
6
|
-
class, and attaches auth headers.
|
|
6
|
+
class, and attaches auth headers. Initial URLs must use HTTPS, except
|
|
7
|
+
for HTTP to unambiguous loopback hosts. Redirect safety is enforced:
|
|
7
8
|
the ``Authorization`` header is stripped when a redirect leaves the
|
|
8
9
|
entry's declared hosts. On 401/403 the next matching entry is tried,
|
|
9
10
|
then unauthenticated.
|
|
@@ -16,7 +17,7 @@ import urllib.request
|
|
|
16
17
|
from typing import Callable
|
|
17
18
|
from urllib.parse import urlparse
|
|
18
19
|
|
|
19
|
-
from .._download_security import is_safe_download_redirect
|
|
20
|
+
from .._download_security import is_https_or_localhost_http, is_safe_download_redirect
|
|
20
21
|
from . import get_provider
|
|
21
22
|
from .config import (
|
|
22
23
|
AuthConfigEntry,
|
|
@@ -65,10 +66,22 @@ def _hostname_in_hosts(hostname: str, hosts: tuple[str, ...]) -> bool:
|
|
|
65
66
|
RedirectValidator = Callable[[str, str], None]
|
|
66
67
|
|
|
67
68
|
|
|
68
|
-
class
|
|
69
|
+
class URLPolicyError(urllib.error.URLError):
|
|
70
|
+
"""A URL rejected because it violates the client's transport policy."""
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class RedirectPolicyError(URLPolicyError):
|
|
69
74
|
"""A redirect rejected because it violates the client's security policy."""
|
|
70
75
|
|
|
71
76
|
|
|
77
|
+
def _validate_initial_url(url: str) -> None:
|
|
78
|
+
if not is_https_or_localhost_http(url):
|
|
79
|
+
raise URLPolicyError(
|
|
80
|
+
"unsafe request URL: target must use HTTPS with a hostname, "
|
|
81
|
+
"or HTTP to loopback (for example localhost, 127.0.0.1, ::1)"
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
72
85
|
def _validate_strict_redirect(old_url: str, new_url: str) -> None:
|
|
73
86
|
if not is_safe_download_redirect(old_url, new_url):
|
|
74
87
|
raise RedirectPolicyError(
|
|
@@ -81,10 +94,11 @@ def _validate_strict_redirect(old_url: str, new_url: str) -> None:
|
|
|
81
94
|
class _StripAuthOnRedirect(urllib.request.HTTPRedirectHandler):
|
|
82
95
|
"""Redirect handler that guards every redirect it is installed for.
|
|
83
96
|
|
|
84
|
-
1.
|
|
85
|
-
2.
|
|
97
|
+
1. Reject malformed absolute targets before urllib normalizes their headers.
|
|
98
|
+
2. Run any caller-provided redirect validator.
|
|
99
|
+
3. Reject redirects that are not HTTPS with a hostname. HTTP loopback is
|
|
86
100
|
allowed only when the previous hop is also loopback.
|
|
87
|
-
|
|
101
|
+
4. Drop ``Authorization`` when a redirect leaves trusted hosts or downgrades.
|
|
88
102
|
"""
|
|
89
103
|
|
|
90
104
|
def __init__(
|
|
@@ -96,6 +110,31 @@ class _StripAuthOnRedirect(urllib.request.HTTPRedirectHandler):
|
|
|
96
110
|
self._hosts = hosts
|
|
97
111
|
self._redirect_validator = redirect_validator
|
|
98
112
|
|
|
113
|
+
def http_error_302(self, req, fp, code, msg, headers):
|
|
114
|
+
if "location" in headers:
|
|
115
|
+
target = headers["location"]
|
|
116
|
+
elif "uri" in headers:
|
|
117
|
+
target = headers["uri"]
|
|
118
|
+
else:
|
|
119
|
+
return super().http_error_302(req, fp, code, msg, headers)
|
|
120
|
+
|
|
121
|
+
try:
|
|
122
|
+
parsed = urlparse(target)
|
|
123
|
+
hostname = parsed.hostname
|
|
124
|
+
parsed.port
|
|
125
|
+
except ValueError as exc:
|
|
126
|
+
raise RedirectPolicyError(f"malformed redirect URL: {exc}") from exc
|
|
127
|
+
|
|
128
|
+
# urllib can otherwise normalize a hostless absolute URL onto the
|
|
129
|
+
# current host before redirect_request sees the original target.
|
|
130
|
+
if parsed.scheme and (parsed.scheme not in ("http", "https") or not hostname):
|
|
131
|
+
raise RedirectPolicyError(
|
|
132
|
+
"unsafe redirect URL: an absolute target must use HTTP(S) with a hostname"
|
|
133
|
+
)
|
|
134
|
+
return super().http_error_302(req, fp, code, msg, headers)
|
|
135
|
+
|
|
136
|
+
http_error_301 = http_error_303 = http_error_307 = http_error_308 = http_error_302
|
|
137
|
+
|
|
99
138
|
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
|
100
139
|
try:
|
|
101
140
|
new_parsed = urlparse(newurl)
|
|
@@ -135,7 +174,9 @@ def build_request(url: str, extra_headers: dict[str, str] | None = None) -> urll
|
|
|
135
174
|
Returns a plain request when no entry matches or the file doesn't exist.
|
|
136
175
|
A ``github-cli`` acquisition failure raises immediately, without trying
|
|
137
176
|
later matching entries or returning an unauthenticated request.
|
|
177
|
+
Rejects URLs that are not HTTPS or loopback HTTP before resolving tokens.
|
|
138
178
|
"""
|
|
179
|
+
_validate_initial_url(url)
|
|
139
180
|
headers: dict[str, str] = {}
|
|
140
181
|
if extra_headers:
|
|
141
182
|
# Strip Authorization from extra_headers to prevent bypass
|
|
@@ -193,7 +234,10 @@ def open_url(
|
|
|
193
234
|
Redirect scheme safety: every attempt goes through
|
|
194
235
|
``_StripAuthOnRedirect``, which rejects redirects to non-HTTPS URLs except
|
|
195
236
|
HTTP between loopback URLs, and rejects remote-to-local redirects.
|
|
237
|
+
Initial URLs must also use HTTPS or loopback HTTP; unsafe URLs are
|
|
238
|
+
rejected before resolving tokens or making any request.
|
|
196
239
|
"""
|
|
240
|
+
_validate_initial_url(url)
|
|
197
241
|
entries = find_entries_for_url(url, _load_config())
|
|
198
242
|
|
|
199
243
|
def _make_req(auth_headers: dict[str, str]) -> urllib.request.Request:
|
specify_cli/bundles/adapters.py
CHANGED
|
@@ -92,7 +92,7 @@ def _file_url_to_path(parsed: ParseResult) -> Path:
|
|
|
92
92
|
|
|
93
93
|
|
|
94
94
|
def _validate_remote_url(source_id: str, url: str) -> None:
|
|
95
|
-
"""Restrict remote catalogs to HTTPS
|
|
95
|
+
"""Restrict remote catalogs to HTTPS with a host, including localhost.
|
|
96
96
|
|
|
97
97
|
Mirrors ``specify_cli.catalogs`` URL validation to avoid MITM/downgrade
|
|
98
98
|
issues before any network call.
|
|
@@ -110,11 +110,9 @@ def _validate_remote_url(source_id: str, url: str) -> None:
|
|
|
110
110
|
raise BundlerError(
|
|
111
111
|
f"Catalog '{source_id}' URL is malformed: {url}"
|
|
112
112
|
) from None
|
|
113
|
-
|
|
114
|
-
if parsed.scheme != "https" and not (parsed.scheme == "http" and is_localhost):
|
|
113
|
+
if parsed.scheme != "https":
|
|
115
114
|
raise BundlerError(
|
|
116
|
-
f"Catalog '{source_id}' URL must use HTTPS (got {parsed.scheme}://).
|
|
117
|
-
"HTTP is only allowed for localhost."
|
|
115
|
+
f"Catalog '{source_id}' URL must use HTTPS (got {parsed.scheme}://)."
|
|
118
116
|
)
|
|
119
117
|
# Check hostname, not netloc: netloc is truthy for host-less URLs like
|
|
120
118
|
# "https://:8080" or "https://user@...", so requiring netloc would let
|
|
@@ -229,7 +227,7 @@ def _http_get_json(source_id: str, url: str) -> dict:
|
|
|
229
227
|
rather than only on the initial URL.
|
|
230
228
|
"""
|
|
231
229
|
from ..authentication.github import GitHubCliAuthError
|
|
232
|
-
from ..authentication.http import
|
|
230
|
+
from ..authentication.http import URLPolicyError, open_url
|
|
233
231
|
|
|
234
232
|
def _validate_redirect(_old_url: str, new_url: str) -> None:
|
|
235
233
|
_validate_remote_url(source_id, new_url)
|
|
@@ -259,8 +257,8 @@ def _http_get_json(source_id: str, url: str) -> dict:
|
|
|
259
257
|
raise BundlerError(
|
|
260
258
|
f"Failed to fetch catalog from {url}: {exc}"
|
|
261
259
|
) from exc
|
|
262
|
-
except (GitHubCliAuthError,
|
|
263
|
-
# Authentication and
|
|
260
|
+
except (GitHubCliAuthError, URLPolicyError) as exc:
|
|
261
|
+
# Authentication and URL-policy failures are definitive, not
|
|
264
262
|
# transient catalog unavailability.
|
|
265
263
|
raise BundlerError(
|
|
266
264
|
f"Failed to fetch catalog from {url}: {exc}"
|
|
@@ -167,19 +167,17 @@ def add_source(
|
|
|
167
167
|
if "://" in url and parsed.scheme.lower() not in _REMOTE_SCHEMES:
|
|
168
168
|
raise BundlerError(
|
|
169
169
|
f"Unsupported catalog url scheme '{parsed.scheme}://' in '{url}'. "
|
|
170
|
-
"Use
|
|
170
|
+
"Use https://, file://, builtin://, or a local path."
|
|
171
171
|
)
|
|
172
172
|
if parsed.scheme.lower() in {"http", "https"}:
|
|
173
173
|
# Mirror specify_cli.catalogs._validate_catalog_url (#3209/#3210):
|
|
174
|
-
# HTTPS only
|
|
174
|
+
# HTTPS only, including localhost, and check hostname, not
|
|
175
175
|
# netloc — netloc is truthy for host-less URLs like "https://:8080"
|
|
176
176
|
# or "https://user@". Validating here keeps junk out of
|
|
177
177
|
# bundle-catalogs.yml instead of failing later at fetch time.
|
|
178
|
-
|
|
179
|
-
if parsed.scheme.lower() != "https" and not is_localhost:
|
|
178
|
+
if parsed.scheme.lower() != "https":
|
|
180
179
|
raise BundlerError(
|
|
181
|
-
f"Catalog url must use HTTPS (got {parsed.scheme}://).
|
|
182
|
-
"HTTP is only allowed for localhost."
|
|
180
|
+
f"Catalog url must use HTTPS (got {parsed.scheme}://)."
|
|
183
181
|
)
|
|
184
182
|
if not hostname:
|
|
185
183
|
raise BundlerError(f"Catalog url must be a valid URL with a host: {url}")
|
|
@@ -7,7 +7,7 @@ from http.client import HTTPException
|
|
|
7
7
|
from urllib.error import HTTPError, URLError
|
|
8
8
|
|
|
9
9
|
from ..authentication.github import GitHubCliAuthError
|
|
10
|
-
from ..authentication.http import
|
|
10
|
+
from ..authentication.http import URLPolicyError
|
|
11
11
|
from . import BundlerError
|
|
12
12
|
from .manifest import ComponentRef
|
|
13
13
|
|
|
@@ -20,7 +20,7 @@ def _is_unavailable(exc: BaseException) -> bool:
|
|
|
20
20
|
seen: set[int] = set()
|
|
21
21
|
while exc is not None and id(exc) not in seen:
|
|
22
22
|
seen.add(id(exc))
|
|
23
|
-
if isinstance(exc, (GitHubCliAuthError,
|
|
23
|
+
if isinstance(exc, (GitHubCliAuthError, URLPolicyError)):
|
|
24
24
|
return False
|
|
25
25
|
if isinstance(exc, HTTPError):
|
|
26
26
|
return exc.code in (408, 429) or 500 <= exc.code <= 599
|
|
@@ -328,9 +328,26 @@ class _PresetKindManager:
|
|
|
328
328
|
) -> BundledPatchWarning | None:
|
|
329
329
|
from .. import get_speckit_version
|
|
330
330
|
from .._assets import _locate_bundled_preset
|
|
331
|
+
from ..extensions import normalize_priority
|
|
331
332
|
|
|
332
333
|
speckit_version = get_speckit_version()
|
|
333
|
-
|
|
334
|
+
|
|
335
|
+
# Preserve existing priority from registry if available
|
|
336
|
+
existing_priority = None
|
|
337
|
+
if component.kind == "presets":
|
|
338
|
+
existing = self._manager.registry.get(component.id)
|
|
339
|
+
if existing and isinstance(existing, dict):
|
|
340
|
+
existing_priority = existing.get("priority")
|
|
341
|
+
|
|
342
|
+
declared_priority = (
|
|
343
|
+
DEFAULT_PRIORITY if component.priority is None else component.priority
|
|
344
|
+
)
|
|
345
|
+
if existing_priority is not None:
|
|
346
|
+
# Registry data may be corrupted (strings, zero, booleans); fall
|
|
347
|
+
# back to the declared/default priority instead of failing later.
|
|
348
|
+
priority = normalize_priority(existing_priority, default=declared_priority)
|
|
349
|
+
else:
|
|
350
|
+
priority = declared_priority
|
|
334
351
|
|
|
335
352
|
bundled = _locate_bundled_preset(component.id)
|
|
336
353
|
if bundled is not None and component.source is None:
|
|
@@ -419,9 +436,26 @@ class _ExtensionKindManager:
|
|
|
419
436
|
) -> BundledPatchWarning | None:
|
|
420
437
|
from .. import get_speckit_version
|
|
421
438
|
from .._assets import _locate_bundled_extension
|
|
439
|
+
from ..extensions import normalize_priority
|
|
422
440
|
|
|
423
441
|
speckit_version = get_speckit_version()
|
|
424
|
-
|
|
442
|
+
|
|
443
|
+
# Preserve existing priority from registry if available
|
|
444
|
+
existing_priority = None
|
|
445
|
+
if component.kind == "extensions":
|
|
446
|
+
existing = self._manager.registry.get(component.id)
|
|
447
|
+
if existing and isinstance(existing, dict):
|
|
448
|
+
existing_priority = existing.get("priority")
|
|
449
|
+
|
|
450
|
+
declared_priority = (
|
|
451
|
+
DEFAULT_PRIORITY if component.priority is None else component.priority
|
|
452
|
+
)
|
|
453
|
+
if existing_priority is not None:
|
|
454
|
+
# Registry data may be corrupted (strings, zero, booleans); fall
|
|
455
|
+
# back to the declared/default priority instead of failing later.
|
|
456
|
+
priority = normalize_priority(existing_priority, default=declared_priority)
|
|
457
|
+
else:
|
|
458
|
+
priority = declared_priority
|
|
425
459
|
|
|
426
460
|
bundled = _locate_bundled_extension(component.id)
|
|
427
461
|
if bundled is not None and component.source is None:
|
specify_cli/catalogs.py
CHANGED
|
@@ -68,7 +68,7 @@ class CatalogStackBase:
|
|
|
68
68
|
|
|
69
69
|
@classmethod
|
|
70
70
|
def _validate_catalog_url(cls, url: str) -> None:
|
|
71
|
-
"""Validate that a catalog URL uses HTTPS,
|
|
71
|
+
"""Validate that a catalog URL uses HTTPS, including local hosts."""
|
|
72
72
|
from urllib.parse import urlparse
|
|
73
73
|
|
|
74
74
|
try:
|
|
@@ -83,14 +83,12 @@ class CatalogStackBase:
|
|
|
83
83
|
_ = parsed.port
|
|
84
84
|
except ValueError:
|
|
85
85
|
raise cls._error(f"Catalog URL is malformed: {url}") from None
|
|
86
|
-
|
|
87
|
-
if parsed.scheme != "https" and not (parsed.scheme == "http" and is_localhost):
|
|
86
|
+
if parsed.scheme != "https":
|
|
88
87
|
# A scheme-less value (``example.com/catalog.json``) would otherwise read
|
|
89
88
|
# "got ://". The value itself is not echoed: callers render errors as Rich markup.
|
|
90
89
|
got = f"{parsed.scheme}://" if parsed.scheme else "a URL with no scheme"
|
|
91
90
|
raise cls._error(
|
|
92
|
-
f"Catalog URL must use HTTPS (got {got}).
|
|
93
|
-
"HTTP is only allowed for localhost."
|
|
91
|
+
f"Catalog URL must use HTTPS (got {got})."
|
|
94
92
|
)
|
|
95
93
|
# Check hostname, not netloc: netloc is truthy for host-less URLs like
|
|
96
94
|
# "https://:8080" or "https://user@", so the host guarantee this error
|
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema_version": "1.0",
|
|
3
|
-
"updated_at": "2026-
|
|
3
|
+
"updated_at": "2026-11-10T00:00:00Z",
|
|
4
4
|
"catalog_url": "https://raw.githubusercontent.com/github/spec-kit/main/bundles/catalog.community.json",
|
|
5
5
|
"bundles": {
|
|
6
|
+
"ado": {
|
|
7
|
+
"name": "Spec Kit for Azure DevOps",
|
|
8
|
+
"id": "ado",
|
|
9
|
+
"version": "0.3.2",
|
|
10
|
+
"role": "developer",
|
|
11
|
+
"description": "The ado extension plus the ado-lifecycle workflow: an ADO story to Done with a human gate on every board or PR change.",
|
|
12
|
+
"author": "praveenlavu",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"download_url": "https://github.com/praveenlavu/spec-kit-ado/releases/download/v0.3.2/ado-0.3.2.zip",
|
|
15
|
+
"sha256": "c18f719069734378954ecdae66bc29fcc2400eef951154724822f33820719c5d",
|
|
16
|
+
"repository": "https://github.com/praveenlavu/spec-kit-ado",
|
|
17
|
+
"requires": {
|
|
18
|
+
"speckit_version": ">=1.2.1"
|
|
19
|
+
},
|
|
20
|
+
"provides": {
|
|
21
|
+
"extensions": 1,
|
|
22
|
+
"presets": 0,
|
|
23
|
+
"steps": 0,
|
|
24
|
+
"workflows": 1
|
|
25
|
+
},
|
|
26
|
+
"tags": ["azure-devops", "issue-tracking", "hitl", "workflow", "governance"],
|
|
27
|
+
"verified": false
|
|
28
|
+
},
|
|
6
29
|
"agentstandards": {
|
|
7
30
|
"name": "Agentstandards Multi-Vendor Architecture",
|
|
8
31
|
"id": "agentstandards",
|
|
@@ -88,7 +88,8 @@ if [ -z "$FEATURE_DESCRIPTION" ]; then
|
|
|
88
88
|
fi
|
|
89
89
|
|
|
90
90
|
# Trim whitespace and validate description is not empty (e.g., user passed only whitespace)
|
|
91
|
-
|
|
91
|
+
# printf (not echo) keeps option-like descriptions such as "-n"/"-e"/"-E" as text, not options.
|
|
92
|
+
FEATURE_DESCRIPTION=$(printf '%s\n' "$FEATURE_DESCRIPTION" | sed -E 's/^[[:space:]]+|[[:space:]]+$//g')
|
|
92
93
|
if [ -z "$FEATURE_DESCRIPTION" ]; then
|
|
93
94
|
echo "Error: Feature description cannot be empty or contain only whitespace" >&2
|
|
94
95
|
exit 1
|
|
@@ -164,12 +164,12 @@ def _print_extension_info(ext_info: dict, manager):
|
|
|
164
164
|
|
|
165
165
|
# Header
|
|
166
166
|
verified_badge = " [green]✓ Verified[/green]" if ext_info.get("verified") else ""
|
|
167
|
-
_commands.console.print(f"\n[bold]{_escape_markup(str(ext_info
|
|
167
|
+
_commands.console.print(f"\n[bold]{_escape_markup(str(ext_info.get('name', ext_info['id'])))}[/bold] (v{_escape_markup(str(ext_info.get('version', 'unknown')))}){verified_badge}")
|
|
168
168
|
_commands.console.print(f"ID: {_escape_markup(str(ext_info['id']))}")
|
|
169
169
|
_commands.console.print()
|
|
170
170
|
|
|
171
171
|
# Description
|
|
172
|
-
_commands.console.print(f"{_escape_markup(str(ext_info
|
|
172
|
+
_commands.console.print(f"{_escape_markup(str(ext_info.get('description', '')))}")
|
|
173
173
|
_commands.console.print()
|
|
174
174
|
|
|
175
175
|
# Author and License
|
|
@@ -45,8 +45,8 @@ def extension_search(
|
|
|
45
45
|
for ext in results:
|
|
46
46
|
# Extension header
|
|
47
47
|
verified_badge = " [green]✓ Verified[/green]" if ext.get("verified") else ""
|
|
48
|
-
console.print(f"[bold]{_escape_markup(str(ext
|
|
49
|
-
console.print(f" {_escape_markup(str(ext
|
|
48
|
+
console.print(f"[bold]{_escape_markup(str(ext.get('name', ext['id'])))}[/bold] (v{_escape_markup(str(ext.get('version', 'unknown')))}){verified_badge}")
|
|
49
|
+
console.print(f" {_escape_markup(str(ext.get('description', '')))}")
|
|
50
50
|
|
|
51
51
|
# Metadata
|
|
52
52
|
console.print(f"\n [dim]Author:[/dim] {_escape_markup(str(ext.get('author', 'Unknown')))}")
|