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:
2026-01-17 00:04:12 +00:00
committed by GitHub
parent caeae62236
commit 3aa83d4480
42 changed files with 815 additions and 618 deletions
+7 -7
View File
@@ -118,7 +118,7 @@ func (cpm *ConnectionPoolManager) cleanIdleConnections() {
if cpm.logger != nil {
cpm.logger.Debug(&libpack_logging.LogMessage{
Message: "Cleaned idle HTTP connections",
Pairs: map[string]interface{}{
Pairs: map[string]any{
"active_connections": cpm.activeConnections.Load(),
"total_connections": cpm.totalConnections.Load(),
},
@@ -172,7 +172,7 @@ func (cpm *ConnectionPoolManager) performKeepAlive() {
if cpm.logger != nil {
cpm.logger.Debug(&libpack_logging.LogMessage{
Message: "Keep-alive request failed",
Pairs: map[string]interface{}{
Pairs: map[string]any{
"error": err.Error(),
},
})
@@ -202,7 +202,7 @@ func (cpm *ConnectionPoolManager) checkAndRecover() {
if cpm.logger != nil {
cpm.logger.Warning(&libpack_logging.LogMessage{
Message: "Connection pool health degraded, attempting recovery",
Pairs: map[string]interface{}{
Pairs: map[string]any{
"consecutive_failures": failures,
},
})
@@ -246,8 +246,8 @@ func (cpm *ConnectionPoolManager) RecordConnectionFailure() {
}
// GetConnectionStats returns current connection statistics
func (cpm *ConnectionPoolManager) GetConnectionStats() map[string]interface{} {
return map[string]interface{}{
func (cpm *ConnectionPoolManager) GetConnectionStats() map[string]any {
return map[string]any{
"active_connections": cpm.activeConnections.Load(),
"total_connections": cpm.totalConnections.Load(),
"connection_failures": cpm.connectionFailures.Load(),
@@ -296,7 +296,7 @@ func InitializeConnectionPool(client *fasthttp.Client) {
connectionPoolMutex.Lock()
defer connectionPoolMutex.Unlock()
if connectionPoolManager != nil {
connectionPoolManager.Shutdown()
_ = connectionPoolManager.Shutdown() // Best-effort cleanup
}
connectionPoolManager = NewConnectionPoolManager(client)
}
@@ -306,7 +306,7 @@ func ShutdownConnectionPool() {
connectionPoolMutex.Lock()
defer connectionPoolMutex.Unlock()
if connectionPoolManager != nil {
connectionPoolManager.Shutdown()
_ = connectionPoolManager.Shutdown() // Best-effort cleanup
connectionPoolManager = nil
}
}