fix(lint): use explicit safe type conversions for gosec
Use separate variables with explicit else branches to make type conversions safe and satisfy gosec integer overflow checks.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user