mirror of
https://github.com/lukaszraczylo/graphql-monitoring-proxy.git
synced 2026-10-17 06:17:40 +00:00
* chore(security,refactor): extract sanitization and improve code quality
- [x] Extract sanitization functions to dedicated sanitization.go module
- [x] Add comprehensive golangci-lint v2 configuration with security rules
- [x] Replace interface{} with any type throughout codebase
- [x] Add admin API authentication security warning
- [x] Extract WebSocket and stats streaming constants
- [x] Add best-effort error handling comments for resource cleanup
- [x] Expand sensitive field patterns for improved PII redaction
- [x] Simplify safety checks and remove redundant nil validations
- [x] Improve test coverage for password field redaction patterns
* refactor: replace interface{} with any type alias
- [x] Replace all `map[string]interface{}` with `map[string]any`
- [x] Replace all `interface{}` with `any` in function signatures and type definitions
- [x] Update sync.Pool New function returns from `interface{}` to `any`
- [x] Add package documentation comments to 8 package files
- [x] Update type assertions and casts to work with `any` type
55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
package libpack_logger
|
|
|
|
import (
|
|
"bytes"
|
|
"sync"
|
|
"testing"
|
|
)
|
|
|
|
// Test_LogConcurrentAccess verifies that the logger correctly handles concurrent access
|
|
// without race conditions
|
|
func TestLogConcurrentAccess(t *testing.T) {
|
|
output := &bytes.Buffer{}
|
|
logger := New().SetOutput(output).SetMinLogLevel(LEVEL_DEBUG)
|
|
|
|
// Number of concurrent goroutines
|
|
numGoroutines := 100
|
|
// Wait group to synchronize goroutines
|
|
var wg sync.WaitGroup
|
|
wg.Add(numGoroutines)
|
|
|
|
// Launch multiple goroutines to log concurrently
|
|
for i := 0; i < numGoroutines; i++ {
|
|
go func(id int) {
|
|
defer wg.Done()
|
|
msg := &LogMessage{
|
|
Message: "concurrent log test",
|
|
Pairs: map[string]any{
|
|
"goroutine_id": id,
|
|
},
|
|
}
|
|
// Use different log levels to test all paths
|
|
switch id % 5 {
|
|
case 0:
|
|
logger.Debug(msg)
|
|
case 1:
|
|
logger.Info(msg)
|
|
case 2:
|
|
logger.Warn(msg)
|
|
case 3:
|
|
logger.Error(msg)
|
|
case 4:
|
|
logger.Fatal(msg)
|
|
}
|
|
}(i)
|
|
}
|
|
|
|
// Wait for all goroutines to complete
|
|
wg.Wait()
|
|
|
|
// If we make it here without a race detector failure, the test passes
|
|
if output.Len() == 0 {
|
|
t.Error("Expected log output, but got none")
|
|
}
|
|
}
|