-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: add dns resolver tests #265
Conversation
Codecov Report
@@ Coverage Diff @@
## master #265 +/- ##
=========================================
+ Coverage 54.86% 58.47% +3.6%
=========================================
Files 129 129
Lines 35786 35790 +4
Branches 6032 6032
=========================================
+ Hits 19635 20929 +1294
+ Misses 16151 14861 -1290
Continue to review full report at Codecov.
|
3f7b677
to
27e9b8c
Compare
27e9b8c
to
d6888a1
Compare
I think the question that we need to answer is if all Resource Record sets in the response need to be authenticated. I do not feel like it is acceptable to have only part of the response authenticated. Based on experience playing with I suppose the combination of sig0 and DNSSEC helps, but the signing keys are public. Resolving Handshake names over the clearweb should be considered just as safe as resolving traditional DNS over clearweb (not safe). I think moving forwards with this PR, I can remove the DNSSEC checks in the tests and then remove the additional DNSSEC code and then open an issue to determine how we want to be authenticate our requests. @boymanjor thoughts? |
|
||
/** | ||
* Build a name to query for the types | ||
* that require additional labels. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to turn this into a helper function as I think I'd find it useful building applications on top of Handshake. Not quite sure where it would live or how to generalize it correctly - notice that it uses a magic index into an array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it be part of utils
or some common package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to check through hsd
and bns
to make sure that it already doesn't exist. Would the fn signature be:
name (str), hsd resource (Resource), dns type (int) -> List[str] (list of query strings)
A Resource can have multiple query strings depending on the Records inside of it, but this also may not return the name number of strings in the return value as the number of Records in the Resource which may be confusing to a library consumer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK if we not maybe test/util/common
is a good place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should leave this as a specific test helper for now. We can abstract this into a proper library method when the functionality is needed elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok this makes sense to me. Its not clearly documented anywhere in the Handshake docs that you need to use a particular domain name (with subdomains) to query for some of the rr types. Maybe the bns
stub resolver could be extended for this repo where its wrapped with an easier to use API that will handle these cases as well as use handshake native types instead of dns rr types. I could imagine that being very helpful for onboarding new developers, especially if it works in the browser.
e4f62ac
to
4c1dbbc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tynes I think this is basically ready to go. I left a comment about separating out the TXT record signing into a separate PR. I also think we can clean up the commit history. Basically this PR adds the helper types and then introduces the tests. All other commits can be squashed once we pull out the signing logic. I'd say don't worry about cleaning things up until everything thing that this depends on is merged.
|
||
/** | ||
* Build a name to query for the types | ||
* that require additional labels. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should leave this as a specific test helper for now. We can abstract this into a proper library method when the functionality is needed elsewhere.
I can rebase on master and rebase out a bunch of the intermediate commits after #292 gets merged. Thanks for the review @boymanjor Note that I wanted to add SIG0 validation to this PR as well, I started in #289 but ran into a bug with See: https://github.com/handshake-org/hsd/blob/master/lib/dns/server.js#L228 |
Needs rebase now that 91f1c27 has been merged |
58ef2ea
to
54d495a
Compare
54d495a
to
ba4dcfb
Compare
This data structure maps the Handshake record types to the DNS protocol record types. It is required for dynamic mapping between the two. Use this to determine which DNS query type to send to get back the appropriate Handshake record type.
ba4dcfb
to
4ea41aa
Compare
@boymanjor Has been rebased to remove intermediate commits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR includes a test that purchases names and then writes one of each of the different Handshake records into the tree. A DNS stub resolver then queries for the name and asserts on the correct data being returned.
The DNSSEC test tests that all resource records sets in the answer and authority sections are signed. If all resource record sets in the additional section were signed as well, it could cause problems because there could potentially be many signatures and would force the DNS server to fall back to TCP. Ideally a different authentication mechanism is devised, because the DNSSEC key is public information anyways.
@boymanjor happy to split this up into smaller PRs if it would make it easier to review
Closes #264