WFE: Suppress logging of probs.PausedProblem (#7719)

Instead of logging the message shown to the caller, log "429 ::
rateLimited :: account/ident pair is paused"
This commit is contained in:
Samantha Frank 2024-09-26 11:20:26 -04:00 committed by GitHub
parent c6849960d3
commit 8c009f2c5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 2 deletions

View File

@ -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")
@ -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,
}

View File

@ -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 {

View File

@ -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"
)
@ -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")
}