mattermost-community-enterp.../vendor/github.com/splitio/go-toolkit/v5/logging/functions.go
Claude ec1f89217a Merge: Complete Mattermost Server with Community Enterprise
Full Mattermost server source with integrated Community Enterprise features.
Includes vendor directory for offline/air-gapped builds.

Structure:
- enterprise-impl/: Enterprise feature implementations
- enterprise-community/: Init files that register implementations
- enterprise/: Bridge imports (community_imports.go)
- vendor/: All dependencies for offline builds

Build (online):
  go build ./cmd/mattermost

Build (offline/air-gapped):
  go build -mod=vendor ./cmd/mattermost

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-17 23:59:07 +09:00

34 lines
830 B
Go

package logging
import (
"fmt"
"net/http"
"regexp"
"strings"
)
// ObfuscateAPIKey obfucate part of api key
func ObfuscateAPIKey(apikey string) string {
obfuscationIndex := 80
total := len(apikey)
charsToObfuscate := obfuscationIndex * total / 100
toShow := (total - charsToObfuscate) / 2
return strings.Join([]string{apikey[:toShow], apikey[len(apikey)-toShow:]}, "...")
}
// ObfuscateHTTPHeader obfuscates sensitive data into headers
func ObfuscateHTTPHeader(headers http.Header) string {
var re = regexp.MustCompile(`Authorization:\[Bearer ([0-9|a-z|A-Z|\s]*)\]`)
var str = fmt.Sprint(headers)
match := re.FindStringSubmatch(str)
if len(match) == 2 {
str = strings.Replace(str, match[1], ObfuscateAPIKey(match[1]), 1)
return fmt.Sprint("[REQUEST_HEADERS]", str, "[END_REQUEST_HEADERS]")
}
return str
}