use core.IsAnyNilOrZero more places (#7925)
There were a bunch of places that had `TODO(#7153)`; that issue is now closed, so let's tidy up.
This commit is contained in:
		
							parent
							
								
									f10f462959
								
							
						
					
					
						commit
						635f43266a
					
				
							
								
								
									
										6
									
								
								ra/ra.go
								
								
								
								
							
							
						
						
									
										6
									
								
								ra/ra.go
								
								
								
								
							|  | @ -1879,8 +1879,7 @@ func (ra *RegistrationAuthorityImpl) PerformValidation( | ||||||
| 	// Clock for start of PerformValidation.
 | 	// Clock for start of PerformValidation.
 | ||||||
| 	vStart := ra.clk.Now() | 	vStart := ra.clk.Now() | ||||||
| 
 | 
 | ||||||
| 	// TODO(#7153): Check each value via core.IsAnyNilOrZero
 | 	if core.IsAnyNilOrZero(req.Authz, req.Authz.Id, req.Authz.DnsName, req.Authz.Status, req.Authz.Expires) { | ||||||
| 	if req.Authz == nil || req.Authz.Id == "" || req.Authz.DnsName == "" || req.Authz.Status == "" || core.IsAnyNilOrZero(req.Authz.Expires) { |  | ||||||
| 		return nil, errIncompleteGRPCRequest | 		return nil, errIncompleteGRPCRequest | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -2577,8 +2576,7 @@ func (ra *RegistrationAuthorityImpl) NewOrder(ctx context.Context, req *rapb.New | ||||||
| 	// Error if an incomplete order is returned.
 | 	// Error if an incomplete order is returned.
 | ||||||
| 	if existingOrder != nil { | 	if existingOrder != nil { | ||||||
| 		// Check to see if the expected fields of the existing order are set.
 | 		// Check to see if the expected fields of the existing order are set.
 | ||||||
| 		// TODO(#7153): Check each value via core.IsAnyNilOrZero
 | 		if core.IsAnyNilOrZero(existingOrder.Id, existingOrder.Status, existingOrder.RegistrationID, existingOrder.DnsNames, existingOrder.Created, existingOrder.Expires) { | ||||||
| 		if existingOrder.Id == 0 || existingOrder.Status == "" || existingOrder.RegistrationID == 0 || len(existingOrder.DnsNames) == 0 || core.IsAnyNilOrZero(existingOrder.Created, existingOrder.Expires) { |  | ||||||
| 			return nil, errIncompleteGRPCResponse | 			return nil, errIncompleteGRPCResponse | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										18
									
								
								sa/sa.go
								
								
								
								
							
							
						
						
									
										18
									
								
								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.
 | // 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) { | func (ssa *SQLStorageAuthority) AddSerial(ctx context.Context, req *sapb.AddSerialRequest) (*emptypb.Empty, error) { | ||||||
| 	// TODO(#7153): Check each value via core.IsAnyNilOrZero
 | 	if core.IsAnyNilOrZero(req.Serial, req.RegID, req.Created, req.Expires) { | ||||||
| 	if req.Serial == "" || req.RegID == 0 || core.IsAnyNilOrZero(req.Created, req.Expires) { |  | ||||||
| 		return nil, errIncompleteRequest | 		return nil, errIncompleteRequest | ||||||
| 	} | 	} | ||||||
| 	err := ssa.dbMap.Insert(ctx, &recordedSerialModel{ | 	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
 | // certificate multiple times. Calling code needs to first insert the cert's
 | ||||||
| // serial into the Serials table to ensure uniqueness.
 | // serial into the Serials table to ensure uniqueness.
 | ||||||
| func (ssa *SQLStorageAuthority) AddPrecertificate(ctx context.Context, req *sapb.AddCertificateRequest) (*emptypb.Empty, error) { | func (ssa *SQLStorageAuthority) AddPrecertificate(ctx context.Context, req *sapb.AddCertificateRequest) (*emptypb.Empty, error) { | ||||||
| 	// TODO(#7153): Check each value via core.IsAnyNilOrZero
 | 	if core.IsAnyNilOrZero(req.Der, req.RegID, req.IssuerNameID, req.Issued) { | ||||||
| 	if len(req.Der) == 0 || req.RegID == 0 || req.IssuerNameID == 0 || core.IsAnyNilOrZero(req.Issued) { |  | ||||||
| 		return nil, errIncompleteRequest | 		return nil, errIncompleteRequest | ||||||
| 	} | 	} | ||||||
| 	parsed, err := x509.ParseCertificate(req.Der) | 	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
 | // AddCertificate stores an issued certificate, returning an error if it is a
 | ||||||
| // duplicate or if any other failure occurs.
 | // duplicate or if any other failure occurs.
 | ||||||
| func (ssa *SQLStorageAuthority) AddCertificate(ctx context.Context, req *sapb.AddCertificateRequest) (*emptypb.Empty, error) { | func (ssa *SQLStorageAuthority) AddCertificate(ctx context.Context, req *sapb.AddCertificateRequest) (*emptypb.Empty, error) { | ||||||
| 	// TODO(#7153): Check each value via core.IsAnyNilOrZero
 | 	if core.IsAnyNilOrZero(req.Der, req.RegID, req.Issued) { | ||||||
| 	if len(req.Der) == 0 || req.RegID == 0 || core.IsAnyNilOrZero(req.Issued) { |  | ||||||
| 		return nil, errIncompleteRequest | 		return nil, errIncompleteRequest | ||||||
| 	} | 	} | ||||||
| 	parsedCertificate, err := x509.ParseCertificate(req.Der) | 	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
 | // 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.
 | // 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) { | func (ssa *SQLStorageAuthority) FinalizeAuthorization2(ctx context.Context, req *sapb.FinalizeAuthorizationRequest) (*emptypb.Empty, error) { | ||||||
| 	// TODO(#7153): Check each value via core.IsAnyNilOrZero
 | 	if core.IsAnyNilOrZero(req.Status, req.Attempted, req.Id, req.Expires) { | ||||||
| 	if req.Status == "" || req.Attempted == "" || req.Id == 0 || core.IsAnyNilOrZero(req.Expires) { |  | ||||||
| 		return nil, errIncompleteRequest | 		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
 | // RevokeCertificate stores revocation information about a certificate. It will only store this
 | ||||||
| // information if the certificate is not already marked as revoked.
 | // information if the certificate is not already marked as revoked.
 | ||||||
| func (ssa *SQLStorageAuthority) RevokeCertificate(ctx context.Context, req *sapb.RevokeCertificateRequest) (*emptypb.Empty, error) { | func (ssa *SQLStorageAuthority) RevokeCertificate(ctx context.Context, req *sapb.RevokeCertificateRequest) (*emptypb.Empty, error) { | ||||||
| 	// TODO(#7153): Check each value via core.IsAnyNilOrZero
 | 	if core.IsAnyNilOrZero(req.Serial, req.IssuerID, req.Date) { | ||||||
| 	if req.Serial == "" || req.IssuerID == 0 || core.IsAnyNilOrZero(req.Date) { |  | ||||||
| 		return nil, errIncompleteRequest | 		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`,
 | // cert is already revoked, if the new revocation reason is `KeyCompromise`,
 | ||||||
| // and if the revokedDate is identical to the current revokedDate.
 | // and if the revokedDate is identical to the current revokedDate.
 | ||||||
| func (ssa *SQLStorageAuthority) UpdateRevokedCertificate(ctx context.Context, req *sapb.RevokeCertificateRequest) (*emptypb.Empty, error) { | func (ssa *SQLStorageAuthority) UpdateRevokedCertificate(ctx context.Context, req *sapb.RevokeCertificateRequest) (*emptypb.Empty, error) { | ||||||
| 	// TODO(#7153): Check each value via core.IsAnyNilOrZero
 | 	if core.IsAnyNilOrZero(req.Serial, req.IssuerID, req.Date, req.Backdate) { | ||||||
| 	if req.Serial == "" || req.IssuerID == 0 || core.IsAnyNilOrZero(req.Date, req.Backdate) { |  | ||||||
| 		return nil, errIncompleteRequest | 		return nil, errIncompleteRequest | ||||||
| 	} | 	} | ||||||
| 	if req.Reason != ocsp.KeyCompromise { | 	if req.Reason != ocsp.KeyCompromise { | ||||||
|  |  | ||||||
|  | @ -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
 | // 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.
 | // 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) { | func (ssa *SQLStorageAuthorityRO) CountCertificatesByNames(ctx context.Context, req *sapb.CountCertificatesByNamesRequest) (*sapb.CountByNames, error) { | ||||||
| 	// TODO(#7153): Check each value via core.IsAnyNilOrZero
 | 	if core.IsAnyNilOrZero(req.DnsNames, req.Range.Earliest, req.Range.Latest) { | ||||||
| 	if len(req.DnsNames) == 0 || core.IsAnyNilOrZero(req.Range.Earliest, req.Range.Latest) { |  | ||||||
| 		return nil, errIncompleteRequest | 		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) { | func (ssa *SQLStorageAuthorityRO) CountOrders(ctx context.Context, req *sapb.CountOrdersRequest) (*sapb.Count, error) { | ||||||
| 	// TODO(#7153): Check each value via core.IsAnyNilOrZero
 | 	if core.IsAnyNilOrZero(req.AccountID, req.Range.Earliest, req.Range.Latest) { | ||||||
| 	if req.AccountID == 0 || core.IsAnyNilOrZero(req.Range.Earliest, req.Range.Latest) { |  | ||||||
| 		return nil, errIncompleteRequest | 		return nil, errIncompleteRequest | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -854,8 +852,7 @@ func (ssa *SQLStorageAuthorityRO) GetValidOrderAuthorizations2(ctx context.Conte | ||||||
| // CountInvalidAuthorizations2 counts invalid authorizations for a user expiring
 | // CountInvalidAuthorizations2 counts invalid authorizations for a user expiring
 | ||||||
| // in a given time range. This method only supports DNS identifier types.
 | // 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) { | func (ssa *SQLStorageAuthorityRO) CountInvalidAuthorizations2(ctx context.Context, req *sapb.CountInvalidAuthorizationsRequest) (*sapb.Count, error) { | ||||||
| 	// TODO(#7153): Check each value via core.IsAnyNilOrZero
 | 	if core.IsAnyNilOrZero(req.RegistrationID, req.DnsName, req.Range.Earliest, req.Range.Latest) { | ||||||
| 	if req.RegistrationID == 0 || req.DnsName == "" || core.IsAnyNilOrZero(req.Range.Earliest, req.Range.Latest) { |  | ||||||
| 		return nil, errIncompleteRequest | 		return nil, errIncompleteRequest | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										21
									
								
								wfe2/wfe.go
								
								
								
								
							
							
						
						
									
										21
									
								
								wfe2/wfe.go
								
								
								
								
							|  | @ -1119,8 +1119,7 @@ func (wfe *WebFrontEndImpl) Challenge( | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// Ensure gRPC response is complete.
 | 	// Ensure gRPC response is complete.
 | ||||||
| 	// TODO(#7153): Check each value via core.IsAnyNilOrZero
 | 	if core.IsAnyNilOrZero(authzPB.Id, authzPB.DnsName, authzPB.Status, authzPB.Expires) { | ||||||
| 	if authzPB.Id == "" || authzPB.DnsName == "" || authzPB.Status == "" || core.IsAnyNilOrZero(authzPB.Expires) { |  | ||||||
| 		wfe.sendError(response, logEvent, probs.ServerInternal("Problem getting authorization"), errIncompleteGRPCResponse) | 		wfe.sendError(response, logEvent, probs.ServerInternal("Problem getting authorization"), errIncompleteGRPCResponse) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  | @ -1322,8 +1321,7 @@ func (wfe *WebFrontEndImpl) postChallenge( | ||||||
| 			Authz:          authzPB, | 			Authz:          authzPB, | ||||||
| 			ChallengeIndex: int64(challengeIndex), | 			ChallengeIndex: int64(challengeIndex), | ||||||
| 		}) | 		}) | ||||||
| 		// TODO(#7153): Check each value via core.IsAnyNilOrZero
 | 		if err != nil || core.IsAnyNilOrZero(authzPB, authzPB.Id, authzPB.DnsName, authzPB.Status, authzPB.Expires) { | ||||||
| 		if err != nil || authzPB == nil || authzPB.Id == "" || authzPB.DnsName == "" || authzPB.Status == "" || core.IsAnyNilOrZero(authzPB.Expires) { |  | ||||||
| 			wfe.sendError(response, logEvent, web.ProblemDetailsForError(err, "Unable to update challenge"), err) | 			wfe.sendError(response, logEvent, web.ProblemDetailsForError(err, "Unable to update challenge"), err) | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
|  | @ -1565,8 +1563,7 @@ func (wfe *WebFrontEndImpl) Authorization( | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// Ensure gRPC response is complete.
 | 	// Ensure gRPC response is complete.
 | ||||||
| 	// TODO(#7153): Check each value via core.IsAnyNilOrZero
 | 	if core.IsAnyNilOrZero(authzPB.Id, authzPB.DnsName, authzPB.Status, authzPB.Expires) { | ||||||
| 	if authzPB.Id == "" || authzPB.DnsName == "" || authzPB.Status == "" || core.IsAnyNilOrZero(authzPB.Expires) { |  | ||||||
| 		wfe.sendError(response, logEvent, probs.ServerInternal("Problem getting authorization"), errIncompleteGRPCResponse) | 		wfe.sendError(response, logEvent, probs.ServerInternal("Problem getting authorization"), errIncompleteGRPCResponse) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  | @ -2403,8 +2400,7 @@ func (wfe *WebFrontEndImpl) NewOrder( | ||||||
| 		IsARIRenewal:           isARIRenewal, | 		IsARIRenewal:           isARIRenewal, | ||||||
| 		IsRenewal:              isRenewal, | 		IsRenewal:              isRenewal, | ||||||
| 	}) | 	}) | ||||||
| 	// TODO(#7153): Check each value via core.IsAnyNilOrZero
 | 	if err != nil || core.IsAnyNilOrZero(order, order.Id, order.RegistrationID, order.DnsNames, order.Created, order.Expires) { | ||||||
| 	if err != nil || order == nil || order.Id == 0 || order.RegistrationID == 0 || len(order.DnsNames) == 0 || core.IsAnyNilOrZero(order.Created, order.Expires) { |  | ||||||
| 		wfe.sendError(response, logEvent, web.ProblemDetailsForError(err, "Error creating new order"), err) | 		wfe.sendError(response, logEvent, web.ProblemDetailsForError(err, "Error creating new order"), err) | ||||||
| 		if errors.Is(err, berrors.RateLimit) { | 		if errors.Is(err, berrors.RateLimit) { | ||||||
| 			// Request was denied by a legacy rate limit. In this error case we
 | 			// 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 | 		return | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// TODO(#7153): Check each value via core.IsAnyNilOrZero
 | 	if core.IsAnyNilOrZero(order.Id, order.Status, order.RegistrationID, order.DnsNames, order.Created, order.Expires) { | ||||||
| 	if order.Id == 0 || order.Status == "" || order.RegistrationID == 0 || len(order.DnsNames) == 0 || core.IsAnyNilOrZero(order.Created, order.Expires) { |  | ||||||
| 		wfe.sendError(response, logEvent, probs.ServerInternal(fmt.Sprintf("Failed to retrieve order for ID %d", orderID)), errIncompleteGRPCResponse) | 		wfe.sendError(response, logEvent, probs.ServerInternal(fmt.Sprintf("Failed to retrieve order for ID %d", orderID)), errIncompleteGRPCResponse) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  | @ -2555,8 +2550,7 @@ func (wfe *WebFrontEndImpl) FinalizeOrder(ctx context.Context, logEvent *web.Req | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// TODO(#7153): Check each value via core.IsAnyNilOrZero
 | 	if core.IsAnyNilOrZero(order.Id, order.Status, order.RegistrationID, order.DnsNames, order.Created, order.Expires) { | ||||||
| 	if order.Id == 0 || order.Status == "" || order.RegistrationID == 0 || len(order.DnsNames) == 0 || core.IsAnyNilOrZero(order.Created, order.Expires) { |  | ||||||
| 		wfe.sendError(response, logEvent, probs.ServerInternal(fmt.Sprintf("Failed to retrieve order for ID %d", orderID)), errIncompleteGRPCResponse) | 		wfe.sendError(response, logEvent, probs.ServerInternal(fmt.Sprintf("Failed to retrieve order for ID %d", orderID)), errIncompleteGRPCResponse) | ||||||
| 		return | 		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) | 		wfe.sendError(response, logEvent, web.ProblemDetailsForError(err, "Error finalizing order"), err) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	// TODO(#7153): Check each value via core.IsAnyNilOrZero
 | 	if core.IsAnyNilOrZero(order.Id, order.RegistrationID, order.DnsNames, order.Created, order.Expires) { | ||||||
| 	if updatedOrder == nil || order.Id == 0 || order.RegistrationID == 0 || len(order.DnsNames) == 0 || core.IsAnyNilOrZero(order.Created, order.Expires) { |  | ||||||
| 		wfe.sendError(response, logEvent, web.ProblemDetailsForError(err, "Error validating order"), errIncompleteGRPCResponse) | 		wfe.sendError(response, logEvent, web.ProblemDetailsForError(err, "Error validating order"), errIncompleteGRPCResponse) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue