Skip to content

Commit

Permalink
* Fix secrets config mapping for HIBP
Browse files Browse the repository at this point in the history
* Prevent nil pointer dereference in ConfigureSecret()

Signed-off-by: Chris Cummer <[email protected]>
  • Loading branch information
senorprogrammer committed May 2, 2020
1 parent 2462789 commit 79d3787
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion cfg/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ func ConfigureSecret(
secret *string, // unfortunate order dependency...
) {
notWanted := func(out *string) bool {
return out == nil && *out != ""
if out == nil {
return false
}

return *out != ""
}

// Don't try to fetch from cred store if nothing is wanted.
Expand Down
3 changes: 2 additions & 1 deletion modules/hibp/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
globalConfig,
"https://haveibeenpwned.com/api",
"",
&settings.apiKey,
nil,
&settings.apiKey,
)

settings.colors.ok = ymlConfig.UString("colors.ok", "white")
settings.colors.pwned = ymlConfig.UString("colors.pwned", "red")

Expand Down

0 comments on commit 79d3787

Please sign in to comment.