From 12c07b444cb8fc2130ba3f9766e94bebd46e0399 Mon Sep 17 00:00:00 2001 From: William Harrison <87287585+wdhdev@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:17:03 +1100 Subject: [PATCH 1/2] domains should not reference themselves --- tests/records.test.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/records.test.js b/tests/records.test.js index a6a15cd3d..6efa84dae 100644 --- a/tests/records.test.js +++ b/tests/records.test.js @@ -138,7 +138,10 @@ t("All files should have valid record values", (t) => { t.true(Array.isArray(value), `${file}: Record value should be an array for ${key}`); value.forEach((record) => { - t.true(typeof record === "string", `${file}: Record value should be a string for ${key}`); + t.true( + typeof record === "string", + `${file}: Record value should be a string for ${key} at index ${value.indexOf(record)}` + ); }); // A: string[] @@ -201,6 +204,10 @@ t("All files should have valid record values", (t) => { if (key === "CNAME") { t.regex(value, hostnameRegex, `${file}: Record value should be a valid hostname for ${key}`); + t.false( + value === file.replace(/\.json$/, "") + ".is-a.dev", + `${file}: Record value should not reference itself for ${key}` + ); } if (key === "URL") { From 43fae0da64af4573495be3cb40161382860de947 Mon Sep 17 00:00:00 2001 From: William Harrison <87287585+wdhdev@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:40:24 +1100 Subject: [PATCH 2/2] dont allow root to cname itself --- tests/records.test.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/records.test.js b/tests/records.test.js index 6efa84dae..f6cd66d5e 100644 --- a/tests/records.test.js +++ b/tests/records.test.js @@ -204,10 +204,18 @@ t("All files should have valid record values", (t) => { if (key === "CNAME") { t.regex(value, hostnameRegex, `${file}: Record value should be a valid hostname for ${key}`); - t.false( - value === file.replace(/\.json$/, "") + ".is-a.dev", - `${file}: Record value should not reference itself for ${key}` - ); + + if(file === "@.json") { + t.false( + value === "is-a.dev", + `${file}: Record value should not reference itself for ${key}` + ); + } else { + t.false( + value === file.replace(/\.json$/, "") + ".is-a.dev", + `${file}: Record value should not reference itself for ${key}` + ); + } } if (key === "URL") {