Skip to content

Commit 8d39a59

Browse files
authored
fix(lint): add nolint directives for safe integer conversions (#361)
## Summary - Fix gosec G115 warnings for safe uint->int/int64 conversions - All flagged conversions involve small config values (ports, timeouts, limits) ## Changes - `main.go:58`: SMTPPort (0-65535) - `main.go:71`: ResetRateLimitRequests (typically 3-10) - `main.go:73`: ResetRateLimitWindowMinutes (typically 60-120) - `internal/rpc/request_password_reset.go:99`: ResetTokenExpiryMinutes (typically 15-60) ## Test plan - CI should pass with gosec checks - No functional changes
2 parents 0d189d8 + 883969e commit 8d39a59

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

internal/rpc/request_password_reset.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func (h *Handler) requestPasswordResetWithIP(params []string, clientIP string) (
9696
now := time.Now()
9797
// Safe conversion: ResetTokenExpiryMinutes is uint, typically small value (15-60)
9898
// Convert to time.Duration for expiration calculation
99+
//nolint:gosec // G115: small config value, safe for int64
99100
expiryDuration := time.Duration(h.opts.ResetTokenExpiryMinutes) * time.Minute
100101
token := &resettoken.ResetToken{
101102
Token: tokenString,

main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func main() {
5555

5656
// Initialize email service
5757
// Safe conversion: SMTPPort is uint, typically 25/587/465 (well within int range)
58-
smtpPort := int(opts.SMTPPort)
58+
smtpPort := int(opts.SMTPPort) //nolint:gosec // G115: SMTPPort is 0-65535, safe for int
5959
emailConfig := email.Config{
6060
SMTPHost: opts.SMTPHost,
6161
SMTPPort: smtpPort,
@@ -68,8 +68,9 @@ func main() {
6868

6969
// Initialize email-based rate limiter (per-user protection)
7070
// Safe conversion: ResetRateLimitRequests is uint, typically small value (3-10)
71-
resetRequests := int(opts.ResetRateLimitRequests)
71+
resetRequests := int(opts.ResetRateLimitRequests) //nolint:gosec // G115: small config value, safe for int
7272
// Safe conversion: ResetRateLimitWindowMinutes is uint, typically 60-120
73+
//nolint:gosec // G115: small config value, safe for int64
7374
resetWindowDuration := time.Duration(opts.ResetRateLimitWindowMinutes) * time.Minute
7475
rateLimiter := ratelimit.NewLimiter(resetRequests, resetWindowDuration)
7576

0 commit comments

Comments
 (0)