Skip to content

Commit

Permalink
WFE: Suppress logging of probs.PausedProblem (#7719)
Browse files Browse the repository at this point in the history
Instead of logging the message shown to the caller, log "429 ::
rateLimited :: account/ident pair is paused"
  • Loading branch information
beautifulentropy authored Sep 26, 2024
1 parent c684996 commit 8c009f2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion probs/probs.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
InvalidContactProblem = ProblemType("invalidContact")
MalformedProblem = ProblemType("malformed")
OrderNotReadyProblem = ProblemType("orderNotReady")
PausedProblem = ProblemType("rateLimited")
RateLimitedProblem = ProblemType("rateLimited")
RejectedIdentifierProblem = ProblemType("rejectedIdentifier")
ServerInternalProblem = ProblemType("serverInternal")
Expand Down Expand Up @@ -220,7 +221,7 @@ func RateLimited(detail string) *ProblemDetails {
// Paused returns a ProblemDetails representing a RateLimitedProblem error
func Paused(detail string) *ProblemDetails {
return &ProblemDetails{
Type: RateLimitedProblem,
Type: PausedProblem,
Detail: detail,
HTTPStatus: http.StatusTooManyRequests,
}
Expand Down
9 changes: 8 additions & 1 deletion web/send_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,15 @@ func SendError(
response.WriteHeader(http.StatusInternalServerError)
}

// Suppress logging of the "Your account is temporarily prevented from
// requesting certificates" error.
var primaryDetail = prob.Detail
if prob.Type == probs.PausedProblem {
primaryDetail = "account/ident pair is paused"
}

// Record details to the log event
logEvent.Error = fmt.Sprintf("%d :: %s :: %s", prob.HTTPStatus, prob.Type, prob.Detail)
logEvent.Error = fmt.Sprintf("%d :: %s :: %s", prob.HTTPStatus, prob.Type, primaryDetail)
if len(prob.SubProblems) > 0 {
subDetails := make([]string, len(prob.SubProblems))
for i, sub := range prob.SubProblems {
Expand Down
9 changes: 9 additions & 0 deletions web/send_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
berrors "github.com/letsencrypt/boulder/errors"
"github.com/letsencrypt/boulder/identifier"
"github.com/letsencrypt/boulder/log"
"github.com/letsencrypt/boulder/probs"
"github.com/letsencrypt/boulder/test"
)

Expand Down Expand Up @@ -94,3 +95,11 @@ func TestSendErrorSubProbLogging(t *testing.T) {

test.AssertEquals(t, logEvent.Error, `400 :: malformed :: dfoop :: bad ["example.com :: malformed :: dfoop :: nop", "what about example.com :: malformed :: dfoop :: nah"]`)
}

func TestSendErrorPausedProblemLoggingSuppression(t *testing.T) {
rw := httptest.NewRecorder()
logEvent := RequestEvent{}
SendError(log.NewMock(), rw, &logEvent, probs.Paused("I better not see any of this"), nil)

test.AssertEquals(t, logEvent.Error, "429 :: rateLimited :: account/ident pair is paused")
}

0 comments on commit 8c009f2

Please sign in to comment.