PraneshkumarR commited on
Commit
b4d1f04
·
1 Parent(s): e028770

Fix 3 critical bugs: trailing-dot grading, hard task difficulty, invalid task_id crash, add IP to easy task description

Browse files
server/dns_environment.py CHANGED
@@ -159,7 +159,12 @@ class DNSEnvironment:
159
  task_id = TASK_IDS[self._task_cycle_index % len(TASK_IDS)]
160
  self._task_cycle_index += 1
161
 
162
- self.task_config = get_task(task_id)
 
 
 
 
 
163
 
164
  # Deep-copy zones so original task data stays pristine ---------
165
  self.zones = {
 
159
  task_id = TASK_IDS[self._task_cycle_index % len(TASK_IDS)]
160
  self._task_cycle_index += 1
161
 
162
+ try:
163
+ self.task_config = get_task(task_id)
164
+ except ValueError:
165
+ # Invalid task_id — fall back to first task
166
+ task_id = TASK_IDS[0]
167
+ self.task_config = get_task(task_id)
168
 
169
  # Deep-copy zones so original task data stays pristine ---------
170
  self.zones = {
server/dns_utils.py CHANGED
@@ -579,9 +579,13 @@ def _check_resolution(
579
 
580
 
581
  def _rdata_match(actual: str, expected: str) -> bool:
582
- """Case-insensitive rdata comparison, ignoring trailing dots and whitespace."""
583
- a = actual.strip().rstrip(".").lower()
584
- e = expected.strip().rstrip(".").lower()
 
 
 
 
585
  return a == e
586
 
587
 
 
579
 
580
 
581
  def _rdata_match(actual: str, expected: str) -> bool:
582
+ """Case-insensitive rdata comparison preserving trailing dots.
583
+
584
+ Trailing dots are semantically significant in DNS (FQDN vs relative),
585
+ so they must NOT be stripped during comparison.
586
+ """
587
+ a = actual.strip().lower()
588
+ e = expected.strip().lower()
589
  return a == e
590
 
591
 
server/tasks.py CHANGED
@@ -95,8 +95,12 @@ def _build_fix_single_record() -> dict:
95
  "description": (
96
  "The DNS zone file for example.com has errors causing resolution "
97
  "failures. The website at www.example.com is unreachable, and "
98
- "emails are not being delivered. Examine the zone file and fix "
99
- "the broken records."
 
 
 
 
100
  ),
101
  "zones": {"example.com": records},
102
  "required_checks": required_checks,
@@ -203,10 +207,13 @@ def _build_debug_delegation() -> dict:
203
  DNSRecord("@", "SOA",
204
  "ns1.dev.parent.org. admin.dev.parent.org. 2024040101 3600 900 604800 86400"),
205
  DNSRecord("@", "NS", "ns1.dev.parent.org."),
206
- DNSRecord("@", "NS", "ns2.dev.parent.org."),
 
207
  DNSRecord("ns1", "A", "10.1.1.10"),
208
- DNSRecord("ns2", "A", "10.1.1.11"),
209
- DNSRecord("@", "A", "10.1.1.20"),
 
 
210
  # BUG: missing trailing dot — should be "dev.parent.org."
211
  DNSRecord("www", "CNAME", "dev.parent.org"),
212
  ]
 
95
  "description": (
96
  "The DNS zone file for example.com has errors causing resolution "
97
  "failures. The website at www.example.com is unreachable, and "
98
+ "emails are not being delivered.\n\n"
99
+ "Known facts:\n"
100
+ "- www.example.com should be a CNAME pointing to example.com\n"
101
+ "- The mail server is at 93.184.216.35\n"
102
+ "- Mail should be delivered via mail.example.com (MX priority 10)\n\n"
103
+ "Examine the zone file and fix the broken records."
104
  ),
105
  "zones": {"example.com": records},
106
  "required_checks": required_checks,
 
207
  DNSRecord("@", "SOA",
208
  "ns1.dev.parent.org. admin.dev.parent.org. 2024040101 3600 900 604800 86400"),
209
  DNSRecord("@", "NS", "ns1.dev.parent.org."),
210
+ # BUG: child NS says ns3 but should be ns2 (must match parent delegation)
211
+ DNSRecord("@", "NS", "ns3.dev.parent.org."),
212
  DNSRecord("ns1", "A", "10.1.1.10"),
213
+ # BUG: wrong IP for ns2 should be 10.1.1.11
214
+ DNSRecord("ns2", "A", "10.1.1.99"),
215
+ # BUG: wrong IP for web server — should be 10.1.1.20
216
+ DNSRecord("@", "A", "10.1.1.200"),
217
  # BUG: missing trailing dot — should be "dev.parent.org."
218
  DNSRecord("www", "CNAME", "dev.parent.org"),
219
  ]