diff --git a/ra/ra.go b/ra/ra.go index 3c0f53e22a0..cab7c723e73 100644 --- a/ra/ra.go +++ b/ra/ra.go @@ -1879,8 +1879,7 @@ func (ra *RegistrationAuthorityImpl) PerformValidation( // Clock for start of PerformValidation. vStart := ra.clk.Now() - // TODO(#7153): Check each value via core.IsAnyNilOrZero - if req.Authz == nil || req.Authz.Id == "" || req.Authz.DnsName == "" || req.Authz.Status == "" || core.IsAnyNilOrZero(req.Authz.Expires) { + if core.IsAnyNilOrZero(req.Authz, req.Authz.Id, req.Authz.DnsName, req.Authz.Status, req.Authz.Expires) { return nil, errIncompleteGRPCRequest } @@ -2577,8 +2576,7 @@ func (ra *RegistrationAuthorityImpl) NewOrder(ctx context.Context, req *rapb.New // Error if an incomplete order is returned. if existingOrder != nil { // Check to see if the expected fields of the existing order are set. - // TODO(#7153): Check each value via core.IsAnyNilOrZero - if existingOrder.Id == 0 || existingOrder.Status == "" || existingOrder.RegistrationID == 0 || len(existingOrder.DnsNames) == 0 || core.IsAnyNilOrZero(existingOrder.Created, existingOrder.Expires) { + if core.IsAnyNilOrZero(existingOrder.Id, existingOrder.Status, existingOrder.RegistrationID, existingOrder.DnsNames, existingOrder.Created, existingOrder.Expires) { return nil, errIncompleteGRPCResponse } diff --git a/sa/sa.go b/sa/sa.go index e3c7137d46c..3f17136d909 100644 --- a/sa/sa.go +++ b/sa/sa.go @@ -281,8 +281,7 @@ func (ssa *SQLStorageAuthority) UpdateRegistrationKey(ctx context.Context, req * // AddSerial writes a record of a serial number generation to the DB. func (ssa *SQLStorageAuthority) AddSerial(ctx context.Context, req *sapb.AddSerialRequest) (*emptypb.Empty, error) { - // TODO(#7153): Check each value via core.IsAnyNilOrZero - if req.Serial == "" || req.RegID == 0 || core.IsAnyNilOrZero(req.Created, req.Expires) { + if core.IsAnyNilOrZero(req.Serial, req.RegID, req.Created, req.Expires) { return nil, errIncompleteRequest } err := ssa.dbMap.Insert(ctx, &recordedSerialModel{ @@ -332,8 +331,7 @@ func (ssa *SQLStorageAuthority) SetCertificateStatusReady(ctx context.Context, r // certificate multiple times. Calling code needs to first insert the cert's // serial into the Serials table to ensure uniqueness. func (ssa *SQLStorageAuthority) AddPrecertificate(ctx context.Context, req *sapb.AddCertificateRequest) (*emptypb.Empty, error) { - // TODO(#7153): Check each value via core.IsAnyNilOrZero - if len(req.Der) == 0 || req.RegID == 0 || req.IssuerNameID == 0 || core.IsAnyNilOrZero(req.Issued) { + if core.IsAnyNilOrZero(req.Der, req.RegID, req.IssuerNameID, req.Issued) { return nil, errIncompleteRequest } parsed, err := x509.ParseCertificate(req.Der) @@ -424,8 +422,7 @@ func (ssa *SQLStorageAuthority) AddPrecertificate(ctx context.Context, req *sapb // AddCertificate stores an issued certificate, returning an error if it is a // duplicate or if any other failure occurs. func (ssa *SQLStorageAuthority) AddCertificate(ctx context.Context, req *sapb.AddCertificateRequest) (*emptypb.Empty, error) { - // TODO(#7153): Check each value via core.IsAnyNilOrZero - if len(req.Der) == 0 || req.RegID == 0 || core.IsAnyNilOrZero(req.Issued) { + if core.IsAnyNilOrZero(req.Der, req.RegID, req.Issued) { return nil, errIncompleteRequest } parsedCertificate, err := x509.ParseCertificate(req.Der) @@ -879,8 +876,7 @@ func (ssa *SQLStorageAuthority) FinalizeOrder(ctx context.Context, req *sapb.Fin // the authorization is being moved to invalid the validationError field must be set. If the // authorization is being moved to valid the validationRecord and expires fields must be set. func (ssa *SQLStorageAuthority) FinalizeAuthorization2(ctx context.Context, req *sapb.FinalizeAuthorizationRequest) (*emptypb.Empty, error) { - // TODO(#7153): Check each value via core.IsAnyNilOrZero - if req.Status == "" || req.Attempted == "" || req.Id == 0 || core.IsAnyNilOrZero(req.Expires) { + if core.IsAnyNilOrZero(req.Status, req.Attempted, req.Id, req.Expires) { return nil, errIncompleteRequest } @@ -1002,8 +998,7 @@ func addRevokedCertificate(ctx context.Context, tx db.Executor, req *sapb.Revoke // RevokeCertificate stores revocation information about a certificate. It will only store this // information if the certificate is not already marked as revoked. func (ssa *SQLStorageAuthority) RevokeCertificate(ctx context.Context, req *sapb.RevokeCertificateRequest) (*emptypb.Empty, error) { - // TODO(#7153): Check each value via core.IsAnyNilOrZero - if req.Serial == "" || req.IssuerID == 0 || core.IsAnyNilOrZero(req.Date) { + if core.IsAnyNilOrZero(req.Serial, req.IssuerID, req.Date) { return nil, errIncompleteRequest } @@ -1056,8 +1051,7 @@ func (ssa *SQLStorageAuthority) RevokeCertificate(ctx context.Context, req *sapb // cert is already revoked, if the new revocation reason is `KeyCompromise`, // and if the revokedDate is identical to the current revokedDate. func (ssa *SQLStorageAuthority) UpdateRevokedCertificate(ctx context.Context, req *sapb.RevokeCertificateRequest) (*emptypb.Empty, error) { - // TODO(#7153): Check each value via core.IsAnyNilOrZero - if req.Serial == "" || req.IssuerID == 0 || core.IsAnyNilOrZero(req.Date, req.Backdate) { + if core.IsAnyNilOrZero(req.Serial, req.IssuerID, req.Date, req.Backdate) { return nil, errIncompleteRequest } if req.Reason != ocsp.KeyCompromise { diff --git a/sa/saro.go b/sa/saro.go index 129b07daacc..6860cb9657a 100644 --- a/sa/saro.go +++ b/sa/saro.go @@ -220,8 +220,7 @@ func ipRange(ip net.IP) (net.IP, net.IP) { // issued for any of the domains during the provided range of time. Queries will // be run in parallel. If any of them error, only one error will be returned. func (ssa *SQLStorageAuthorityRO) CountCertificatesByNames(ctx context.Context, req *sapb.CountCertificatesByNamesRequest) (*sapb.CountByNames, error) { - // TODO(#7153): Check each value via core.IsAnyNilOrZero - if len(req.DnsNames) == 0 || core.IsAnyNilOrZero(req.Range.Earliest, req.Range.Latest) { + if core.IsAnyNilOrZero(req.DnsNames, req.Range.Earliest, req.Range.Latest) { return nil, errIncompleteRequest } @@ -424,8 +423,7 @@ func (ssa *SQLStorageAuthorityRO) GetRevocationStatus(ctx context.Context, req * } func (ssa *SQLStorageAuthorityRO) CountOrders(ctx context.Context, req *sapb.CountOrdersRequest) (*sapb.Count, error) { - // TODO(#7153): Check each value via core.IsAnyNilOrZero - if req.AccountID == 0 || core.IsAnyNilOrZero(req.Range.Earliest, req.Range.Latest) { + if core.IsAnyNilOrZero(req.AccountID, req.Range.Earliest, req.Range.Latest) { return nil, errIncompleteRequest } @@ -854,8 +852,7 @@ func (ssa *SQLStorageAuthorityRO) GetValidOrderAuthorizations2(ctx context.Conte // CountInvalidAuthorizations2 counts invalid authorizations for a user expiring // in a given time range. This method only supports DNS identifier types. func (ssa *SQLStorageAuthorityRO) CountInvalidAuthorizations2(ctx context.Context, req *sapb.CountInvalidAuthorizationsRequest) (*sapb.Count, error) { - // TODO(#7153): Check each value via core.IsAnyNilOrZero - if req.RegistrationID == 0 || req.DnsName == "" || core.IsAnyNilOrZero(req.Range.Earliest, req.Range.Latest) { + if core.IsAnyNilOrZero(req.RegistrationID, req.DnsName, req.Range.Earliest, req.Range.Latest) { return nil, errIncompleteRequest } diff --git a/wfe2/wfe.go b/wfe2/wfe.go index a41472e54ce..7c6a3e4d475 100644 --- a/wfe2/wfe.go +++ b/wfe2/wfe.go @@ -1119,8 +1119,7 @@ func (wfe *WebFrontEndImpl) Challenge( } // Ensure gRPC response is complete. - // TODO(#7153): Check each value via core.IsAnyNilOrZero - if authzPB.Id == "" || authzPB.DnsName == "" || authzPB.Status == "" || core.IsAnyNilOrZero(authzPB.Expires) { + if core.IsAnyNilOrZero(authzPB.Id, authzPB.DnsName, authzPB.Status, authzPB.Expires) { wfe.sendError(response, logEvent, probs.ServerInternal("Problem getting authorization"), errIncompleteGRPCResponse) return } @@ -1322,8 +1321,7 @@ func (wfe *WebFrontEndImpl) postChallenge( Authz: authzPB, ChallengeIndex: int64(challengeIndex), }) - // TODO(#7153): Check each value via core.IsAnyNilOrZero - if err != nil || authzPB == nil || authzPB.Id == "" || authzPB.DnsName == "" || authzPB.Status == "" || core.IsAnyNilOrZero(authzPB.Expires) { + if err != nil || core.IsAnyNilOrZero(authzPB, authzPB.Id, authzPB.DnsName, authzPB.Status, authzPB.Expires) { wfe.sendError(response, logEvent, web.ProblemDetailsForError(err, "Unable to update challenge"), err) return } @@ -1565,8 +1563,7 @@ func (wfe *WebFrontEndImpl) Authorization( } // Ensure gRPC response is complete. - // TODO(#7153): Check each value via core.IsAnyNilOrZero - if authzPB.Id == "" || authzPB.DnsName == "" || authzPB.Status == "" || core.IsAnyNilOrZero(authzPB.Expires) { + if core.IsAnyNilOrZero(authzPB.Id, authzPB.DnsName, authzPB.Status, authzPB.Expires) { wfe.sendError(response, logEvent, probs.ServerInternal("Problem getting authorization"), errIncompleteGRPCResponse) return } @@ -2403,8 +2400,7 @@ func (wfe *WebFrontEndImpl) NewOrder( IsARIRenewal: isARIRenewal, IsRenewal: isRenewal, }) - // TODO(#7153): Check each value via core.IsAnyNilOrZero - if err != nil || order == nil || order.Id == 0 || order.RegistrationID == 0 || len(order.DnsNames) == 0 || core.IsAnyNilOrZero(order.Created, order.Expires) { + if err != nil || core.IsAnyNilOrZero(order, order.Id, order.RegistrationID, order.DnsNames, order.Created, order.Expires) { wfe.sendError(response, logEvent, web.ProblemDetailsForError(err, "Error creating new order"), err) if errors.Is(err, berrors.RateLimit) { // Request was denied by a legacy rate limit. In this error case we @@ -2474,8 +2470,7 @@ func (wfe *WebFrontEndImpl) GetOrder(ctx context.Context, logEvent *web.RequestE return } - // TODO(#7153): Check each value via core.IsAnyNilOrZero - if order.Id == 0 || order.Status == "" || order.RegistrationID == 0 || len(order.DnsNames) == 0 || core.IsAnyNilOrZero(order.Created, order.Expires) { + if core.IsAnyNilOrZero(order.Id, order.Status, order.RegistrationID, order.DnsNames, order.Created, order.Expires) { wfe.sendError(response, logEvent, probs.ServerInternal(fmt.Sprintf("Failed to retrieve order for ID %d", orderID)), errIncompleteGRPCResponse) return } @@ -2555,8 +2550,7 @@ func (wfe *WebFrontEndImpl) FinalizeOrder(ctx context.Context, logEvent *web.Req return } - // TODO(#7153): Check each value via core.IsAnyNilOrZero - if order.Id == 0 || order.Status == "" || order.RegistrationID == 0 || len(order.DnsNames) == 0 || core.IsAnyNilOrZero(order.Created, order.Expires) { + if core.IsAnyNilOrZero(order.Id, order.Status, order.RegistrationID, order.DnsNames, order.Created, order.Expires) { wfe.sendError(response, logEvent, probs.ServerInternal(fmt.Sprintf("Failed to retrieve order for ID %d", orderID)), errIncompleteGRPCResponse) return } @@ -2613,8 +2607,7 @@ func (wfe *WebFrontEndImpl) FinalizeOrder(ctx context.Context, logEvent *web.Req wfe.sendError(response, logEvent, web.ProblemDetailsForError(err, "Error finalizing order"), err) return } - // TODO(#7153): Check each value via core.IsAnyNilOrZero - if updatedOrder == nil || order.Id == 0 || order.RegistrationID == 0 || len(order.DnsNames) == 0 || core.IsAnyNilOrZero(order.Created, order.Expires) { + if core.IsAnyNilOrZero(order.Id, order.RegistrationID, order.DnsNames, order.Created, order.Expires) { wfe.sendError(response, logEvent, web.ProblemDetailsForError(err, "Error validating order"), errIncompleteGRPCResponse) return }