applySanitizePattern removes or replaces characters not in the allowed set. When the caller has requested preservation of special chars, unwanted chars are replaced with hyphens; otherwise they are removed entirely.
(result, allowedChars string, preserveSpecialChars bool)
| 158 | // When the caller has requested preservation of special chars, unwanted chars are |
| 159 | // replaced with hyphens; otherwise they are removed entirely. |
| 160 | func applySanitizePattern(result, allowedChars string, preserveSpecialChars bool) string { |
| 161 | pattern, ok := sanitizePatterns[allowedChars] |
| 162 | if !ok { |
| 163 | pattern = regexp.MustCompile(`[^` + allowedChars + `]+`) |
| 164 | } |
| 165 | if preserveSpecialChars { |
| 166 | return pattern.ReplaceAllString(result, "-") |
| 167 | } |
| 168 | return pattern.ReplaceAllString(result, "") |
| 169 | } |
| 170 | |
| 171 | // SanitizeErrorMessage removes potential secret key names from error messages to prevent |
| 172 | // information disclosure via logs. This prevents exposing details about an organization's |
no test coverage detected