letsencrypt / letsencrypt/boulder
Improve type-safety in the identifiers package
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:
- Other packages can access and use the
.Valuewithout checking the.Type, potentially leading to cases where an IP address is used where a DNS name is expected, or vice versa; - It's possible to construct an identifier whose
.Typeclaims to be an IP address but whose.Valueis a DNS name, or vice versa; and - 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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