Warn on empty string in whitelist

This commit is contained in:
AJ ONeal 2019-04-17 17:08:53 -06:00
parent 671ea1250d
commit 6fc75632c8
2 changed files with 7 additions and 1 deletions

View File

@ -409,6 +409,10 @@ func NewWhitelist(issuers []string, privateList ...[]string) (Whitelist, error)
func newWhitelist(list []*url.URL, issuers []string, insecure bool) (Whitelist, error) {
for i := range issuers {
iss := issuers[i]
if "" == strings.TrimSpace(iss) {
fmt.Println("[Warning] You have an empty string in your keyfetch whitelist.")
continue
}
// Should have a valid http or https prefix
// TODO support custom prefixes (i.e. app://) ?

View File

@ -20,7 +20,9 @@ func TestInvalidIssuer(t *testing.T) {
}
func TestIssuerMatches(t *testing.T) {
// because [""] = strings.Split(os.Getenv("DOESNTEXIST"), ",")
trusted := []string{
"",
"https://example.com/",
"foobar.net/def/",
"https://*.wild.org",
@ -41,7 +43,7 @@ func TestIssuerMatches(t *testing.T) {
t.Fatal(err)
}
// Combo list
list, err = NewWhitelist(trusted, privates)
list, err = NewWhitelist(trusted[1:], privates)
if nil != err {
t.Fatal(err)
}