From 8808f1b60d6c3c8e912a17419f1111cf4d6ce70b Mon Sep 17 00:00:00 2001 From: William Harrison Date: Thu, 29 Dec 2022 18:07:12 +0800 Subject: [PATCH 1/4] prettier --- utils/utils.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/utils/utils.js b/utils/utils.js index f9a6879..319aa50 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -3,19 +3,19 @@ const fs = require('fs'); const core = require('@actions/core'); function getFiles(path) { - //get all files in path, returns arr + // Get all files in path: returns array const allFiles = fs.readdirSync(path); return allFiles } function getFileExtension(filename) { - //get file ext + // Get file extension return (/[.]/.exec(filename)) ? /[^.]+$/.exec(filename) : undefined; } function stripExt(filename) { - //remove file ext + // Remove file extension return filename.substr(0, filename.lastIndexOf('.')) } @@ -34,17 +34,20 @@ function checkIfValidFQDN(str) { } function checkInvalidDomain(str) { - //check invalid domains + // Check invalid domains if (invalidDomains.includes(str)) { - core.setOutput("recordInfo", "This subdomain has been blocked for register by the is-a-good.dev team.") + core.setOutput("recordInfo", "This subdomain has been blocked.") return true; } - //check reserved domains + + // Check reserved domains const files = getFiles("./reserved/").map(file => stripExt(file)); + if (files.includes(str)) { core.setOutput("recordInfo", "This subdomain has been reserved by the is-a-good.dev team.") return true; } + return false; } From 159f9b7f80af6fb75789c011b1efb07cac275dec Mon Sep 17 00:00:00 2001 From: William Harrison Date: Thu, 29 Dec 2022 18:10:34 +0800 Subject: [PATCH 2/4] Update utils.js --- utils/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/utils.js b/utils/utils.js index 319aa50..79b4c22 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -6,7 +6,7 @@ function getFiles(path) { // Get all files in path: returns array const allFiles = fs.readdirSync(path); - return allFiles + return allFiles; } function getFileExtension(filename) { @@ -16,7 +16,7 @@ function getFileExtension(filename) { function stripExt(filename) { // Remove file extension - return filename.substr(0, filename.lastIndexOf('.')) + return filename.substr(0, filename.lastIndexOf('.')); } function checkIfValidIP(str) { From 48ed3dd0af3e749a234b2efb914bbaf32d7d7faf Mon Sep 17 00:00:00 2001 From: William Harrison Date: Thu, 29 Dec 2022 18:20:12 +0800 Subject: [PATCH 3/4] Update checkRecords.js --- utils/checkRecords.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/utils/checkRecords.js b/utils/checkRecords.js index 548523b..96afeae 100644 --- a/utils/checkRecords.js +++ b/utils/checkRecords.js @@ -2,17 +2,25 @@ const { checkIfValidIP, checkIfValidFQDN, checkInvalidDomain } = require('./uti function checkRecords(data) { const recordType = Object.keys(data.target)[0]; - + + // Check if the domain is invalid if (checkInvalidDomain(data.target[recordType].name) === true) return false; - + + // Check A record if (recordType.toLowerCase() === 'a') { return checkIfValidIP(data.target[recordType].value); } + // Check CNAME record if (recordType.toLowerCase() === 'cname') { return checkIfValidFQDN(data.target[recordType].value); } + // Check if record name matches file name + if (recordType.toLowerCase() === 'a' || recordType.toLowerCase() === 'cname') { + if (data.target[recordType].name != /* Put file name value here */) return false; + } + return false; } From f724ac89c793cc3111af4dc0b218fee522488752 Mon Sep 17 00:00:00 2001 From: William Harrison Date: Mon, 2 Jan 2023 06:41:03 +0800 Subject: [PATCH 4/4] Update checkRecords.js --- utils/checkRecords.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/utils/checkRecords.js b/utils/checkRecords.js index 96afeae..a9dc68a 100644 --- a/utils/checkRecords.js +++ b/utils/checkRecords.js @@ -16,11 +16,6 @@ function checkRecords(data) { return checkIfValidFQDN(data.target[recordType].value); } - // Check if record name matches file name - if (recordType.toLowerCase() === 'a' || recordType.toLowerCase() === 'cname') { - if (data.target[recordType].name != /* Put file name value here */) return false; - } - return false; }