-
-
Notifications
You must be signed in to change notification settings - Fork 125
feat: enable insecure mode via INSECURE environment variable #247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -66,7 +66,7 @@ function download_and_install() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Use temp dir for download | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
TARGET="${TMPDIR}/${CLIENT_BINARY}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
curl -# -fSL --retry 5 --keepalive-time 2 ${INSECURE_OPTION} "${DOWNLOAD_URL_PREFIX}/${CLIENT_BINARY}" -o "${TARGET}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
curl -# -fSL --retry 5 --keepalive-time 2 ${INSECURE_ARG} "${DOWNLOAD_URL_PREFIX}/${CLIENT_BINARY}" -o "${TARGET}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
chmod +x "${TARGET}" || log_error "Failed to set executable permission on: ${TARGET}" 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Move the binary to install dir and rename to codegpt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
mv "${TARGET}" "${INSTALL_DIR}/codegpt" || log_error "Failed to move ${TARGET} to ${INSTALL_DIR}/codegpt" 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -104,9 +104,9 @@ function add_to_path() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
function get_latest_version() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
local latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if command -v jq >/dev/null 2>&1; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
latest=$(curl $INSECURE_OPTION -# --retry 5 -fSL https://api.github.com/repos/appleboy/CodeGPT/releases/latest | jq -r .tag_name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
latest=$(curl $INSECURE_ARG -# --retry 5 -fSL https://api.github.com/repos/appleboy/CodeGPT/releases/latest | jq -r .tag_name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As part of refactoring to use an array for optional arguments, please update this
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
latest=$(curl $INSECURE_OPTION -# --retry 5 -fSL https://api.github.com/repos/appleboy/CodeGPT/releases/latest | grep '"tag_name":' | sed -E 's/.*"tag_name": ?"v?([^"]+)".*/\1/') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
latest=$(curl $INSECURE_ARG -# --retry 5 -fSL https://api.github.com/repos/appleboy/CodeGPT/releases/latest | grep '"tag_name":' | sed -E 's/.*"tag_name": ?"v?([^"]+)".*/\1/') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As part of refactoring to use an array for optional arguments, please update this
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Remove leading 'v' if present | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
latest="${latest#v}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -120,18 +120,13 @@ for cmd in curl; do | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CURL_INSECURE="${CURL_INSECURE:-false}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if [[ "${CURL_INSECURE}" != 'true' && "${CURL_INSECURE}" != 'false' ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
log_error "CURL_INSECURE must be either 'true' or 'false'" 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if [[ "${CURL_INSECURE}" == 'true' ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
print_message warning "WARNING: CURL_INSECURE is set to true. Proceeding with insecure download." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# If INSECURE is set to any value, enable curl --insecure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
INSECURE_ARG="" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if [[ -n "${INSECURE:-}" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
INSECURE_ARG="--insecure" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
print_message warning "WARNING: INSECURE mode is enabled. Proceeding with insecure download." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
print_message warning "WARNING: You are bypassing SSL certificate verification. This is insecure and may expose you to man-in-the-middle attacks." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+124
to
129
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For better script robustness, it's recommended to use an array to handle optional command arguments. This avoids potential word-splitting issues and is generally safer. This refactoring defines I'll add suggestions to update the
Suggested change
Comment on lines
+123
to
129
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainEnable backward compatibility with deprecated CURL_INSECURE (optional) Current behavior is correct per PR goals. To avoid breaking existing automation, optionally honor legacy CURL_INSECURE (any non-empty), and emit a deprecation warning. INSECURE_ARG=""
if [[ -n "${INSECURE:-}" ]]; then
INSECURE_ARG="--insecure"
print_message warning "WARNING: INSECURE mode is enabled. Proceeding with insecure download."
print_message warning "WARNING: You are bypassing SSL certificate verification. This is insecure and may expose you to man-in-the-middle attacks."
fi
+
+# Backward compatibility (deprecated). Prefer INSECURE=1.
+if [[ -z "${INSECURE:-}" && -n "${CURL_INSECURE:-}" ]]; then
+ INSECURE_ARG="--insecure"
+ print_message warning "WARNING: CURL_INSECURE is deprecated. Use INSECURE=1 instead."
+fi To ensure all old references were removed elsewhere in the repo and that curl call sites now use INSECURE_ARG, run: 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Searching for legacy CURL_INSECURE..."
rg -n --hidden --glob '!*dist*' --glob '!*build*' --glob '!*node_modules*' 'CURL_INSECURE' || true
echo "Searching for curl sites using INSECURE_ARG..."
rg -n --hidden --glob '!*dist*' --glob '!*build*' --glob '!*node_modules*' 'curl .*INSECURE_ARG' Length of output: 876 Honor legacy CURL_INSECURE for backward compatibility All INSECURE_ARG=""
if [[ -n "${INSECURE:-}" ]]; then
INSECURE_ARG="--insecure"
print_message warning "WARNING: INSECURE mode is enabled. Proceeding with insecure download."
print_message warning "WARNING: You are bypassing SSL certificate verification. This is insecure and may expose you to man-in-the-middle attacks."
fi
+# Backward compatibility (deprecated). Prefer INSECURE=1.
+if [[ -z "${INSECURE:-}" && -n "${CURL_INSECURE:-}" ]]; then
+ INSECURE_ARG="--insecure"
+ print_message warning "WARNING: CURL_INSECURE is deprecated. Use INSECURE=1 instead."
+fi This ensures any existing automation relying on 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
INSECURE_OPTION="" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if [[ "${CURL_INSECURE}" == 'true' ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
INSECURE_OPTION="--insecure" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if [[ -z "${VERSION:-}" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LATEST_VERSION=$(get_latest_version) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As part of refactoring to use an array for optional arguments, please update this
curl
invocation. Using"${INSECURE_ARGS[@]}"
ensures arguments are handled safely.