Add DNS record RDATA validation#48
Conversation
4165bb7 to
fb06d68
Compare
Greptile SummaryThis PR introduces
Confidence Score: 5/5Safe to merge — new public surface is additive, existing encoding paths are unchanged, and the decode→encode round-trip for all record types (including unknown types stored as hex) remains intact. The change adds two small, well-tested methods with no side effects on existing behaviour. All current record types are correctly handled by the empty-packet call in No files require special attention. Important Files Changed
Reviews (3): Last reviewed commit: "Add DNS record rdata validation" | Re-trigger Greptile |
fb06d68 to
75a075b
Compare
75a075b to
b2b8d07
Compare
What
Adds reusable DNS record RDATA validation so callers can validate answers, authority, and additional records without serializing a full DNS message.
Why
Invalid RDATA such as a hostname in an A record (
ns2.appwrite.zone) currently surfaces only while encoding. Exposing validation at theRecordandMessagelevel lets DNS services detect malformed records earlier and return an appropriate failure response.Changes
Record::validateRdata()for record-type-specific RDATA checks.Message::validate()to validate answer, authority, and additional sections.encodeRdata()aligned by callingvalidateRdata()before encoding.Testing
composer test -- --filter 'RecordTest|MessageTest'composer format:check./vendor/bin/phpstan analyse --level max -c phpstan.neon src tests --memory-limit=1GFull
composer testwas also run and only failed in localhost DNS client e2e tests because nothing was listening on127.0.0.1:5300.