mirror of
https://github.com/project-zot/zot.git
synced 2026-06-15 11:37:56 +08:00
chore: optimize sanitize field normalization
This commit is contained in:
committed by
GitHub
parent
cea72a4c08
commit
60f719400e
@@ -23,6 +23,7 @@ import (
|
||||
var (
|
||||
openIDSupportedProviders = [...]string{"google", "gitlab", "oidc"} //nolint: gochecknoglobals
|
||||
oauth2SupportedProviders = [...]string{"github"} //nolint: gochecknoglobals
|
||||
sensitiveFieldNormalizer = strings.NewReplacer("_", "", "-", "") //nolint: gochecknoglobals
|
||||
)
|
||||
|
||||
const redactedSecret = "******"
|
||||
@@ -934,7 +935,7 @@ func redactSecretsInMap(values map[string]any) {
|
||||
}
|
||||
|
||||
func isSensitiveFieldName(fieldName string) bool {
|
||||
normalized := strings.NewReplacer("_", "", "-", "").Replace(strings.ToLower(fieldName))
|
||||
normalized := sensitiveFieldNormalizer.Replace(strings.ToLower(fieldName))
|
||||
|
||||
switch normalized {
|
||||
case "accesskey", "secretkey", "clientsecret", "password", "token", "authorization",
|
||||
|
||||
Reference in New Issue
Block a user