Skip to content

Commit 58ed563

Browse files
authored
feat: enable insecure mode via INSECURE environment variable (#247)
- Change INSECURE configuration to be enabled by presence of the INSECURE variable, replacing the previous true/false CURL_INSECURE approach - Update documentation in English and Chinese (Simplified, Traditional) to reflect INSECURE variable usage - Add usage examples showing how to enable insecure mode via INSECURE=1 - Remove validation checks for CURL_INSECURE value and all references to CURL_INSECURE in the script - Use INSECURE_ARG for curl invocations to manage SSL verification according to the new logic Signed-off-by: appleboy <[email protected]>
1 parent 254b21f commit 58ed563

File tree

4 files changed

+28
-24
lines changed

4 files changed

+28
-24
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,18 @@ chmod +x install.sh
130130

131131
#### Configurable Environment Variables
132132

133-
| Variable Name | Default Value | Description |
134-
| ------------- | ------------------ | ----------------------------------------------------------- |
135-
| VERSION | latest | The CodeGPT version to install (defaults to latest release) |
136-
| INSTALL_DIR | $HOME/.codegpt/bin | Installation directory |
137-
| CURL_INSECURE | false | Skip SSL verification (true/false) |
133+
| Variable Name | Default Value | Description |
134+
| ------------- | ------------------ | ----------------------------------------------------------------------------- |
135+
| VERSION | latest | The CodeGPT version to install (defaults to latest release) |
136+
| INSTALL_DIR | $HOME/.codegpt/bin | Installation directory |
137+
| INSECURE | unset (disabled) | If set to any value, skips SSL verification. Enabled when variable is present |
138138

139139
Example usage:
140140

141141
```sh
142+
# Install with insecure mode enabled (ignoring curl SSL verification):
143+
INSECURE=1 ./install.sh
144+
142145
# Install a specific version to a custom directory:
143146
VERSION=1.1.0 INSTALL_DIR=/opt/codegpt ./install.sh
144147
```

README.zh-cn.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,16 @@ chmod +x install.sh
127127

128128
| 变量名 | 默认值 | 说明 |
129129
| ------------- | ------------------ | ----------------------------------------- |
130-
| VERSION | latest | 要安装的 CodeGPT 版本(默认为最新发布版) |
131-
| INSTALL_DIR | $HOME/.codegpt/bin | 安装目录 |
132-
| CURL_INSECURE | false | 是否跳过 SSL 验证 (true/false) |
130+
| VERSION | latest | 要安装的 CodeGPT 版本(默认为最新发布版) |
131+
| INSTALL_DIR | $HOME/.codegpt/bin | 安装目录 |
132+
| INSECURE | 未设置(默认关闭) | 只要设置该变量(值不限),即跳过 SSL 验证 |
133133

134134
使用示例:
135135

136136
```sh
137+
# 启用 insecure 模式(跳过 curl SSL 验证)
138+
INSECURE=1 ./install.sh
139+
137140
# 安装指定版本到自定义目录
138141
VERSION=1.1.0 INSTALL_DIR=/opt/codegpt ./install.sh
139142
```

README.zh-tw.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,16 @@ chmod +x install.sh
131131

132132
| 變數名稱 | 預設值 | 說明 |
133133
| ------------- | ------------------ | ----------------------------------------- |
134-
| VERSION | latest | 要安裝的 CodeGPT 版本(預設為最新發布版) |
135-
| INSTALL_DIR | $HOME/.codegpt/bin | 安裝目錄 |
136-
| CURL_INSECURE | false | 是否跳過 SSL 驗證 (true/false) |
134+
| VERSION | latest | 要安裝的 CodeGPT 版本(預設為最新發布版) |
135+
| INSTALL_DIR | $HOME/.codegpt/bin | 安裝目錄 |
136+
| INSECURE | 未設定(預設停用) | 只要設定該變數(值不限),就會啟用跳過 SSL 驗證模式 |
137137

138138
使用範例:
139139

140140
```sh
141+
# 啟用 insecure 模式(忽略 SSL 驗證)
142+
INSECURE=1 ./install.sh
143+
141144
# 安裝特定版本到自訂目錄
142145
VERSION=1.1.0 INSTALL_DIR=/opt/codegpt ./install.sh
143146
```

install.sh

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function download_and_install() {
6666
# Use temp dir for download
6767
TARGET="${TMPDIR}/${CLIENT_BINARY}"
6868

69-
curl -# -fSL --retry 5 --keepalive-time 2 ${INSECURE_OPTION} "${DOWNLOAD_URL_PREFIX}/${CLIENT_BINARY}" -o "${TARGET}"
69+
curl -# -fSL --retry 5 --keepalive-time 2 ${INSECURE_ARG} "${DOWNLOAD_URL_PREFIX}/${CLIENT_BINARY}" -o "${TARGET}"
7070
chmod +x "${TARGET}" || log_error "Failed to set executable permission on: ${TARGET}" 7
7171
# Move the binary to install dir and rename to codegpt
7272
mv "${TARGET}" "${INSTALL_DIR}/codegpt" || log_error "Failed to move ${TARGET} to ${INSTALL_DIR}/codegpt" 8
@@ -104,9 +104,9 @@ function add_to_path() {
104104
function get_latest_version() {
105105
local latest
106106
if command -v jq >/dev/null 2>&1; then
107-
latest=$(curl $INSECURE_OPTION -# --retry 5 -fSL https://api.github.com/repos/appleboy/CodeGPT/releases/latest | jq -r .tag_name)
107+
latest=$(curl $INSECURE_ARG -# --retry 5 -fSL https://api.github.com/repos/appleboy/CodeGPT/releases/latest | jq -r .tag_name)
108108
else
109-
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/')
109+
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/')
110110
fi
111111
# Remove leading 'v' if present
112112
latest="${latest#v}"
@@ -120,18 +120,13 @@ for cmd in curl; do
120120
fi
121121
done
122122

123-
CURL_INSECURE="${CURL_INSECURE:-false}"
124-
if [[ "${CURL_INSECURE}" != 'true' && "${CURL_INSECURE}" != 'false' ]]; then
125-
log_error "CURL_INSECURE must be either 'true' or 'false'" 4
126-
fi
127-
if [[ "${CURL_INSECURE}" == 'true' ]]; then
128-
print_message warning "WARNING: CURL_INSECURE is set to true. Proceeding with insecure download."
123+
# If INSECURE is set to any value, enable curl --insecure
124+
INSECURE_ARG=""
125+
if [[ -n "${INSECURE:-}" ]]; then
126+
INSECURE_ARG="--insecure"
127+
print_message warning "WARNING: INSECURE mode is enabled. Proceeding with insecure download."
129128
print_message warning "WARNING: You are bypassing SSL certificate verification. This is insecure and may expose you to man-in-the-middle attacks."
130129
fi
131-
INSECURE_OPTION=""
132-
if [[ "${CURL_INSECURE}" == 'true' ]]; then
133-
INSECURE_OPTION="--insecure"
134-
fi
135130

136131
if [[ -z "${VERSION:-}" ]]; then
137132
LATEST_VERSION=$(get_latest_version)

0 commit comments

Comments
 (0)