Skip to content

Commit 981a78a

Browse files
authored
Remove dead code (#8506)
This started with noticing the semaphore package (forked for use in OCSP) was dead. That followed by using the golang `deadcode` tool and Goland's various "Unused ..." inspection tools to find other dead code. Nothing in here looks like it would be used externally to Boulder, as far as I can tell.
1 parent 9564684 commit 981a78a

File tree

17 files changed

+3
-1084
lines changed

17 files changed

+3
-1084
lines changed

core/challenges.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package core
22

3-
import "fmt"
4-
53
func newChallenge(challengeType AcmeChallenge, token string) Challenge {
64
return Challenge{
75
Type: challengeType,
@@ -29,20 +27,3 @@ func TLSALPNChallenge01(token string) Challenge {
2927
func DNSAccountChallenge01(token string) Challenge {
3028
return newChallenge(ChallengeTypeDNSAccount01, token)
3129
}
32-
33-
// NewChallenge constructs a challenge of the given kind. It returns an
34-
// error if the challenge type is unrecognized.
35-
func NewChallenge(kind AcmeChallenge, token string) (Challenge, error) {
36-
switch kind {
37-
case ChallengeTypeHTTP01:
38-
return HTTPChallenge01(token), nil
39-
case ChallengeTypeDNS01:
40-
return DNSChallenge01(token), nil
41-
case ChallengeTypeTLSALPN01:
42-
return TLSALPNChallenge01(token), nil
43-
case ChallengeTypeDNSAccount01:
44-
return DNSAccountChallenge01(token), nil
45-
default:
46-
return Challenge{}, fmt.Errorf("unrecognized challenge type %q", kind)
47-
}
48-
}

core/objects.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,6 @@ const (
3333
StatusDeactivated = AcmeStatus("deactivated") // Object has been deactivated
3434
)
3535

36-
// AcmeResource values identify different types of ACME resources
37-
type AcmeResource string
38-
39-
// The types of ACME resources
40-
const (
41-
ResourceNewReg = AcmeResource("new-reg")
42-
ResourceNewAuthz = AcmeResource("new-authz")
43-
ResourceNewCert = AcmeResource("new-cert")
44-
ResourceRevokeCert = AcmeResource("revoke-cert")
45-
ResourceRegistration = AcmeResource("reg")
46-
ResourceChallenge = AcmeResource("challenge")
47-
ResourceAuthz = AcmeResource("authz")
48-
ResourceKeyChange = AcmeResource("key-change")
49-
)
50-
5136
// AcmeChallenge values identify different types of ACME challenges
5237
type AcmeChallenge string
5338

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ require (
3838
go.opentelemetry.io/otel/trace v1.38.0
3939
golang.org/x/crypto v0.44.0
4040
golang.org/x/net v0.47.0
41-
golang.org/x/sync v0.18.0
4241
golang.org/x/term v0.37.0
4342
golang.org/x/text v0.31.0
4443
golang.org/x/time v0.11.0
@@ -86,6 +85,7 @@ require (
8685
go.opentelemetry.io/otel/metric v1.38.0 // indirect
8786
go.opentelemetry.io/proto/otlp v1.7.1 // indirect
8887
golang.org/x/mod v0.29.0 // indirect
88+
golang.org/x/sync v0.18.0 // indirect
8989
golang.org/x/sys v0.38.0 // indirect
9090
golang.org/x/tools v0.38.0 // indirect
9191
google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 // indirect

grpc/internal/resolver/dns/dns_resolver_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ func TestMain(m *testing.M) {
4848
}
4949

5050
const (
51-
txtBytesLimit = 255
5251
defaultTestTimeout = 10 * time.Second
5352
defaultTestShortTimeout = 10 * time.Millisecond
5453
)

log/mock.go

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"log/syslog"
66
"regexp"
77
"strings"
8-
"time"
98
)
109

1110
// UseMock sets a mock logger as the default logger, and returns it.
@@ -20,13 +19,6 @@ func NewMock() *Mock {
2019
return &Mock{impl{newMockWriter()}}
2120
}
2221

23-
// NewWaitingMock creates a mock logger implementing the writer interface.
24-
// It stores all logged messages in a buffer for inspection by test
25-
// functions.
26-
func NewWaitingMock() *WaitingMock {
27-
return &WaitingMock{impl{newWaitingMockWriter()}}
28-
}
29-
3022
// Mock is a logger that stores all log messages in memory to be examined by a
3123
// test.
3224
type Mock struct {
@@ -130,39 +122,3 @@ func (m *Mock) Clear() {
130122
w := m.w.(*mockWriter)
131123
w.clearChan <- struct{}{}
132124
}
133-
134-
type waitingMockWriter struct {
135-
logChan chan string
136-
}
137-
138-
// newWaitingMockWriter returns a new waitingMockWriter
139-
func newWaitingMockWriter() *waitingMockWriter {
140-
logChan := make(chan string, 1000)
141-
return &waitingMockWriter{
142-
logChan,
143-
}
144-
}
145-
146-
func (m *waitingMockWriter) logAtLevel(p syslog.Priority, msg string, a ...any) {
147-
m.logChan <- fmt.Sprintf("%s: %s", levelName[p&7], fmt.Sprintf(msg, a...))
148-
}
149-
150-
// WaitForMatch returns the first log line matching a regex. It accepts a
151-
// regexp string and timeout. If the timeout value is met before the
152-
// matching pattern is read from the channel, an error is returned.
153-
func (m *WaitingMock) WaitForMatch(reString string, timeout time.Duration) (string, error) {
154-
w := m.w.(*waitingMockWriter)
155-
deadline := time.After(timeout)
156-
re := regexp.MustCompile(reString)
157-
for {
158-
select {
159-
case logLine := <-w.logChan:
160-
if re.MatchString(logLine) {
161-
close(w.logChan)
162-
return logLine, nil
163-
}
164-
case <-deadline:
165-
return "", fmt.Errorf("timeout waiting for match: %q", reString)
166-
}
167-
}
168-
}

mocks/sa.go

Lines changed: 0 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"context"
66
"crypto/x509"
77
"errors"
8-
"math/rand/v2"
98
"os"
109
"time"
1110

@@ -34,17 +33,6 @@ func NewStorageAuthorityReadOnly(clk clock.Clock) *StorageAuthorityReadOnly {
3433
return &StorageAuthorityReadOnly{clk}
3534
}
3635

37-
// StorageAuthority is a mock of sapb.StorageAuthorityClient
38-
type StorageAuthority struct {
39-
StorageAuthorityReadOnly
40-
}
41-
42-
// NewStorageAuthority creates a new mock storage authority
43-
// with the given clock.
44-
func NewStorageAuthority(clk clock.Clock) *StorageAuthority {
45-
return &StorageAuthority{StorageAuthorityReadOnly{clk}}
46-
}
47-
4836
const (
4937
test1KeyPublicJSON = `{"kty":"RSA","n":"yNWVhtYEKJR21y9xsHV-PD_bYwbXSeNuFal46xYxVfRL5mqha7vttvjB_vc7Xg2RvgCxHPCqoxgMPTzHrZT75LjCwIW2K_klBYN8oYvTwwmeSkAz6ut7ZxPv-nZaT5TJhGk0NT2kh_zSpdriEJ_3vW-mqxYbbBmpvHqsa1_zx9fSuHYctAZJWzxzUZXykbWMWQZpEiE0J4ajj51fInEzVn7VxV-mzfMyboQjujPh7aNJxAWSq4oQEJJDgWwSh9leyoJoPpONHxh5nEE5AjE01FkGICSxjpZsF-w8hOTI3XXohUdu29Se26k2B0PolDSuj0GIQU6-W9TdLXSjBb2SpQ","e":"AQAB"}`
5038
test2KeyPublicJSON = `{"kty":"RSA","n":"qnARLrT7Xz4gRcKyLdydmCr-ey9OuPImX4X40thk3on26FkMznR3fRjs66eLK7mmPcBZ6uOJseURU6wAaZNmemoYx1dMvqvWWIyiQleHSD7Q8vBrhR6uIoO4jAzJZR-ChzZuSDt7iHN-3xUVspu5XGwXU_MVJZshTwp4TaFx5elHIT_ObnTvTOU3Xhish07AbgZKmWsVbXh5s-CrIicU4OexJPgunWZ_YJJueOKmTvnLlTV4MzKR2oZlBKZ27S0-SfdV_QDx_ydle5oMAyKVtlAV35cyPMIsYNwgUGBCdY_2Uzi5eX0lTc7MPRwz6qR1kip-i59VcGcUQgqHV6Fyqw","e":"AQAB"}`
@@ -221,51 +209,21 @@ func (sa *StorageAuthorityReadOnly) SerialsForIncident(ctx context.Context, _ *s
221209
return &ServerStreamClient[sapb.IncidentSerial]{}, nil
222210
}
223211

224-
// SerialsForIncident is a mock
225-
func (sa *StorageAuthority) SerialsForIncident(ctx context.Context, _ *sapb.SerialsForIncidentRequest, _ ...grpc.CallOption) (sapb.StorageAuthority_SerialsForIncidentClient, error) {
226-
return &ServerStreamClient[sapb.IncidentSerial]{}, nil
227-
}
228-
229212
// CheckIdentifiersPaused is a mock
230213
func (sa *StorageAuthorityReadOnly) CheckIdentifiersPaused(_ context.Context, _ *sapb.PauseRequest, _ ...grpc.CallOption) (*sapb.Identifiers, error) {
231214
return nil, nil
232215
}
233216

234-
// CheckIdentifiersPaused is a mock
235-
func (sa *StorageAuthority) CheckIdentifiersPaused(_ context.Context, _ *sapb.PauseRequest, _ ...grpc.CallOption) (*sapb.Identifiers, error) {
236-
return nil, nil
237-
}
238-
239217
// GetPausedIdentifiers is a mock
240218
func (sa *StorageAuthorityReadOnly) GetPausedIdentifiers(_ context.Context, _ *sapb.RegistrationID, _ ...grpc.CallOption) (*sapb.Identifiers, error) {
241219
return nil, nil
242220
}
243221

244-
// GetPausedIdentifiers is a mock
245-
func (sa *StorageAuthority) GetPausedIdentifiers(_ context.Context, _ *sapb.RegistrationID, _ ...grpc.CallOption) (*sapb.Identifiers, error) {
246-
return nil, nil
247-
}
248-
249222
// GetRevokedCertsByShard is a mock
250223
func (sa *StorageAuthorityReadOnly) GetRevokedCertsByShard(ctx context.Context, _ *sapb.GetRevokedCertsByShardRequest, _ ...grpc.CallOption) (grpc.ServerStreamingClient[corepb.CRLEntry], error) {
251224
return &ServerStreamClient[corepb.CRLEntry]{}, nil
252225
}
253226

254-
// AddRateLimitOverride is a mock
255-
func (sa *StorageAuthority) AddRateLimitOverride(_ context.Context, req *sapb.AddRateLimitOverrideRequest, _ ...grpc.CallOption) (*sapb.AddRateLimitOverrideResponse, error) {
256-
return nil, nil
257-
}
258-
259-
// DisableRateLimitOverride is a mock
260-
func (sa *StorageAuthority) DisableRateLimitOverride(ctx context.Context, req *sapb.DisableRateLimitOverrideRequest) (*emptypb.Empty, error) {
261-
return nil, nil
262-
}
263-
264-
// EnableRateLimitOverride is a mock
265-
func (sa *StorageAuthority) EnableRateLimitOverride(ctx context.Context, req *sapb.EnableRateLimitOverrideRequest) (*emptypb.Empty, error) {
266-
return nil, nil
267-
}
268-
269227
// GetRateLimitOverride is a mock
270228
func (sa *StorageAuthorityReadOnly) GetRateLimitOverride(_ context.Context, req *sapb.GetRateLimitOverrideRequest, _ ...grpc.CallOption) (*sapb.RateLimitOverrideResponse, error) {
271229
return nil, nil
@@ -276,31 +234,6 @@ func (sa *StorageAuthorityReadOnly) GetEnabledRateLimitOverrides(_ context.Conte
276234
return nil, nil
277235
}
278236

279-
// AddPrecertificate is a mock
280-
func (sa *StorageAuthority) AddPrecertificate(ctx context.Context, req *sapb.AddCertificateRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) {
281-
return nil, nil
282-
}
283-
284-
// AddSerial is a mock
285-
func (sa *StorageAuthority) AddSerial(ctx context.Context, req *sapb.AddSerialRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) {
286-
return nil, nil
287-
}
288-
289-
// AddCertificate is a mock
290-
func (sa *StorageAuthority) AddCertificate(_ context.Context, _ *sapb.AddCertificateRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) {
291-
return nil, nil
292-
}
293-
294-
// NewRegistration is a mock
295-
func (sa *StorageAuthority) NewRegistration(_ context.Context, _ *corepb.Registration, _ ...grpc.CallOption) (*corepb.Registration, error) {
296-
return &corepb.Registration{}, nil
297-
}
298-
299-
// UpdateRegistration is a mock
300-
func (sa *StorageAuthority) UpdateRegistration(_ context.Context, _ *corepb.Registration, _ ...grpc.CallOption) (*emptypb.Empty, error) {
301-
return &emptypb.Empty{}, nil
302-
}
303-
304237
// FQDNSetTimestampsForWindow is a mock
305238
func (sa *StorageAuthorityReadOnly) FQDNSetTimestampsForWindow(_ context.Context, _ *sapb.CountFQDNSetsRequest, _ ...grpc.CallOption) (*sapb.Timestamps, error) {
306239
return &sapb.Timestamps{}, nil
@@ -311,45 +244,6 @@ func (sa *StorageAuthorityReadOnly) FQDNSetExists(_ context.Context, _ *sapb.FQD
311244
return &sapb.Exists{Exists: false}, nil
312245
}
313246

314-
// DeactivateRegistration is a mock
315-
func (sa *StorageAuthority) DeactivateRegistration(_ context.Context, _ *sapb.RegistrationID, _ ...grpc.CallOption) (*emptypb.Empty, error) {
316-
return &emptypb.Empty{}, nil
317-
}
318-
319-
// NewOrderAndAuthzs is a mock
320-
func (sa *StorageAuthority) NewOrderAndAuthzs(_ context.Context, req *sapb.NewOrderAndAuthzsRequest, _ ...grpc.CallOption) (*corepb.Order, error) {
321-
response := &corepb.Order{
322-
// Fields from the input new order request.
323-
RegistrationID: req.NewOrder.RegistrationID,
324-
Expires: req.NewOrder.Expires,
325-
Identifiers: req.NewOrder.Identifiers,
326-
V2Authorizations: req.NewOrder.V2Authorizations,
327-
// Mock new fields generated by the database transaction.
328-
Id: rand.Int64(),
329-
Created: timestamppb.Now(),
330-
// A new order is never processing because it can't have been finalized yet.
331-
BeganProcessing: false,
332-
Status: string(core.StatusPending),
333-
CertificateProfileName: req.NewOrder.CertificateProfileName,
334-
}
335-
return response, nil
336-
}
337-
338-
// SetOrderProcessing is a mock
339-
func (sa *StorageAuthority) SetOrderProcessing(_ context.Context, req *sapb.OrderRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) {
340-
return &emptypb.Empty{}, nil
341-
}
342-
343-
// SetOrderError is a mock
344-
func (sa *StorageAuthority) SetOrderError(_ context.Context, req *sapb.SetOrderErrorRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) {
345-
return &emptypb.Empty{}, nil
346-
}
347-
348-
// FinalizeOrder is a mock
349-
func (sa *StorageAuthority) FinalizeOrder(_ context.Context, req *sapb.FinalizeOrderRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) {
350-
return &emptypb.Empty{}, nil
351-
}
352-
353247
// GetOrder is a mock
354248
func (sa *StorageAuthorityReadOnly) GetOrder(_ context.Context, req *sapb.OrderRequest, _ ...grpc.CallOption) (*corepb.Order, error) {
355249
if req.Id == 2 {
@@ -416,14 +310,6 @@ func (sa *StorageAuthorityReadOnly) GetOrderForNames(_ context.Context, _ *sapb.
416310
return nil, nil
417311
}
418312

419-
func (sa *StorageAuthority) FinalizeAuthorization2(ctx context.Context, req *sapb.FinalizeAuthorizationRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) {
420-
return &emptypb.Empty{}, nil
421-
}
422-
423-
func (sa *StorageAuthority) DeactivateAuthorization2(ctx context.Context, req *sapb.AuthorizationID2, _ ...grpc.CallOption) (*emptypb.Empty, error) {
424-
return nil, nil
425-
}
426-
427313
func (sa *StorageAuthorityReadOnly) CountPendingAuthorizations2(ctx context.Context, req *sapb.RegistrationID, _ ...grpc.CallOption) (*sapb.Count, error) {
428314
return &sapb.Count{}, nil
429315
}
@@ -476,36 +362,11 @@ func (sa *StorageAuthorityReadOnly) GetSerialsByKey(ctx context.Context, _ *sapb
476362
return &ServerStreamClient[sapb.Serial]{}, nil
477363
}
478364

479-
// GetSerialsByKey is a mock
480-
func (sa *StorageAuthority) GetSerialsByKey(ctx context.Context, _ *sapb.SPKIHash, _ ...grpc.CallOption) (sapb.StorageAuthority_GetSerialsByKeyClient, error) {
481-
return &ServerStreamClient[sapb.Serial]{}, nil
482-
}
483-
484365
// GetSerialsByAccount is a mock
485366
func (sa *StorageAuthorityReadOnly) GetSerialsByAccount(ctx context.Context, _ *sapb.RegistrationID, _ ...grpc.CallOption) (sapb.StorageAuthorityReadOnly_GetSerialsByAccountClient, error) {
486367
return &ServerStreamClient[sapb.Serial]{}, nil
487368
}
488369

489-
// GetSerialsByAccount is a mock
490-
func (sa *StorageAuthority) GetSerialsByAccount(ctx context.Context, _ *sapb.RegistrationID, _ ...grpc.CallOption) (sapb.StorageAuthority_GetSerialsByAccountClient, error) {
491-
return &ServerStreamClient[sapb.Serial]{}, nil
492-
}
493-
494-
// RevokeCertificate is a mock
495-
func (sa *StorageAuthority) RevokeCertificate(ctx context.Context, req *sapb.RevokeCertificateRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) {
496-
return nil, nil
497-
}
498-
499-
// UpdateRevokedCertificate is a mock
500-
func (sa *StorageAuthority) UpdateRevokedCertificate(ctx context.Context, req *sapb.RevokeCertificateRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) {
501-
return nil, nil
502-
}
503-
504-
// AddBlockedKey is a mock
505-
func (sa *StorageAuthority) AddBlockedKey(ctx context.Context, req *sapb.AddBlockedKeyRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) {
506-
return &emptypb.Empty{}, nil
507-
}
508-
509370
// KeyBlocked is a mock
510371
func (sa *StorageAuthorityReadOnly) KeyBlocked(ctx context.Context, req *sapb.SPKIHash, _ ...grpc.CallOption) (*sapb.Exists, error) {
511372
return &sapb.Exists{Exists: false}, nil
@@ -516,16 +377,6 @@ func (sa *StorageAuthorityReadOnly) IncidentsForSerial(ctx context.Context, req
516377
return &sapb.Incidents{}, nil
517378
}
518379

519-
// LeaseCRLShard is a mock.
520-
func (sa *StorageAuthority) LeaseCRLShard(ctx context.Context, req *sapb.LeaseCRLShardRequest, _ ...grpc.CallOption) (*sapb.LeaseCRLShardResponse, error) {
521-
return nil, errors.New("unimplemented")
522-
}
523-
524-
// UpdateCRLShard is a mock.
525-
func (sa *StorageAuthority) UpdateCRLShard(ctx context.Context, req *sapb.UpdateCRLShardRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) {
526-
return nil, errors.New("unimplemented")
527-
}
528-
529380
// ReplacementOrderExists is a mock.
530381
func (sa *StorageAuthorityReadOnly) ReplacementOrderExists(ctx context.Context, req *sapb.Serial, _ ...grpc.CallOption) (*sapb.Exists, error) {
531382
return nil, nil

probs/probs.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -312,19 +312,6 @@ func UnsupportedIdentifier(detail string, a ...any) *ProblemDetails {
312312
// Additional helper functions that return variations on MalformedProblem with
313313
// different HTTP status codes set.
314314

315-
// Canceled returns a ProblemDetails with a MalformedProblem and a 408 Request
316-
// Timeout status code.
317-
func Canceled(detail string, a ...any) *ProblemDetails {
318-
if len(a) > 0 {
319-
detail = fmt.Sprintf(detail, a...)
320-
}
321-
return &ProblemDetails{
322-
Type: MalformedProblem,
323-
Detail: detail,
324-
HTTPStatus: http.StatusRequestTimeout,
325-
}
326-
}
327-
328315
// Conflict returns a ProblemDetails with a ConflictProblem and a 409 Conflict
329316
// status code.
330317
func Conflict(detail string) *ProblemDetails {

0 commit comments

Comments
 (0)