mirror of
https://github.com/lukaszraczylo/graphql-monitoring-proxy.git
synced 2026-06-05 23:03:48 +00:00
chore(security,refactor): extract sanitization and improve code quality (#41)
* 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
This commit is contained in:
+8
-11
@@ -56,7 +56,7 @@ func (bhm *BackendHealthManager) WaitForBackendReady(timeout time.Duration) erro
|
||||
|
||||
bhm.logger.Info(&libpack_logger.LogMessage{
|
||||
Message: "Waiting for GraphQL backend to become ready",
|
||||
Pairs: map[string]interface{}{
|
||||
Pairs: map[string]any{
|
||||
"backend_url": bhm.backendURL,
|
||||
"timeout": timeout.String(),
|
||||
},
|
||||
@@ -70,7 +70,7 @@ func (bhm *BackendHealthManager) WaitForBackendReady(timeout time.Duration) erro
|
||||
bhm.mu.Unlock()
|
||||
bhm.logger.Info(&libpack_logger.LogMessage{
|
||||
Message: "GraphQL backend is ready",
|
||||
Pairs: map[string]interface{}{
|
||||
Pairs: map[string]any{
|
||||
"retry_count": retryCount,
|
||||
"time_taken": time.Since(deadline.Add(-timeout)).String(),
|
||||
},
|
||||
@@ -83,7 +83,7 @@ func (bhm *BackendHealthManager) WaitForBackendReady(timeout time.Duration) erro
|
||||
if retryCount%5 == 0 {
|
||||
bhm.logger.Warning(&libpack_logger.LogMessage{
|
||||
Message: "Still waiting for GraphQL backend",
|
||||
Pairs: map[string]interface{}{
|
||||
Pairs: map[string]any{
|
||||
"retry_count": retryCount,
|
||||
"time_remaining": time.Until(deadline).String(),
|
||||
},
|
||||
@@ -185,7 +185,7 @@ func (bhm *BackendHealthManager) checkBackendHealth() bool {
|
||||
if err != nil {
|
||||
bhm.logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Backend health check failed",
|
||||
Pairs: map[string]interface{}{
|
||||
Pairs: map[string]any{
|
||||
"error": err.Error(),
|
||||
"check_url": healthCheckURL,
|
||||
},
|
||||
@@ -199,7 +199,7 @@ func (bhm *BackendHealthManager) checkBackendHealth() bool {
|
||||
if !isHealthy {
|
||||
bhm.logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Backend returned unhealthy status",
|
||||
Pairs: map[string]interface{}{
|
||||
Pairs: map[string]any{
|
||||
"status_code": statusCode,
|
||||
"check_url": healthCheckURL,
|
||||
},
|
||||
@@ -226,14 +226,11 @@ func (bhm *BackendHealthManager) updateHealthStatus(isHealthy bool) {
|
||||
if !previouslyHealthy {
|
||||
bhm.logger.Info(&libpack_logger.LogMessage{
|
||||
Message: "GraphQL backend recovered",
|
||||
Pairs: map[string]interface{}{
|
||||
Pairs: map[string]any{
|
||||
"consecutive_failures": bhm.consecutiveFails.Load(),
|
||||
},
|
||||
})
|
||||
// Trigger circuit breaker reset if needed
|
||||
if cfg != nil && cfg.CircuitBreaker.Enable && cb != nil {
|
||||
// The circuit breaker will automatically reset based on its timeout
|
||||
}
|
||||
// Note: Circuit breaker resets automatically based on its configured timeout
|
||||
}
|
||||
bhm.consecutiveFails.Store(0)
|
||||
} else {
|
||||
@@ -241,7 +238,7 @@ func (bhm *BackendHealthManager) updateHealthStatus(isHealthy bool) {
|
||||
if previouslyHealthy {
|
||||
bhm.logger.Warning(&libpack_logger.LogMessage{
|
||||
Message: "GraphQL backend became unhealthy",
|
||||
Pairs: map[string]interface{}{
|
||||
Pairs: map[string]any{
|
||||
"consecutive_failures": fails,
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user