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
+5 -5
View File
@@ -81,7 +81,7 @@ func (rb *RetryBudget) AllowRetry() bool {
if rb.logger != nil {
rb.logger.Debug(&libpack_logger.LogMessage{
Message: "Retry denied: budget exhausted",
Pairs: map[string]interface{}{
Pairs: map[string]any{
"current_tokens": current,
"denied_count": rb.deniedRetries.Load(),
},
@@ -150,7 +150,7 @@ func (rb *RetryBudget) refill() {
}
// GetStats returns current statistics
func (rb *RetryBudget) GetStats() map[string]interface{} {
func (rb *RetryBudget) GetStats() map[string]any {
totalAttempts := rb.totalAttempts.Load()
allowedRetries := rb.allowedRetries.Load()
deniedRetries := rb.deniedRetries.Load()
@@ -160,7 +160,7 @@ func (rb *RetryBudget) GetStats() map[string]interface{} {
denialRate = float64(deniedRetries) / float64(totalAttempts) * 100
}
return map[string]interface{}{
return map[string]any{
"enabled": rb.enabled,
"current_tokens": rb.currentTokens.Load(),
"max_tokens": rb.maxTokens,
@@ -195,7 +195,7 @@ func (rb *RetryBudget) UpdateConfig(config RetryBudgetConfig) {
if rb.logger != nil {
rb.logger.Info(&libpack_logger.LogMessage{
Message: "Retry budget configuration updated",
Pairs: map[string]interface{}{
Pairs: map[string]any{
"tokens_per_sec": config.TokensPerSecond,
"max_tokens": config.MaxTokens,
"enabled": config.Enabled,
@@ -222,7 +222,7 @@ func InitializeRetryBudgetWithContext(ctx context.Context, config RetryBudgetCon
if logger != nil && config.Enabled {
logger.Info(&libpack_logger.LogMessage{
Message: "Retry budget initialized",
Pairs: map[string]interface{}{
Pairs: map[string]any{
"tokens_per_sec": config.TokensPerSecond,
"max_tokens": config.MaxTokens,
},