mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-11 03:13:35 +00:00
Merge branch 'main' into patch-4
This commit is contained in:
3 files changed
+17
-61
No files matched your search
@@ -81,25 +81,3 @@ t("Nested subdomains should be owned by the parent subdomain's owner", (t) => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
t("Subdomains containing an underscore can only have specific records", (t) => {
|
||||
files.forEach((file) => {
|
||||
const subdomain = file.replace(/\.json$/, "");
|
||||
|
||||
if (subdomain.includes("_")) {
|
||||
const data = getDomainData(subdomain);
|
||||
const recordKeys = Object.keys(data.record);
|
||||
|
||||
if (subdomain.startsWith("_acme-challenge.") || subdomain.includes("._domainkey.")) {
|
||||
t.true(
|
||||
recordKeys.every((key) => new Set(["TXT", "CNAME"]).has(key)),
|
||||
`${file}: This type of subdomain can only have TXT or CNAME records`
|
||||
);
|
||||
} else if (subdomain.includes("._tcp.") || subdomain.includes("._udp.")) {
|
||||
t.deepEqual(recordKeys, ["SRV"], `${file}: This type of subdomain can only have SRV records`);
|
||||
} else {
|
||||
t.deepEqual(recordKeys, ["TXT"], `${file}: Subdomains with underscores can only have TXT records`);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
+15
-23
@@ -2,17 +2,11 @@ const t = require("ava");
|
||||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
|
||||
const domainsPath = path.resolve("domains");
|
||||
const files = fs.readdirSync(domainsPath).filter((file) => file.endsWith(".json"));
|
||||
|
||||
const changedFiles = JSON.parse(process.env.CHANGED_FILES);
|
||||
const prAuthor = process.env.PR_AUTHOR.toLowerCase();
|
||||
const prLabels = JSON.parse(process.env.PR_LABELS);
|
||||
const trustedUsers = require("../util/trusted.json").map((u) => u.toLowerCase());
|
||||
|
||||
function getDomainData(subdomain) {
|
||||
try {
|
||||
const data = fs.readJsonSync(path.join(domainsPath, `${subdomain}.json`));
|
||||
const data = fs.readJsonSync(path.join(path.resolve("domains"), `${subdomain}.json`));
|
||||
return data;
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to read JSON for ${subdomain}: ${error.message}`);
|
||||
@@ -21,26 +15,24 @@ function getDomainData(subdomain) {
|
||||
|
||||
t("Users can only update their own subdomains", (t) => {
|
||||
if (process.env.PR_AUTHOR && process.env.CHANGED_FILES) {
|
||||
const changedFiles = JSON.parse(process.env.CHANGED_FILES);
|
||||
const prAuthor = process.env.PR_AUTHOR.toLowerCase();
|
||||
const changedJSONFiles = changedFiles
|
||||
.filter((file) => file.startsWith("domains/"))
|
||||
.map((file) => path.basename(file))
|
||||
.forEach((file) => file.replace(/\.json$/, ""));
|
||||
.map((file) => path.basename(file));
|
||||
|
||||
if (trustedUsers.includes(prAuthor) || prLabels.includes("bypass-owner-check")) {
|
||||
t.pass();
|
||||
} else {
|
||||
files
|
||||
.filter((file) => changedJSONFiles.includes(file))
|
||||
.forEach((file) => {
|
||||
const subdomain = file.replace(/\.json$/, "");
|
||||
const data = getDomainData(subdomain);
|
||||
if (!changedJSONFiles || trustedUsers.includes(prAuthor)) return t.pass();
|
||||
if (process.env.PR_LABELS && process.env.PR_LABELS.includes("bypass-owner-check")) return t.pass();
|
||||
|
||||
t.true(
|
||||
data.owner.username.toLowerCase() === prAuthor,
|
||||
`${subdomain}: ${prAuthor} does not own ${subdomain}.is-a.dev`
|
||||
);
|
||||
});
|
||||
}
|
||||
changedJSONFiles.forEach((file) => {
|
||||
const subdomain = file.replace(/\.json$/, "");
|
||||
const data = getDomainData(subdomain);
|
||||
|
||||
t.true(
|
||||
data.owner.username.toLowerCase() === prAuthor,
|
||||
`${subdomain}: ${prAuthor} does not own ${subdomain}.is-a.dev`
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
t.pass();
|
||||
|
||||
+2
-16
@@ -7,7 +7,6 @@
|
||||
"account",
|
||||
"accounts",
|
||||
"admin",
|
||||
"admin[1-99]",
|
||||
"admins",
|
||||
"administrator",
|
||||
"administrator[1-99]",
|
||||
@@ -32,12 +31,10 @@
|
||||
"chat",
|
||||
"checkout",
|
||||
"cname",
|
||||
"cname[1-99]",
|
||||
"co",
|
||||
"codeofconduct",
|
||||
"code-of-conduct",
|
||||
"com",
|
||||
"com[1-9]",
|
||||
"con",
|
||||
"confirm",
|
||||
"confirm[1-99]",
|
||||
@@ -62,7 +59,6 @@
|
||||
"example",
|
||||
"feedback",
|
||||
"file",
|
||||
"file[1-9999]",
|
||||
"files",
|
||||
"finance",
|
||||
"forgot",
|
||||
@@ -72,7 +68,6 @@
|
||||
"help",
|
||||
"helpdesk",
|
||||
"helper",
|
||||
"helper[1-99]",
|
||||
"helpers",
|
||||
"hostmaster",
|
||||
"http",
|
||||
@@ -87,7 +82,6 @@
|
||||
"license",
|
||||
"login",
|
||||
"logout",
|
||||
"lpt[1-9]",
|
||||
"m",
|
||||
"mail",
|
||||
"maintainer",
|
||||
@@ -96,7 +90,6 @@
|
||||
"media",
|
||||
"mobile",
|
||||
"mod",
|
||||
"mod[1-99]",
|
||||
"mods",
|
||||
"moderator",
|
||||
"moderators",
|
||||
@@ -108,10 +101,9 @@
|
||||
"notifications",
|
||||
"notify",
|
||||
"ns",
|
||||
"ns[1-99]",
|
||||
"ns[1-9]",
|
||||
"nul",
|
||||
"oauth",
|
||||
"oauth[1-99]",
|
||||
"official",
|
||||
"operations",
|
||||
"ops",
|
||||
@@ -146,7 +138,6 @@
|
||||
"signout",
|
||||
"signup",
|
||||
"srv",
|
||||
"srv[1-99]",
|
||||
"staff",
|
||||
"staging",
|
||||
"statistics",
|
||||
@@ -159,9 +150,6 @@
|
||||
"system",
|
||||
"teams",
|
||||
"test",
|
||||
"test[1-9999]",
|
||||
"terms",
|
||||
"terms[1-99]",
|
||||
"termsofservice",
|
||||
"terms-of-service",
|
||||
"tld",
|
||||
@@ -171,16 +159,14 @@
|
||||
"tos",
|
||||
"tos[1-99]",
|
||||
"txt",
|
||||
"txt[1-9999]",
|
||||
"url",
|
||||
"url[1-9999]",
|
||||
"user",
|
||||
"user[1-9999]",
|
||||
"users",
|
||||
"webmail",
|
||||
"webmaster",
|
||||
"whois",
|
||||
"www[1-99]",
|
||||
"www[1-9]",
|
||||
"wwww",
|
||||
"your-domain-name"
|
||||
]
|
||||
Reference in new issue
Block a user