mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(route53): preserve negative answers through private CNAME chains (#7460)
Preserve the target's negative DNS answer while chasing a private CNAME. Cover missing and TXT-only targets, creation/deletion, and positive TTLs. Signed-off-by: Andre Kurait <akurait@amazon.com> (cherry picked from commit da2e197f93113312212d502ee303e94ac4aa87c7) Co-authored-by: Andre Kurait <AndreKurait@gmail.com>
This commit is contained in:
1 parent
9158f28b01
commit
a796e2e58f
3 files changed
+43
-1
No files matched your search
+39
@@ -13,6 +13,8 @@ import io.vertx.core.datagram.DatagramSocketOptions;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
@@ -40,6 +42,43 @@ class Route53DnsPacketIntegrationTest {
|
||||
|
||||
private final List<String> zoneIds = new ArrayList<>();
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({"1,1", "2,1", "1,28", "2,28"})
|
||||
void privateCnamePreservesMissingTargetResponseAcrossTheWire(int depth, int type) throws Exception {
|
||||
String name = uniqueName() + ".example";
|
||||
String id = route53.createHostedZone(name, UUID.randomUUID().toString(), null,
|
||||
new VpcAssociation("vpc-cname-negative", "us-east-1")).zone().getId();
|
||||
zoneIds.add(id);
|
||||
String missing = "missing." + name;
|
||||
for (int hop = 0; hop < depth; hop++) {
|
||||
String target = hop + 1 == depth ? missing : "alias" + (hop + 1) + "." + name;
|
||||
change(id, "CREATE", record("alias" + hop + "." + name, "CNAME", 30, target + "."));
|
||||
}
|
||||
|
||||
assertEquals(3, ByteBuffer.wrap(query(request(missing, type))).getShort(2) & 15);
|
||||
byte[] response = query(request("alias0." + name, type));
|
||||
assertEquals(3, ByteBuffer.wrap(response).getShort(2) & 15,
|
||||
"A private CNAME must preserve its target's NXDOMAIN response");
|
||||
assertEquals(0, ByteBuffer.wrap(response).getShort(6));
|
||||
|
||||
ResourceRecordSet text = record(missing, "TXT", 60, "\"present\"");
|
||||
change(id, "CREATE", text);
|
||||
byte[] noData = query(request("alias0." + name, type));
|
||||
assertEquals(0, ByteBuffer.wrap(noData).getShort(2) & 15);
|
||||
assertEquals(0, ByteBuffer.wrap(noData).getShort(6));
|
||||
change(id, "DELETE", text);
|
||||
assertEquals(3, ByteBuffer.wrap(query(request("alias0." + name, type))).getShort(2) & 15);
|
||||
|
||||
change(id, "CREATE", record(missing, "A", 600, "192.0.2.17"));
|
||||
byte[] request = request("alias0." + name, 1);
|
||||
byte[] restored = query(request);
|
||||
assertEquals(0, ByteBuffer.wrap(restored).getShort(2) & 15);
|
||||
assertEquals(1, ByteBuffer.wrap(restored).getShort(6));
|
||||
assertEquals(30, ByteBuffer.wrap(restored).getInt(request.length + 6));
|
||||
assertArrayEquals(new DnsRecord.Address(1, "192.0.2.17").data(),
|
||||
Arrays.copyOfRange(restored, restored.length - 4, restored.length));
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void deleteOwnedZones() {
|
||||
for (String id : zoneIds.reversed()) {
|
||||
|
||||
Reference in new issue
Block a user