fixed Fiber IP security and cleanup code

This commit is contained in:
Turbootzz committed 2025-10-24 21:20:29 +02:00
1 parent 8cea6d1f8c
commit 70481d0350
11 files changed
+87 -366

No files matched your search

+1 -31
View File
@@ -1,10 +1,10 @@
// Package logger provides structured logging for the application
package logger
import (
"io"
"log"
"os"
"strings"
)
var (
@@ -29,33 +29,3 @@ func init() {
Warn = log.New(os.Stdout, "WARN: ", log.Ldate|log.Ltime|log.Lshortfile)
Error = log.New(os.Stderr, "ERROR: ", log.Ldate|log.Ltime|log.Lshortfile)
}
// Sanitize removes sensitive data from log messages
// This prevents accidental logging of secrets, tokens, or API keys
func Sanitize(msg string) string {
// List of sensitive keywords to redact
sensitive := []string{"token", "key", "password", "secret", "apikey", "bearer"}
lower := strings.ToLower(msg)
for _, keyword := range sensitive {
if strings.Contains(lower, keyword) {
return "[REDACTED - Contains sensitive data]"
}
}
return msg
}
// InfoSafe logs an info message after sanitizing it
func InfoSafe(format string, v ...interface{}) {
Info.Printf(Sanitize(format), v...)
}
// WarnSafe logs a warning message after sanitizing it
func WarnSafe(format string, v ...interface{}) {
Warn.Printf(Sanitize(format), v...)
}
// ErrorSafe logs an error message after sanitizing it
func ErrorSafe(format string, v ...interface{}) {
Error.Printf(Sanitize(format), v...)
}