mirror of
https://github.com/lukaszraczylo/graphql-monitoring-proxy.git
synced 2026-10-19 06:27:38 +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:
@@ -29,15 +29,15 @@ const (
|
||||
|
||||
// ProxyError represents a structured error response
|
||||
type ProxyError struct {
|
||||
Code string `json:"code"` // Machine-readable error code
|
||||
Message string `json:"message"` // Human-readable error message
|
||||
Details string `json:"details,omitempty"` // Additional error details
|
||||
Retryable bool `json:"retryable"` // Whether the request can be retried
|
||||
StatusCode int `json:"status_code"` // HTTP status code
|
||||
Timestamp time.Time `json:"timestamp"` // When the error occurred
|
||||
TraceID string `json:"trace_id,omitempty"` // Trace ID for correlation
|
||||
Metadata map[string]interface{} `json:"metadata,omitempty"` // Additional context
|
||||
Cause error `json:"-"` // Original error (not serialized)
|
||||
Code string `json:"code"` // Machine-readable error code
|
||||
Message string `json:"message"` // Human-readable error message
|
||||
Details string `json:"details,omitempty"` // Additional error details
|
||||
Retryable bool `json:"retryable"` // Whether the request can be retried
|
||||
StatusCode int `json:"status_code"` // HTTP status code
|
||||
Timestamp time.Time `json:"timestamp"` // When the error occurred
|
||||
TraceID string `json:"trace_id,omitempty"` // Trace ID for correlation
|
||||
Metadata map[string]any `json:"metadata,omitempty"` // Additional context
|
||||
Cause error `json:"-"` // Original error (not serialized)
|
||||
}
|
||||
|
||||
// Error implements the error interface
|
||||
@@ -78,7 +78,7 @@ func NewProxyError(code, message string, statusCode int, retryable bool) *ProxyE
|
||||
StatusCode: statusCode,
|
||||
Retryable: retryable,
|
||||
Timestamp: time.Now(),
|
||||
Metadata: make(map[string]interface{}),
|
||||
Metadata: make(map[string]any),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ func (e *ProxyError) WithTraceID(traceID string) *ProxyError {
|
||||
}
|
||||
|
||||
// WithMetadata adds metadata
|
||||
func (e *ProxyError) WithMetadata(key string, value interface{}) *ProxyError {
|
||||
func (e *ProxyError) WithMetadata(key string, value any) *ProxyError {
|
||||
e.Metadata[key] = value
|
||||
return e
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user