dns-message-parser icon indicating copy to clipboard operation
dns-message-parser copied to clipboard

Support issue, issuewild and iodef CAA property tags

Open rushmorem opened this issue 3 years ago • 6 comments

These have value types explicitly defined in the RFC (https://tools.ietf.org/html/rfc8659#section-4.2).

Perhaps instead of having tag and value fields for CAA RRs, we could just have value whose type is an enum like

pub enum Value {
    Issue(DomainName),
    IssueWild(DomainName),
    IoDef(url::Url),
    Unknown(Tag, Vec<u8>),
}

?

rushmorem avatar Apr 02 '21 20:04 rushmorem

Thanks for the suggestion. It has to be prevented that the user or the parse creates a Value::Unknown with Tag for example equals to issue. Because it would be ambiguous to Value::Issue.

I want to keep the library so that for the user it would be nearly impossible to create an incorrect DNS packet or ambiguous packet.

LinkTed avatar Apr 03 '21 07:04 LinkTed

We can prevent the user from not making such a mistake by not exposing the enum or checking for such mistakes when encoding the packet. As for creating it when parsing, that would be a bug in the parser. With correct code, it will simply not be possible.

I want to keep the library so that for the user it would be nearly impossible to create an incorrect DNS packet

Right now it's trivial for a user to create an incorrect DNS packet by creating a CAA record with a tag of "issue", "issuewild" or "iodef" and then using a value that doesn't parse to the type specified by the RFC. That's what I'm trying to avoid with this suggestion. We can use Rust's type system to avoid that.

rushmorem avatar Apr 03 '21 17:04 rushmorem

We can prevent the user from not making such a mistake by not exposing the enum or checking for such mistakes when encoding the packet. As for creating it when parsing, that would be a bug in the parser. With correct code, it will simply not be possible.

If we are not exposing the enum, how can the user create such RR then? About the parser you are right.

LinkTed avatar Apr 03 '21 17:04 LinkTed

By doing the construction through methods. Say Value::issue, Value::issue_wild etc that do the construction on the user's behalf.

rushmorem avatar Apr 03 '21 18:04 rushmorem

How the user can access the different data? For example, a DomainNameif it is a Issueor the Urlif it is a IoDef.

LinkTed avatar Apr 03 '21 18:04 LinkTed

That boils down to your API design choice but here is one way to do it.

rushmorem avatar Apr 03 '21 20:04 rushmorem