Skip to content

Commit bd1ee20

Browse files
committed
fix(ci): 修复 CI 门禁以打通 1.2.45 发布
- 迁移 275 契约测试:移除对 _notx 文件内 SET lock_timeout/statement_timeout 的断言(由 runner 统一注入,见 executeNonTransactionalMigration) - golangci-lint:gofmt 5 处、errcheck 3 处、SA1019(GetSecurityClientIP)、ST1005(Grok 错误串小写)、QF1002(tagged switch) - govulncheck:Go 1.26.5→1.26.6(修复 net/http 等 6 个 stdlib 漏洞)+ golang.org/x/image v0.43→v0.45(GO-2026-6222) - pnpm audit:nanoid 覆盖 pin 至 3.3.18(CVE-2026-67213
1 parent abda021 commit bd1ee20

20 files changed

Lines changed: 139 additions & 118 deletions

.github/workflows/backend-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
cache-dependency-path: backend/go.sum
4040
- name: Verify Go version
4141
run: |
42-
go version | grep -q 'go1.26.5'
42+
go version | grep -q 'go1.26.6'
4343
- name: Unit tests
4444
working-directory: backend
4545
run: make test-unit
@@ -124,7 +124,7 @@ jobs:
124124
cache-dependency-path: backend/go.sum
125125
- name: Verify Go version
126126
run: |
127-
go version | grep -q 'go1.26.5'
127+
go version | grep -q 'go1.26.6'
128128
- name: golangci-lint
129129
uses: golangci/golangci-lint-action@v9
130130
with:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ jobs:
142142

143143
- name: Verify Go version
144144
run: |
145-
go version | grep -q 'go1.26.5'
145+
go version | grep -q 'go1.26.6'
146146
147147
# Docker setup for GoReleaser
148148
- name: Set up QEMU

backend/go.mod

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/Wei-Shaw/sub2api
22

3-
go 1.26.5
3+
go 1.26.6
44

55
require (
66
entgo.io/ent v0.14.5
@@ -41,11 +41,11 @@ require (
4141
github.com/wechatpay-apiv3/wechatpay-go v0.2.21
4242
github.com/zeromicro/go-zero v1.9.4
4343
go.uber.org/zap v1.24.0
44-
golang.org/x/crypto v0.53.0
45-
golang.org/x/image v0.43.0
46-
golang.org/x/net v0.56.0
47-
golang.org/x/sync v0.21.0
48-
golang.org/x/term v0.44.0
44+
golang.org/x/crypto v0.54.0
45+
golang.org/x/image v0.45.0
46+
golang.org/x/net v0.57.0
47+
golang.org/x/sync v0.22.0
48+
golang.org/x/term v0.45.0
4949
gopkg.in/natefinch/lumberjack.v2 v2.2.1
5050
gopkg.in/yaml.v3 v3.0.1
5151
modernc.org/sqlite v1.44.3
@@ -174,10 +174,10 @@ require (
174174
go.uber.org/multierr v1.9.0 // indirect
175175
golang.org/x/arch v0.3.0 // indirect
176176
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 // indirect
177-
golang.org/x/mod v0.37.0 // indirect
178-
golang.org/x/sys v0.46.0 // indirect
179-
golang.org/x/text v0.39.0 // indirect
180-
golang.org/x/tools v0.47.0 // indirect
177+
golang.org/x/mod v0.38.0 // indirect
178+
golang.org/x/sys v0.47.0 // indirect
179+
golang.org/x/text v0.41.0 // indirect
180+
golang.org/x/tools v0.48.0 // indirect
181181
google.golang.org/grpc v1.75.1 // indirect
182182
google.golang.org/protobuf v1.36.10 // indirect
183183
gopkg.in/ini.v1 v1.67.0 // indirect

backend/go.sum

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,24 +441,34 @@ golang.org/x/crypto v0.51.0 h1:IBPXwPfKxY7cWQZ38ZCIRPI50YLeevDLlLnyC5wRGTI=
441441
golang.org/x/crypto v0.51.0/go.mod h1:8AdwkbraGNABw2kOX6YFPs3WM22XqI4EXEd8g+x7Oc8=
442442
golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto=
443443
golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio=
444+
golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw=
445+
golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk=
444446
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2wtOnGAHZWCHUM4KGzY=
445447
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
446448
golang.org/x/image v0.39.0 h1:skVYidAEVKgn8lZ602XO75asgXBgLj9G/FE3RbuPFww=
447449
golang.org/x/image v0.39.0/go.mod h1:sIbmppfU+xFLPIG0FoVUTvyBMmgng1/XAMhQ2ft0hpA=
448450
golang.org/x/image v0.43.0 h1:FLxcP4ec2350nTfOC8ysKtqYSIFbk/QGjw1ZHNP4tsY=
449451
golang.org/x/image v0.43.0/go.mod h1:rrpelvGFt+kLPAjPM4HeWPgrl0FtafueU//e5N0qk/Q=
452+
golang.org/x/image v0.45.0 h1:FMb1nTbH5H9vF55SriQHgFw5GnNL9Jg6L25BwXKzhB0=
453+
golang.org/x/image v0.45.0/go.mod h1:n62x/7RqlwXDvGsSU4u6IUTUf6KghUZ9Bt7cG/T9Fx4=
450454
golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=
451455
golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU=
452456
golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ=
453457
golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0=
458+
golang.org/x/mod v0.38.0 h1:MECBjubtXD7yj4HrhIUcywNaGeNVUdfVnxmPajOk4yk=
459+
golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40=
454460
golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8=
455461
golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww=
456462
golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o=
457463
golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec=
464+
golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE=
465+
golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU=
458466
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
459467
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
460468
golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
461469
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
470+
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
471+
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
462472
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
463473
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
464474
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -472,20 +482,28 @@ golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
472482
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
473483
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
474484
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
485+
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
486+
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
475487
golang.org/x/term v0.43.0 h1:S4RLU2sB31O/NCl+zFN9Aru9A/Cq2aqKpTZJ6B+DwT4=
476488
golang.org/x/term v0.43.0/go.mod h1:lrhlHNdQJHO+1qVYiHfFKVuVioJIheAc3fBSMFYEIsk=
477489
golang.org/x/term v0.44.0 h1:0rLvDRCtNj0gZkyIXhCyOb2OAzEhLVqc4B+hrsBhrmc=
478490
golang.org/x/term v0.44.0/go.mod h1:7ze4MdzUzLXpSAoFP1H0bOI9aXDqveSvatT5vKcFh2Y=
491+
golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0=
492+
golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w=
479493
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
480494
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
481495
golang.org/x/text v0.39.0 h1:UbZz4pLOvn600D6Oh6GGEI6VAmndrEBLv8/6BEXzyus=
482496
golang.org/x/text v0.39.0/go.mod h1:3UwRclnC2g0TU9x8PZiyfOajCd1zaUNHF9cvqcQZ+ZM=
497+
golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8=
498+
golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M=
483499
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
484500
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
485501
golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
486502
golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI=
487503
golang.org/x/tools v0.47.0 h1:7Kn5x/d1svx/PzryTsqeoZN4TZwqeH5pGWjefhLi/1Q=
488504
golang.org/x/tools v0.47.0/go.mod h1:dFHnyTvFWY212G+h7ZY4Vsp/K3U4/7W9TyVaAul8uCA=
505+
golang.org/x/tools v0.48.0 h1:3+hClM1aLL5mjMKm5ovokw9epgRXPuu2tILgismM6RE=
506+
golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk=
489507
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
490508
google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 h1:wpZ8pe2x1Q3f2KyT5f8oP/fa9rHAKgFPr/HZdNuS+PQ=
491509
google.golang.org/genproto/googleapis/api v0.0.0-20250929231259-57b25ae835d4 h1:8XJ4pajGwOlasW+L13MnEGA8W4115jJySQtVfS2/IBU=

backend/internal/handler/admin/account_codex_agent_identity_import_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import (
1414

1515
func TestNormalizeCodexImportEntryAcceptsAgentIdentityAuthJSON(t *testing.T) {
1616
value := buildAgentIdentityImportValue(t, "runtime-import", "team-import", "user-import", "")
17-
identity := value["agent_identity"].(map[string]any)
17+
identity, ok := value["agent_identity"].(map[string]any)
18+
require.True(t, ok)
1819
identity["email"] = "agent@example.invalid"
1920
identity["plan_type"] = "pro"
2021
identity["chatgpt_account_is_fedramp"] = false
@@ -56,7 +57,8 @@ func TestCodexAgentIdentityIndexSeparatesTeamsAndMergesSameTeam(t *testing.T) {
5657
func TestImportCodexSessionsMergesAgentRuntimeForSameTeamWithoutOAuthExpiry(t *testing.T) {
5758
first := buildAgentIdentityImportValue(t, "runtime-a", "team-a", "same-user", "task-a")
5859
second := buildAgentIdentityImportValue(t, "runtime-b", "team-a", "same-user", "task-b")
59-
firstIdentity := first["agent_identity"].(map[string]any)
60+
firstIdentity, ok := first["agent_identity"].(map[string]any)
61+
require.True(t, ok)
6062
svc := newCodexImportMemoryAdminService([]service.Account{{
6163
ID: 41, Platform: service.PlatformOpenAI, Type: service.AccountTypeOAuth,
6264
Credentials: map[string]any{

backend/internal/handler/admin/channel_handler.go

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,20 @@ type updateChannelRequest struct {
5656
}
5757

5858
type channelModelPricingRequest struct {
59-
Platform string `json:"platform" binding:"omitempty,max=50"`
60-
Models []string `json:"models" binding:"required,min=1,max=100"`
61-
BillingMode string `json:"billing_mode" binding:"omitempty,oneof=token per_request image"`
62-
InputPrice *float64 `json:"input_price" binding:"omitempty,min=0"`
63-
OutputPrice *float64 `json:"output_price" binding:"omitempty,min=0"`
64-
CacheWritePrice *float64 `json:"cache_write_price" binding:"omitempty,min=0"`
65-
CacheReadPrice *float64 `json:"cache_read_price" binding:"omitempty,min=0"`
66-
ImageInputPrice *float64 `json:"image_input_price" binding:"omitempty,min=0"`
67-
ImageCacheReadPrice *float64 `json:"image_cache_read_price" binding:"omitempty,min=0"`
68-
ImageOutputPrice *float64 `json:"image_output_price" binding:"omitempty,min=0"`
69-
PerRequestPrice *float64 `json:"per_request_price" binding:"omitempty,min=0"`
70-
LongContextPricingEnabled *bool `json:"long_context_pricing_enabled"`
71-
LongContextInputTokenThreshold *int `json:"long_context_input_token_threshold" binding:"omitempty,min=1,max=2147483647"`
72-
Intervals []pricingIntervalRequest `json:"intervals"`
59+
Platform string `json:"platform" binding:"omitempty,max=50"`
60+
Models []string `json:"models" binding:"required,min=1,max=100"`
61+
BillingMode string `json:"billing_mode" binding:"omitempty,oneof=token per_request image"`
62+
InputPrice *float64 `json:"input_price" binding:"omitempty,min=0"`
63+
OutputPrice *float64 `json:"output_price" binding:"omitempty,min=0"`
64+
CacheWritePrice *float64 `json:"cache_write_price" binding:"omitempty,min=0"`
65+
CacheReadPrice *float64 `json:"cache_read_price" binding:"omitempty,min=0"`
66+
ImageInputPrice *float64 `json:"image_input_price" binding:"omitempty,min=0"`
67+
ImageCacheReadPrice *float64 `json:"image_cache_read_price" binding:"omitempty,min=0"`
68+
ImageOutputPrice *float64 `json:"image_output_price" binding:"omitempty,min=0"`
69+
PerRequestPrice *float64 `json:"per_request_price" binding:"omitempty,min=0"`
70+
LongContextPricingEnabled *bool `json:"long_context_pricing_enabled"`
71+
LongContextInputTokenThreshold *int `json:"long_context_input_token_threshold" binding:"omitempty,min=1,max=2147483647"`
72+
Intervals []pricingIntervalRequest `json:"intervals"`
7373
TimeRanges []pricingTimeRangeRequest `json:"time_ranges"`
7474
}
7575

@@ -125,21 +125,21 @@ type channelResponse struct {
125125
}
126126

127127
type channelModelPricingResponse struct {
128-
ID int64 `json:"id"`
129-
Platform string `json:"platform"`
130-
Models []string `json:"models"`
131-
BillingMode string `json:"billing_mode"`
132-
InputPrice *float64 `json:"input_price"`
133-
OutputPrice *float64 `json:"output_price"`
134-
CacheWritePrice *float64 `json:"cache_write_price"`
135-
CacheReadPrice *float64 `json:"cache_read_price"`
136-
ImageInputPrice *float64 `json:"image_input_price"`
137-
ImageCacheReadPrice *float64 `json:"image_cache_read_price"`
138-
ImageOutputPrice *float64 `json:"image_output_price"`
139-
PerRequestPrice *float64 `json:"per_request_price"`
140-
LongContextPricingEnabled *bool `json:"long_context_pricing_enabled"`
141-
LongContextInputTokenThreshold *int `json:"long_context_input_token_threshold"`
142-
Intervals []pricingIntervalResponse `json:"intervals"`
128+
ID int64 `json:"id"`
129+
Platform string `json:"platform"`
130+
Models []string `json:"models"`
131+
BillingMode string `json:"billing_mode"`
132+
InputPrice *float64 `json:"input_price"`
133+
OutputPrice *float64 `json:"output_price"`
134+
CacheWritePrice *float64 `json:"cache_write_price"`
135+
CacheReadPrice *float64 `json:"cache_read_price"`
136+
ImageInputPrice *float64 `json:"image_input_price"`
137+
ImageCacheReadPrice *float64 `json:"image_cache_read_price"`
138+
ImageOutputPrice *float64 `json:"image_output_price"`
139+
PerRequestPrice *float64 `json:"per_request_price"`
140+
LongContextPricingEnabled *bool `json:"long_context_pricing_enabled"`
141+
LongContextInputTokenThreshold *int `json:"long_context_input_token_threshold"`
142+
Intervals []pricingIntervalResponse `json:"intervals"`
143143
TimeRanges []pricingTimeRangeResponse `json:"time_ranges"`
144144
}
145145

backend/internal/handler/gateway_web_search.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ func (h *GatewayHandler) WebSearch(c *gin.Context) {
219219
}
220220

221221
userAgent := c.GetHeader("User-Agent")
222-
clientIP := ip.GetClientIP(c)
222+
clientIP := ip.GetSecurityClientIP(c)
223223
inboundEndpoint := GetInboundEndpoint(c)
224224
upstreamEndpoint := GetUpstreamEndpoint(c, account.Platform)
225225
requestPayloadHash := service.HashUsageRequestPayload([]byte(req.Query))

backend/internal/service/account.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ const (
157157
)
158158

159159
const (
160-
AccountListStatusRateLimited = "rate_limited"
161-
AccountListStatusTempUnschedulable = "temp_unschedulable"
162-
AccountListStatusUnschedulable = "unschedulable"
163-
AccountListStatusCodexQuotaProtected = "codex_quota_protected"
160+
AccountListStatusRateLimited = "rate_limited"
161+
AccountListStatusTempUnschedulable = "temp_unschedulable"
162+
AccountListStatusUnschedulable = "unschedulable"
163+
AccountListStatusCodexQuotaProtected = "codex_quota_protected"
164164
AccountListStatusOpencodeQuotaProtected = "opencode_quota_protected"
165165
)
166166

0 commit comments

Comments
 (0)