Skip to content

Commit

Permalink
ratelimits: Remove legacy registrations per IP implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
beautifulentropy committed Oct 18, 2024
1 parent d0c9aa3 commit 884dc1f
Show file tree
Hide file tree
Showing 24 changed files with 1,102 additions and 1,950 deletions.
33 changes: 13 additions & 20 deletions cmd/contact-auditor/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package notmain
import (
"context"
"fmt"
"net"
"os"
"strings"
"testing"
Expand Down Expand Up @@ -133,37 +132,31 @@ func (tc testCtx) addRegistrations(t *testing.T) {
"e":"AQAB"
}`)

initialIP, err := net.ParseIP("127.0.0.1").MarshalText()
test.AssertNotError(t, err, "Couldn't create initialIP")

regA = &corepb.Registration{
Id: 1,
Contact: []string{emailA},
Key: jsonKeyA,
InitialIP: initialIP,
Id: 1,
Contact: []string{emailA},
Key: jsonKeyA,
}
regB = &corepb.Registration{
Id: 2,
Contact: []string{emailB},
Key: jsonKeyB,
InitialIP: initialIP,
Id: 2,
Contact: []string{emailB},
Key: jsonKeyB,
}
regC = &corepb.Registration{
Id: 3,
Contact: []string{emailC},
Key: jsonKeyC,
InitialIP: initialIP,
Id: 3,
Contact: []string{emailC},
Key: jsonKeyC,
}
// Reg D has a `tel:` contact ACME URL
regD = &corepb.Registration{
Id: 4,
Contact: []string{tel},
Key: jsonKeyD,
InitialIP: initialIP,
Id: 4,
Contact: []string{tel},
Key: jsonKeyD,
}

// Add the four test registrations
ctx := context.Background()
var err error
regA, err = tc.ssa.NewRegistration(ctx, regA)
test.AssertNotError(t, err, "Couldn't store regA")
regB, err = tc.ssa.NewRegistration(ctx, regB)
Expand Down
17 changes: 3 additions & 14 deletions cmd/expiration-mailer/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"errors"
"fmt"
"math/big"
"net"
"strings"
"testing"
"text/template"
Expand Down Expand Up @@ -462,20 +461,10 @@ func TestFindExpiringCertificates(t *testing.T) {
}

func makeRegistration(sac sapb.StorageAuthorityClient, id int64, jsonKey []byte, contacts []string) (*corepb.Registration, error) {
var ip [4]byte
_, err := rand.Reader.Read(ip[:])
if err != nil {
return nil, err
}
ipText, err := net.IP(ip[:]).MarshalText()
if err != nil {
return nil, fmt.Errorf("formatting IP address: %s", err)
}
reg, err := sac.NewRegistration(context.Background(), &corepb.Registration{
Id: id,
Contact: contacts,
Key: jsonKey,
InitialIP: ipText,
Id: id,
Contact: contacts,
Key: jsonKey,
})
if err != nil {
return nil, fmt.Errorf("storing registration: %s", err)
Expand Down
33 changes: 13 additions & 20 deletions cmd/id-exporter/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"encoding/base64"
"fmt"
"math/big"
"net"
"os"
"testing"
"time"
Expand Down Expand Up @@ -276,38 +275,32 @@ func (tc testCtx) addRegistrations(t *testing.T) {
"e":"AQAB"
}`)

initialIP, err := net.ParseIP("127.0.0.1").MarshalText()
test.AssertNotError(t, err, "Couldn't create initialIP")

// Regs A through C have `mailto:` contact ACME URL's
regA = &corepb.Registration{
Id: 1,
Contact: []string{emailA},
Key: jsonKeyA,
InitialIP: initialIP,
Id: 1,
Contact: []string{emailA},
Key: jsonKeyA,
}
regB = &corepb.Registration{
Id: 2,
Contact: []string{emailB},
Key: jsonKeyB,
InitialIP: initialIP,
Id: 2,
Contact: []string{emailB},
Key: jsonKeyB,
}
regC = &corepb.Registration{
Id: 3,
Contact: []string{emailC},
Key: jsonKeyC,
InitialIP: initialIP,
Id: 3,
Contact: []string{emailC},
Key: jsonKeyC,
}
// Reg D has a `tel:` contact ACME URL
regD = &corepb.Registration{
Id: 4,
Contact: []string{tel},
Key: jsonKeyD,
InitialIP: initialIP,
Id: 4,
Contact: []string{tel},
Key: jsonKeyD,
}

// Add the four test registrations
ctx := context.Background()
var err error
regA, err = tc.ssa.NewRegistration(ctx, regA)
test.AssertNotError(t, err, "Couldn't store regA")
regB, err = tc.ssa.NewRegistration(ctx, regB)
Expand Down
3 changes: 0 additions & 3 deletions core/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ type Registration struct {
// Agreement with terms of service
Agreement string `json:"agreement,omitempty"`

// InitialIP is the IP address from which the registration was created
InitialIP net.IP `json:"initialIp"`

// CreatedAt is the time the registration was created.
CreatedAt *time.Time `json:"createdAt,omitempty"`

Expand Down
132 changes: 61 additions & 71 deletions core/proto/core.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion core/proto/core.proto
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ message Registration {
repeated string contact = 3;
bool contactsPresent = 4;
string agreement = 5;
bytes initialIP = 6;
reserved 7; // Previously createdAtNS
google.protobuf.Timestamp createdAt = 9;
string status = 8;
Expand Down
8 changes: 4 additions & 4 deletions db/map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestTableFromQuery(t *testing.T) {
expectedTable string
}{
{
query: "SELECT id, jwk, jwk_sha256, contact, agreement, initialIP, createdAt, LockCol, status FROM registrations WHERE jwk_sha256 = ?",
query: "SELECT id, jwk, jwk_sha256, contact, agreement, createdAt, LockCol, status FROM registrations WHERE jwk_sha256 = ?",
expectedTable: "registrations",
},
{
Expand All @@ -134,15 +134,15 @@ func TestTableFromQuery(t *testing.T) {
expectedTable: "authz2",
},
{
query: "insert into `registrations` (`id`,`jwk`,`jw k_sha256`,`contact`,`agreement`,`initialIp`,`createdAt`,`LockCol`,`status`) values (null,?,?,?,?,?,?,?,?);",
query: "insert into `registrations` (`id`,`jwk`,`jw k_sha256`,`contact`,`agreement`,`createdAt`,`LockCol`,`status`) values (null,?,?,?,?,?,?,?,?);",
expectedTable: "`registrations`",
},
{
query: "update `registrations` set `jwk`=?, `jwk_sh a256`=?, `contact`=?, `agreement`=?, `initialIp`=?, `createdAt`=?, `LockCol` =?, `status`=? where `id`=? and `LockCol`=?;",
query: "update `registrations` set `jwk`=?, `jwk_sh a256`=?, `contact`=?, `agreement`=?, `createdAt`=?, `LockCol` =?, `status`=? where `id`=? and `LockCol`=?;",
expectedTable: "`registrations`",
},
{
query: "SELECT COUNT(*) FROM registrations WHERE initialIP = ? AND ? < createdAt AND createdAt <= ?",
query: "SELECT COUNT(*) FROM registrations WHERE ? < createdAt AND createdAt <= ?",
expectedTable: "registrations",
},
{
Expand Down
Loading

0 comments on commit 884dc1f

Please sign in to comment.