Skip to content

Commit 3740d4a

Browse files
committed
fix: address Copilot review round 11 findings
- Fix _parse_semver() return type annotation and docstring to reflect that it returns packaging.version.Version or tuple[int, ...] - Fail closed on DNS resolution errors in check_url_reachable() to prevent SSRF bypass via unresolvable-then-resolvable hostnames - Remove dead documentation field code from _build_preset_entry() since the preset issue template has no documentation URL field - Update catalog-generate-table.py docstring to match --target behavior (exits with error when markers missing, not print to stdout) - Document that extension table Category/Effect columns require catalog schema extension to be populated - Update presets/DEVELOPING.md tag comment from 2-5 to 2-10
1 parent d627a64 commit 3740d4a

3 files changed

Lines changed: 21 additions & 9 deletions

File tree

.github/scripts/catalog-generate-table.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"""Generate a markdown table from a community catalog JSON file.
33
44
Reads a catalog.community.json and replaces content between marker comments
5-
in a target markdown file. If the markers are not present the table is
5+
in a target markdown file. When ``--target`` is provided and markers are
6+
missing, the script exits with an error. Without ``--target`` the table is
67
printed to stdout.
78
89
Markers expected in the markdown file:
@@ -100,7 +101,12 @@ def _provides_str_extension(provides: dict) -> str:
100101

101102

102103
def build_extension_table(catalog: dict) -> str:
103-
"""Build a markdown table for extensions."""
104+
"""Build a markdown table for extensions.
105+
106+
Note: Category and Effect columns will be empty unless the catalog
107+
entries include ``category`` and ``effect`` fields (not yet part of
108+
the standard catalog schema).
109+
"""
104110
entries = catalog.get("extensions", {})
105111
lines: list[str] = []
106112
lines.append("| Extension | Purpose | Category | Effect | URL |")

.github/scripts/catalog-validate.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,12 @@ def _present(value: str | None) -> bool:
155155
return bool(value and value.strip() and value.strip() != "_No response_")
156156

157157

158-
def _parse_semver(version: str) -> tuple[int, ...]:
159-
"""Parse a semver string into a comparable tuple of ints."""
158+
def _parse_semver(version: str):
159+
"""Parse a version string into a comparable object.
160+
161+
Returns a ``packaging.version.Version`` when the library is available,
162+
otherwise a tuple of ints (major, minor, patch).
163+
"""
160164
try:
161165
from packaging.version import Version
162166
return Version(version)
@@ -300,7 +304,9 @@ def check_url_reachable(
300304
f"{field_name} URL `{url}` resolves to a private/reserved address."
301305
)
302306
except (socket.gaierror, ValueError):
303-
pass # DNS resolution may fail for unreachable hosts — let urlopen handle it
307+
return False, (
308+
f"{field_name} URL `{url}` could not be resolved."
309+
)
304310

305311
_gh_hosts = {"github.com", "www.github.com", "codeload.github.com", "raw.githubusercontent.com"}
306312
_is_github = hostname in _gh_hosts
@@ -766,9 +772,9 @@ def _build_preset_entry(
766772
elif is_update and "extensions" in existing.get("requires", {}):
767773
requires["extensions"] = existing["requires"]["extensions"]
768774

769-
# Documentation URL: use existing on update, fall back to repo/blob/main/README.md
770-
documentation = _clean(fields.get("documentation", ""))
771-
if not documentation and is_update:
775+
# Documentation URL: preserve on update, fall back to repo/blob/main/README.md
776+
documentation = ""
777+
if is_update:
772778
documentation = existing.get("documentation", "")
773779
if not documentation:
774780
documentation = repo + "/blob/main/README.md"

presets/DEVELOPING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ provides:
6363
description: "Custom spec template"
6464
replaces: "spec-template"
6565

66-
tags: # 2-5 relevant tags
66+
tags: # 2-10 relevant tags
6767
- "category"
6868
- "workflow"
6969
```

0 commit comments

Comments
 (0)