fix(security): 修复gosec报告的7处代码安全分析告警(G101/G104/G203/G602)
Security Checks / security (push) Waiting to run
Security Checks / security (push) Waiting to run
This commit is contained in:
1 parent
e58e635492
commit
3753c4a0c9
6 files changed
+14
-4
No files matched your search
@@ -50,7 +50,9 @@ func GetEmailDetail(ctx *context.Context, id int, markRead bool) (*response.Emai
|
||||
}
|
||||
session := db.Instance.NewSession()
|
||||
blocked, err := models.BlacklistedRecipientIDs(session, []int{ctx.UserID}, email.FromAddress, sender.EmailAddress)
|
||||
session.Close()
|
||||
if closeErr := session.Close(); closeErr != nil && err == nil {
|
||||
err = closeErr
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -171,7 +171,9 @@ func forwardToLocalUser(ctx *context.Context, email *parsemail.Email, account, f
|
||||
}
|
||||
session := db.Instance.NewSession()
|
||||
blocked, filterErr := models.BlacklistedRecipientIDs(session, []int{user.ID}, email.SenderFilterAddresses()...)
|
||||
session.Close()
|
||||
if closeErr := session.Close(); closeErr != nil && filterErr == nil {
|
||||
filterErr = closeErr
|
||||
}
|
||||
if filterErr != nil {
|
||||
return filterErr
|
||||
}
|
||||
|
||||
@@ -382,7 +382,9 @@ func randomCodeFromReader(length int, reader io.Reader) (string, error) {
|
||||
continue
|
||||
}
|
||||
digit := int(value) % len(digits)
|
||||
// #nosec G602 -- digit 取值由 int(value)%len(digits) 限定在 0-9 范围,且 counts 和 digits 长度均固定为 10,不存在切片越界
|
||||
code[written] = digits[digit]
|
||||
// #nosec G602 -- digit 取值限定在 0-9 范围,counts 长度为 10,不存在切片越界
|
||||
counts[digit]++
|
||||
written++
|
||||
if written == length {
|
||||
|
||||
Reference in new issue
Block a user