- Implemented CrowdSec configuration page with import/export capabilities. - Added API endpoints for exporting, importing, listing, reading, and writing CrowdSec configuration files. - Enhanced security handler to support runtime overrides for CrowdSec mode and API URL. - Updated frontend components to include CrowdSec settings in the UI. - Added tests for CrowdSec configuration management and security handler behavior. - Improved user experience with toast notifications for successful operations and error handling.
21 lines
500 B
Go
21 lines
500 B
Go
package handlers
|
|
|
|
import (
|
|
"regexp"
|
|
"strings"
|
|
)
|
|
|
|
// sanitizeForLog removes control characters and newlines from user content before logging.
|
|
func sanitizeForLog(s string) string {
|
|
if s == "" {
|
|
return s
|
|
}
|
|
// Replace CRLF and LF with spaces and remove other control chars
|
|
s = strings.ReplaceAll(s, "\r\n", " ")
|
|
s = strings.ReplaceAll(s, "\n", " ")
|
|
// remove any other non-printable control characters
|
|
re := regexp.MustCompile(`[\x00-\x1F\x7F]+`)
|
|
s = re.ReplaceAllString(s, " ")
|
|
return s
|
|
}
|