letsencrypt / letsencrypt/boulder

Improve type-safety in the identifiers package

Open
#8,195 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
5.8k
Forks
649
Avg merge
3d 23h
Merged PRs (30d)
24

Description

Currently our Identifier type looks like this:
https://github.com/letsencrypt/boulder/blob/bef73f3c8b9e233bbb8ec75e08e007d6c274fed9/identifier/identifier.go#L47-L53

This means that:

  1. Other packages can access and use the .Value without checking the .Type, potentially leading to cases where an IP address is used where a DNS name is expected, or vice versa;
  2. It's possible to construct an identifier whose .Type claims to be an IP address but whose .Value is a DNS name, or vice versa; and
  3. IP Addresses are stored and carried around as strings, rather than as netip.Addrs.

We'd like to replace this with a more type-safe structure, perhaps something like:

type ACMEIdentifier interface {
  func ToProto() *corepb.Identifier
  func ToJSON() string
}

type DNS struct {
  value string
}

type IP struct {
  value netip.Addr
}

where the latter two types implement the interface.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with identifier/identifier.go, especially the current Identifier definition at lines 47–53. Trace how identifiers are converted to protobuf and JSON, then assess the proposed ACMEIdentifier, DNS, and IP types using netip.Addr; done means callers can no longer mix identifier types or carry IP addresses as strings.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
security
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.