fix(lint): add bounds checking for integer conversions to fix gosec warnings
All checks were successful
CI / Test (pull_request) Successful in 57s
CI / Lint (pull_request) Successful in 27s
CI / Build (pull_request) Successful in 39s
CI / Format Check (pull_request) Successful in 2s

- Add bounds checking for Limit and Offset conversions in audit_client.go
- Add bounds checking for t, m, and p conversions in password.go
- Add nolint comments with explanations for safe conversions
This commit is contained in:
2025-11-07 10:04:14 +01:00
parent 9712e50f6c
commit 75c5293c8c
3 changed files with 39 additions and 9 deletions

View File

@@ -90,13 +90,17 @@ func (c *AuditClient) Query(ctx context.Context, filters *services.AuditLogFilte
var limitInt32, offsetInt32 int32
if filters.Limit > math.MaxInt32 {
limitInt32 = math.MaxInt32
} else if filters.Limit < math.MinInt32 {
limitInt32 = math.MinInt32
} else {
limitInt32 = int32(filters.Limit)
limitInt32 = int32(filters.Limit) //nolint:gosec // bounds checked above
}
if filters.Offset > math.MaxInt32 {
offsetInt32 = math.MaxInt32
} else if filters.Offset < math.MinInt32 {
offsetInt32 = math.MinInt32
} else {
offsetInt32 = int32(filters.Offset)
offsetInt32 = int32(filters.Offset) //nolint:gosec // bounds checked above
}
req := &auditv1.QueryRequest{
Limit: limitInt32,