Repository navigation
Feature/add sms notification #4306
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
base: main
Are you sure you want to change the base?
Changes from 7 commits
16121c8
d7d35e9
2e7a732
b52f74b
64a4395
b679a1d
5ccf67c
a35f11e
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 |
|---|---|---|
|
|
@@ -63,6 +63,22 @@ func InitOptionMap() { | |
| common.OptionMap["SMTPToken"] = "" | ||
| common.OptionMap["SMTPSSLEnabled"] = strconv.FormatBool(common.SMTPSSLEnabled) | ||
| common.OptionMap["SMTPForceAuthLogin"] = strconv.FormatBool(common.SMTPForceAuthLogin) | ||
| common.OptionMap["SMSProvider"] = "" | ||
| common.OptionMap["SMSAliyunAccessKeyId"] = "" | ||
| common.OptionMap["SMSAliyunAccessKeySecret"] = "" | ||
| common.OptionMap["SMSAliyunSignName"] = "" | ||
| common.OptionMap["SMSAliyunTemplateCode"] = "" | ||
| common.OptionMap["SMSSendCloudSmsUser"] = "" | ||
| common.OptionMap["SMSSendCloudSmsKey"] = "" | ||
| common.OptionMap["SMSSendCloudTemplateId"] = "" | ||
| common.OptionMap["SMSTencentSecretId"] = "" | ||
| common.OptionMap["SMSTencentSecretKey"] = "" | ||
| common.OptionMap["SMSTencentSmsSdkAppId"] = "" | ||
| common.OptionMap["SMSTencentSignName"] = "" | ||
| common.OptionMap["SMSTencentTemplateId"] = "" | ||
| common.OptionMap["SMSCustomUrl"] = "" | ||
| common.OptionMap["SMSCustomMethod"] = "POST" | ||
| common.OptionMap["SMSCustomTemplate"] = "" | ||
| common.OptionMap["Notice"] = "" | ||
| common.OptionMap["About"] = "" | ||
| common.OptionMap["HomePageContent"] = "" | ||
|
|
@@ -345,6 +361,46 @@ func updateOptionMap(key string, value string) (err error) { | |
| common.SMTPFrom = value | ||
| case "SMTPToken": | ||
| common.SMTPToken = value | ||
| case "SMSProvider": | ||
| common.SMSProvider = value | ||
| case "SMSAliyunAccessKeyId": | ||
| common.SMSAliyunAccessKeyId = value | ||
| case "SMSAliyunAccessKeySecret": | ||
| common.SMSAliyunAccessKeySecret = value | ||
| case "SMSAliyunSignName": | ||
| common.SMSAliyunSignName = value | ||
| case "SMSAliyunTemplateCode": | ||
| common.SMSAliyunTemplateCode = value | ||
| case "SMSSendCloudSmsUser": | ||
| common.SMSSendCloudSmsUser = value | ||
| case "SMSSendCloudSmsKey": | ||
| common.SMSSendCloudSmsKey = value | ||
| case "SMSSendCloudTemplateId": | ||
| common.SMSSendCloudTemplateId = value | ||
| case "SMSTencentSecretId": | ||
| common.SMSTencentSecretId = value | ||
| case "SMSTencentSecretKey": | ||
| common.SMSTencentSecretKey = value | ||
| case "SMSTencentSmsSdkAppId": | ||
| common.SMSTencentSmsSdkAppId = value | ||
| case "SMSTencentSignName": | ||
| common.SMSTencentSignName = value | ||
| case "SMSTencentTemplateId": | ||
| common.SMSTencentTemplateId = value | ||
| case "SMSCustomUrl": | ||
| common.SMSCustomUrl = value | ||
| case "SMSCustomMethod": | ||
| upperMethod := strings.ToUpper(value) | ||
| switch upperMethod { | ||
| case "GET", "POST", "PUT", "DELETE", "PATCH": | ||
| common.SMSCustomMethod = upperMethod | ||
| case "": | ||
| // 空值保留默认的 POST | ||
| default: | ||
| common.SMSCustomMethod = "POST" | ||
| } | ||
| case "SMSCustomTemplate": | ||
| common.SMSCustomTemplate = value | ||
|
Comment on lines
+364
to
+403
Contributor
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. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Enumerate which SMS keys are actually filtered by controller/option.go and which are returned.
rg -nP -C3 '(SMSAliyunAccessKeyId|SMSSendCloudSmsUser|SMSTencentSecretId|SMSCustomUrl|SMSCustomTemplate|HasSuffix\(k,\s*"(Secret|Key|Token|secret|api_key)"\))' controller/option.go
echo "---"
# Find any other place SMS* options are read/written (to confirm no additional exposure paths)
rg -nP -C2 '\bSMS[A-Z][A-Za-z]+' --type=goRepository: QuantumNous/new-api Length of output: 7675 Fix credential exposure: The filtering logic in 🤖 Prompt for AI Agents |
||
| case "ServerAddress": | ||
| system_setting.ServerAddress = value | ||
| case "WorkerUrl": | ||
|
|
||
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.
Normalize
SMSCustomMethodbefore storing it.common.OptionMap[key]is written with the raw input before this branch runs, so a blank or unsupported method can still be exposed via/api/option/even thoughcommon.SMSCustomMethodfalls back toPOST. This also accepts methods thatservice/sms_notify.godoes not actually send, so the config can drift from runtime behavior.🛠️ Suggested fix
case "SMSCustomMethod": upperMethod := strings.ToUpper(value) switch upperMethod { - case "GET", "POST", "PUT", "DELETE", "PATCH": + case "GET", "POST": common.SMSCustomMethod = upperMethod + common.OptionMap[key] = upperMethod case "": - // 空值保留默认的 POST + common.SMSCustomMethod = "POST" + common.OptionMap[key] = "POST" default: common.SMSCustomMethod = "POST" + common.OptionMap[key] = "POST" }🤖 Prompt for AI Agents