Skip to content

Commit

Permalink
fix(NR-185554): obfuscate wrong license key
Browse files Browse the repository at this point in the history
  • Loading branch information
DavSanchez committed Dec 20, 2023
1 parent 0fc94f6 commit 9eb3c0e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ var (
ErrNoDatabindSources = fmt.Errorf("no databind sources provided")
ErrUnexpectedVariablesAmount = fmt.Errorf("unexpected config file variables replacement amount")
ErrUnexpectedVariablesType = fmt.Errorf("unexpected config file variables replacement type")
ErrInvalidLicense = fmt.Errorf("invalid license, check agent's config file or NRIA_LICENSE_KEY environment variable")
clog = log.WithComponent("Configuration")
)

Expand Down Expand Up @@ -2090,7 +2091,9 @@ func NormalizeConfig(cfg *Config, cfgMetadata config_loader.YAMLMetadata) (err e

cfg.License = strings.TrimSpace(cfg.License)
if !license.IsValid(cfg.License) {
err = fmt.Errorf("invalid license: %s, check agent's config file or NRIA_LICENSE_KEY environment variable", cfg.License)
const preservedLength = 10
obfuscatedL := cfg.License[:preservedLength] + strings.Repeat("*", len(cfg.License)-preservedLength)
err = fmt.Errorf("%w: %s", ErrInvalidLicense, obfuscatedL)
return
}

Expand Down

0 comments on commit 9eb3c0e

Please # to comment.