-
Notifications
You must be signed in to change notification settings - Fork 1
test(record): pin zero through the wire format and the zone file #51
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
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,11 @@ public static function lookup(Message $query, Zone $zone): Message | |
| $records = self::selectBestRecords($query, $zone); | ||
|
|
||
| if (empty($records)) { | ||
| // SOA is stored separately; if querying SOA at the zone apex, return it | ||
| if ($question->type === Record::TYPE_SOA && $question->name === $zone->name) { | ||
| return self::soaApexResponse($query, $zone); | ||
| } | ||
|
|
||
| return Message::response( | ||
| header: $query->header, | ||
| responseCode: Message::RCODE_NXDOMAIN, | ||
|
|
@@ -157,6 +162,11 @@ private static function handleExactMatch(array $records, Message $query, Zone $z | |
| $isAuthoritative = $zone->isAuthoritative($question->name); | ||
|
|
||
| if ($isAuthoritative) { | ||
| // SOA is stored separately in Zone; handle SOA queries at the zone apex | ||
| if ($question->type === Record::TYPE_SOA && $question->name === $zone->name) { | ||
| return self::soaApexResponse($query, $zone); | ||
| } | ||
|
|
||
| // Path E1: Exact match of type | ||
| $exactTypeRecords = array_filter( | ||
| $records, | ||
|
|
@@ -215,6 +225,21 @@ private static function handleExactMatch(array $records, Message $query, Zone $z | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Build an authoritative SOA answer for the zone apex. | ||
| */ | ||
| private static function soaApexResponse(Message $query, Zone $zone): Message | ||
| { | ||
| return Message::response( | ||
| header: $query->header, | ||
| responseCode: Message::RCODE_NOERROR, | ||
| questions: $query->questions, | ||
| answers: [$zone->soa], | ||
| authoritative: true, | ||
|
Comment on lines
+234
to
+238
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new shortcut returns the zone's SOA without checking the question class. For example, a CH-class apex SOA question against an IN-class zone receives an authoritative IN record instead of no matching answer, violating the DNS question-class contract. Prompt To Fix With AIThis is a comment left during a code review.
Path: src/DNS/Zone/Resolver.php
Line: 234-238
Comment:
**SOA shortcut ignores class**
The new shortcut returns the zone's SOA without checking the question class. For example, a CH-class apex SOA question against an IN-class zone receives an authoritative IN record instead of no matching answer, violating the DNS question-class contract.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly. |
||
| recursionAvailable: false | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Randomize RRSet order for load balancing. | ||
| * | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
A programmatically constructed apex SOA question such as
example.com.keeps its trailing dot, while this new path requires exact string equality with the zone name. The query therefore falls through and returns NXDOMAIN or NODATA instead of the zone's SOA, leaving the apex SOA fix incomplete.Prompt To Fix With AI