feature/epic2-core-services #6

Merged
master merged 60 commits from feature/epic2-core-services into main 2025-11-07 10:23:20 +01:00
6 changed files with 35 additions and 14 deletions
Showing only changes of commit 31e8ca7ce9 - Show all commits

0
ci/runner/Dockerfile Normal file
View File

View File

@@ -277,12 +277,15 @@ func (s *auditServerImpl) Query(ctx context.Context, req *auditv1.QueryRequest)
}
total := len(protoEntries)
var totalInt32 int32
if total > math.MaxInt32 {
total = math.MaxInt32
totalInt32 = math.MaxInt32
} else {
totalInt32 = int32(total)
}
return &auditv1.QueryResponse{
Entries: protoEntries,
Total: int32(total),
Total: totalInt32,
}, nil
}

View File

@@ -77,7 +77,13 @@ func verifyPassword(password, hash string) (bool, error) {
if hashLen < 0 || hashLen > math.MaxUint32 {
return false, fmt.Errorf("invalid hash length: %d", hashLen)
}
actualHash := argon2.IDKey([]byte(password), salt, 3, 64*1024, 4, uint32(hashLen))
var hashLenUint32 uint32
if hashLen > math.MaxUint32 {
hashLenUint32 = math.MaxUint32
} else {
hashLenUint32 = uint32(hashLen)
}
actualHash := argon2.IDKey([]byte(password), salt, 3, 64*1024, 4, hashLenUint32)
return subtle.ConstantTimeCompare(expectedHash, actualHash) == 1, nil
}

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 {

View File

@@ -120,11 +120,14 @@ func (s *Server) Query(ctx context.Context, req *auditv1.QueryRequest) (*auditv1
}
total := len(protoEntries)
var totalInt32 int32
if total > math.MaxInt32 {
total = math.MaxInt32
totalInt32 = math.MaxInt32
} else {
totalInt32 = int32(total)
}
return &auditv1.QueryResponse{
Entries: protoEntries,
Total: int32(total), // Note: This is a simplified total, actual total would require a count query
Total: totalInt32, // Note: This is a simplified total, actual total would require a count query
}, nil
}

View File

@@ -82,7 +82,13 @@ func Verify(password, hash string) (bool, error) {
if hashLen < 0 || hashLen > math.MaxUint32 {
return false, fmt.Errorf("invalid hash length: %d", hashLen)
}
actualHash := argon2.IDKey([]byte(password), salt, uint32(t), uint32(m), uint8(p), uint32(hashLen))
var hashLenUint32 uint32
if hashLen > math.MaxUint32 {
hashLenUint32 = math.MaxUint32
} else {
hashLenUint32 = uint32(hashLen)
}
actualHash := argon2.IDKey([]byte(password), salt, uint32(t), uint32(m), uint8(p), hashLenUint32)
// Constant-time comparison
if subtle.ConstantTimeCompare(expectedHash, actualHash) == 1 {