From 356510aa541842909c255c49e37991271d8516cb Mon Sep 17 00:00:00 2001 From: Roland Bracewell Shoemaker Date: Mon, 15 Jun 2020 10:33:28 -0700 Subject: [PATCH] cmd/bad-key-revoker: don't skip certificates where the account has no contacts (#4872) --- cmd/bad-key-revoker/main.go | 10 +++++++--- cmd/bad-key-revoker/main_test.go | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cmd/bad-key-revoker/main.go b/cmd/bad-key-revoker/main.go index 1a4c39f52..e2b593720 100644 --- a/cmd/bad-key-revoker/main.go +++ b/cmd/bad-key-revoker/main.go @@ -153,15 +153,19 @@ func (bkr *badKeyRevoker) resolveContacts(ids []int64) (map[int64][]string, erro } err := bkr.dbMap.SelectOne(&emails, "SELECT contact FROM registrations WHERE id = ?", id) if err != nil { - if db.IsNoRows(err) { - continue - } + // ErrNoRows is not acceptable here since there should always be a + // row for the registration, even if there are no contacts return nil, err } if len(emails.Contact) != 0 { for _, email := range emails.Contact { idToEmail[id] = append(idToEmail[id], strings.TrimPrefix(email, "mailto:")) } + } else { + // if the account has no contacts add a placeholder empty contact + // so that we don't skip any certificates + idToEmail[id] = append(idToEmail[id], "") + continue } } return idToEmail, nil diff --git a/cmd/bad-key-revoker/main_test.go b/cmd/bad-key-revoker/main_test.go index 54c6f810d..4e7cb8595 100644 --- a/cmd/bad-key-revoker/main_test.go +++ b/cmd/bad-key-revoker/main_test.go @@ -145,7 +145,7 @@ func TestFindUnrevoked(t *testing.T) { test.AssertNotError(t, err, "failed setting up db client") defer test.ResetSATestDatabase(t)() - regID := insertRegistration(t, dbMap, "") + regID := insertRegistration(t, dbMap) bkr := &badKeyRevoker{dbMap: dbMap, serialBatchSize: 1, maxRevocations: 10} @@ -177,12 +177,12 @@ func TestResolveContacts(t *testing.T) { bkr := &badKeyRevoker{dbMap: dbMap} - regIDA := insertRegistration(t, dbMap, "") + regIDA := insertRegistration(t, dbMap) regIDB := insertRegistration(t, dbMap, "example.com", "example-2.com") regIDC := insertRegistration(t, dbMap, "example.com") regIDD := insertRegistration(t, dbMap, "example-2.com") - idToEmail, err := bkr.resolveContacts([]int64{0, regIDA, regIDB, regIDC, regIDD}) + idToEmail, err := bkr.resolveContacts([]int64{regIDA, regIDB, regIDC, regIDD}) test.AssertNotError(t, err, "resolveContacts failed") test.AssertDeepEquals(t, idToEmail, map[int64][]string{ regIDA: {""}, @@ -254,7 +254,7 @@ func TestInvoke(t *testing.T) { regIDA := insertRegistration(t, dbMap, "example.com") regIDB := insertRegistration(t, dbMap, "example.com") regIDC := insertRegistration(t, dbMap, "other.example.com", "uno.example.com") - regIDD := insertRegistration(t, dbMap, "") + regIDD := insertRegistration(t, dbMap) hashA := randHash(t) insertBlockedRow(t, dbMap, hashA, regIDC, false) insertCert(t, dbMap, hashA, "ff", regIDA, false, false)