Skip to content

Commit 2c3ab4c

Browse files
committed
Validate package URL before calling curl; fail with clear diagnostic (ci/validate-macports-package-url)
1 parent f7c795d commit 2c3ab4c

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

install_macports

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import re
6565
import sys
6666
6767
macos = sys.argv[1]
68-
tag_name = sys.argv[2]
68+
tag_name = sys.argv[2]
6969
7070
package_pattern = macos + "[.]pkg$"
7171
@@ -221,12 +221,31 @@ main()
221221
'Configuration Summary'\
222222
configuration_summary
223223

224+
# Guarded package selection and installation.
224225
if [ "${macports_prefix}" = '/opt/local' ]; then
225-
fetch_and_install_package "$(make_package)"
226+
# Determine the package URL for this macOS/version.
227+
package_url="$(make_package)"
228+
# Diagnostic values for debugging.
229+
detected_macos="$(probe_macos)"
230+
detected_version="${macports_version:-unknown}"
231+
232+
if [ -z "${package_url}" ] || [ "${package_url}" = ":not-found" ]; then
233+
failwith 'Cannot determine MacPorts package for detected macOS "%s" and version "%s". Package URL is empty.' "${detected_macos}" "${detected_version}"
234+
fi
235+
236+
# Confirm the URL looks like an https URL to avoid passing blanks/options to curl.
237+
case "${package_url}" in
238+
https://* )
239+
fetch_and_install_package "${package_url}"
240+
;;
241+
* )
242+
failwith 'Invalid MacPorts package URL: %s' "${package_url}"
243+
;;
244+
esac
226245
else
227-
install_from_source
246+
install_from_source
228247
fi
229-
248+
230249
install_ports "${macports_prefix}/etc/setup-macports.yaml"
231250
}
232251

0 commit comments

Comments
 (0)