fix(lint): use explicit safe type conversions for gosec
Some checks failed
CI / Test (pull_request) Successful in 51s
CI / Lint (pull_request) Failing after 26s
CI / Build (pull_request) Successful in 38s
CI / Format Check (pull_request) Failing after 2s

Use separate variables with explicit else branches to make type
conversions safe and satisfy gosec integer overflow checks.
This commit is contained in:
2025-11-07 09:37:53 +01:00
parent e673fcae6f
commit 31e8ca7ce9
6 changed files with 35 additions and 14 deletions

View File

@@ -87,17 +87,20 @@ func (c *AuditClient) Query(ctx context.Context, filters *services.AuditLogFilte
return nil, err
}
limit := filters.Limit
if limit > math.MaxInt32 {
limit = math.MaxInt32
var limitInt32, offsetInt32 int32
if filters.Limit > math.MaxInt32 {
limitInt32 = math.MaxInt32
} else {
limitInt32 = int32(filters.Limit)
}
offset := filters.Offset
if offset > math.MaxInt32 {
offset = math.MaxInt32
if filters.Offset > math.MaxInt32 {
offsetInt32 = math.MaxInt32
} else {
offsetInt32 = int32(filters.Offset)
}
req := &auditv1.QueryRequest{
Limit: int32(limit),
Offset: int32(offset),
Limit: limitInt32,
Offset: offsetInt32,
}
if filters.UserID != nil {