Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
gbicann committed Sep 6, 2024
1 parent 1de35d5 commit 48c6353
Showing 1 changed file with 112 additions and 57 deletions.
169 changes: 112 additions & 57 deletions lib/rdap-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1611,15 +1611,21 @@ self.validateCommonGTLDResponseProperties = function(response) {
* Validate a domain object as per the gTLD RDAP profile for a gTLD registry.
*/
self.validateGTLDRegistryDomain = function(domain, name) {
self.pushSpec("feb24-rp");

self.msg("validating response for a gTLD registry");
self.validateCommonGTLDResponseProperties(domain);
self.validateCommonGTLDDomainProperties(domain, name);

self.popSpec("feb24-rp");
};

/**
* Validate a domain object as per the gTLD RDAP profile for a registrar.
*/
self.validateGTLDRegistrarDomain = function(domain, name) {
self.pushSpec("feb24-rp");

self.msg("validating response for a gTLD registrar");
self.validateCommonGTLDResponseProperties(domain);
self.validateCommonGTLDDomainProperties(domain, name);
Expand All @@ -1642,6 +1648,8 @@ self.validateGTLDRegistrarDomain = function(domain, name) {
);

self.popPath(".entities");

self.popSpec("feb24-rp");
};

self.validategTLDRegistrantEntity = function(rant) {
Expand All @@ -1668,7 +1676,8 @@ self.validateCommonGTLDDomainProperties = function(domain, name) {

self.add(
domain.hasOwnProperty("handle"),
"Domain object MUST have the 'handle' property."
"Domain object MUST have the 'handle' property.",
"page=3",
);

self.popPath(".handle");
Expand All @@ -1677,36 +1686,41 @@ self.validateCommonGTLDDomainProperties = function(domain, name) {

self.pushPath(".entities");

if (!self.add(
domain.hasOwnProperty("entities"),
"The 'entities' property MUST be present."
)) return;

if (!self.add(
self.isArray(domain.entities),
"The 'entities' property MUST be an array."
)) return;

let registrarPresent = false;
self.iterate(
domain.entities,
function (e) {
if (
self.isObject(e) &&
e.hasOwnProperty("roles") &&
self.isArray(e.roles) &&
e.roles.includes("registrar")
) {
registrarPresent = true;
self.validateGTLDRegistrarEntity(e);
if (
self.add(
domain.hasOwnProperty("entities"),
"The 'entities' property MUST be present.",
"page=4",
)
&&
self.add(
self.isArray(domain.entities),
"The 'entities' property MUST be an array.",
"page=4",
)
) {
let registrarPresent = false;
self.iterate(
domain.entities,
function (e) {
if (
self.isObject(e) &&
e.hasOwnProperty("roles") &&
self.isArray(e.roles) &&
e.roles.includes("registrar")
) {
registrarPresent = true;
self.validateGTLDRegistrarEntity(e);
}
}
}
);
);

self.add(
registrarPresent,
"Domain object MUST have an entity with the 'registrar' role."
);
self.add(
registrarPresent,
"Domain object MUST have an entity with the 'registrar' role.",
"page=4",
);
}

self.popPath(".entities");

Expand All @@ -1722,18 +1736,29 @@ self.validateCommonGTLDDomainProperties = function(domain, name) {
}
["registration", "expiration"].forEach((e) => self.add(
Object.keys(seen).includes(e),
"Domain object MUST have an event with an 'eventAction' property of '" + e + "'."
"Domain object MUST have an event with an 'eventAction' property of '" + e + "'.",
"page=4",
));

self.popPath(".events");


self.pushPath(".status");

self.add(
domain.hasOwnProperty("status"),
"Domain object MUST have a 'status' property."
);
if (
self.add(
domain.hasOwnProperty("status"),
"Domain object MUST have a 'status' property.",
"page=5",
)
&&
self.isArray(domain.status)
) {
self.add(
domain.status.length > 0,
"'status' array MUST contain at least one value.",
"page=5",
)
}

self.popPath(".status");

Expand All @@ -1742,7 +1767,8 @@ self.validateCommonGTLDDomainProperties = function(domain, name) {
if (
self.add(
domain.hasOwnProperty("notices"),
"Domain object MUST have a 'notices' property."
"Domain object MUST have a 'notices' property.",
"page=5",
)
&&
self.isArray(domain.notices)
Expand All @@ -1761,7 +1787,8 @@ self.validateCommonGTLDDomainProperties = function(domain, name) {
"https://icann.org/epp" === n.href
).length > 0
).length,
"Domain object MUST contain a 'Status Codes' notice containing a link with rel=glossary and href=https://icann.org/epp."
"Domain object MUST contain a 'Status Codes' notice containing a link with rel=glossary and href=https://icann.org/epp.",
"page=5",
);

self.add(
Expand All @@ -1778,7 +1805,8 @@ self.validateCommonGTLDDomainProperties = function(domain, name) {
"https://icann.org/wicf" === n.href
).length > 0
).length,
"Domain object MUST contain a 'RDDS Inaccuracy Complaint Form' notice containing a link with rel=help and href=https://icann.org/wicf."
"Domain object MUST contain a 'RDDS Inaccuracy Complaint Form' notice containing a link with rel=help and href=https://icann.org/wicf.",
"page=7",
);
}

Expand All @@ -1788,7 +1816,8 @@ self.validateCommonGTLDDomainProperties = function(domain, name) {

self.add(
domain.hasOwnProperty("nameservers"),
"Domain object MUST have a 'nameservers' property."
"Domain object MUST have a 'nameservers' property.",
"page=7",
);

self.popPath(".nameservers");
Expand All @@ -1798,20 +1827,23 @@ self.validateCommonGTLDDomainProperties = function(domain, name) {
if (
self.add(
domain.hasOwnProperty("secureDNS"),
"Domain object MUST have a 'secureDNS' property."
"Domain object MUST have a 'secureDNS' property.",
"page=7",
)
&&
self.isObject(domain.secureDNS)
&&
self.add(
domain.secureDNS.hasOwnProperty("delegationSigned"),
"The 'secureDNS' property MUST have a 'delegationSigned' property."
"The 'secureDNS' property MUST have a 'delegationSigned' property.",
"page=7",
)
) {
if (domain.secureDNS.delegationSigned) {
self.add(
["keyData", "dsData"].filter((k) => domain.secureDNS.hasOwnProperty(k)).length,
"The 'secureDNS' property MUST have a 'keyData' or 'dsData' property."
"The 'secureDNS' property MUST have a 'keyData' or 'dsData' property.",
"page=7",
);
}
}
Expand All @@ -1829,11 +1861,13 @@ self.validateGTLDNameProperties = function(object, name) {

if (self.add(
object.hasOwnProperty("ldhName"),
"Object MUST include an 'ldhName' property."
"Object MUST include an 'ldhName' property.",
"page=3",
)) {
self.add(
name.toLowerCase() === object.ldhName.toLowerCase(),
"The 'ldhName' property MUST match the queried-for object name."
"The 'ldhName' property MUST match the queried-for object name.",
"page=3",
);
}

Expand All @@ -1850,11 +1884,13 @@ self.validateGTLDNameProperties = function(object, name) {

if (self.add(
object.hasOwnProperty("unicodeName"),
"Object MUST include an 'unicodeName' property."
"Object MUST include an 'unicodeName' property.",
"page=3",
)) {
self.add(
name.toLowerCase() === object.unicodeName.toLowerCase(),
"The 'unicodeName' property MUST match the queried-for object name."
"The 'unicodeName' property MUST match the queried-for object name.",
"page=3",
);
}

Expand All @@ -1879,7 +1915,8 @@ self.validateGTLDRegistrarEntity = function(rar) {

self.add(
rar.hasOwnProperty("handle"),
"The registrar entity MUST have a 'handle' property."
"The registrar entity MUST have a 'handle' property.",
"page=8",
);

self.popPath(".handle");
Expand All @@ -1888,7 +1925,8 @@ self.validateGTLDRegistrarEntity = function(rar) {

if (!self.add(
rar.hasOwnProperty("publicIds"),
"The registrar entity MUST have the 'publicIds' property."
"The registrar entity MUST have the 'publicIds' property.",
"page=4",
)) return;

self.pushPath("[?('IANA Registrar ID' == @.type)][0]");
Expand All @@ -1899,7 +1937,8 @@ self.validateGTLDRegistrarEntity = function(rar) {
const ids = rar.publicIds.filter((id) => type == id.type);
if (!self.add(
1 === ids.length,
"The registrar entity MUST have exactly one Public ID object with the '" + type + "' type."
"The registrar entity MUST have exactly one Public ID object with the '" + type + "' type.",
"page=4",
)) return;

self.popPath(".type");
Expand All @@ -1908,11 +1947,13 @@ self.validateGTLDRegistrarEntity = function(rar) {

if (self.add(
self.isString(ids[0].identifier) && self.isInteger(parseInt(ids[0].identifier)),
"The 'type' property of the Public ID object MUST be a string containing an integer."
"The 'type' property of the Public ID object MUST be a string containing an integer.",
"page=4",
)) {
self.add(
parseInt(ids[0].identifier) === parseInt(rar.handle),
"The 'handle' property MUST be equal to the IANA Registrar ID."
"The 'handle' property MUST be equal to the IANA Registrar ID.",
"page=4",
)
}

Expand Down Expand Up @@ -1943,7 +1984,8 @@ self.validateGTLDRegistrarEntity = function(rar) {

if (self.add(
abuse !== undefined,
"Registrar entity object MUST have an entity with the 'abuse' role."
"Registrar entity object MUST have an entity with the 'abuse' role.",
"page=5",
)) {
self.pushPath("[" + i + "]");

Expand All @@ -1959,7 +2001,8 @@ self.validateGTLDRegistrarEntity = function(rar) {

["TEL", "EMAIL"].forEach((t) => self.add(
seen.hasOwnProperty(t),
"Registrar entity's abuse entity MUST have a '" + t + "' property."
"Registrar entity's abuse entity MUST have a '" + t + "' property.",
"page=5",
));

self.popPath(".vcardArray[1]");
Expand All @@ -1976,12 +2019,17 @@ self.validateGTLDRegistrarEntity = function(rar) {
if (
self.add(
rar.hasOwnProperty("links"),
"Registrar entity MUST have a 'links' property."
"Registrar entity MUST have a 'links' property.",
"page=5",
)
&&
self.isArray(rar.links)
) {
self.msg("TODO - validate link objects once the RDAP Response Profile makes sense.")
self.add(
rar.links.length > 0,
"Registrar entity 'links' property MUST contain at least one entry.",
"page=5",
);
}

self.popPath(".links");
Expand Down Expand Up @@ -2601,7 +2649,12 @@ self.setTestCompleteCallback = function(callback) {
self.add = function(result, message, ref) {
if (false === result) self.errors++;

self.resultCallback(result, message, self.getPath(), ref ? self.ref(ref) : undefined);
self.resultCallback(
result,
message,
self.getPath(),
self.ref(ref),
);

return result;
};
Expand Down Expand Up @@ -2651,5 +2704,7 @@ self.objectClassNameReferences = {
* Generate a URL given the current specification and a fragment.
*/
self.ref = function(fragment, alternateSpec=null) {
return self.referenceBase + self.referenceURLs[alternateSpec ? alternateSpec : self.currentSpec()] + "#" + fragment;
return self.referenceBase
+ self.referenceURLs[alternateSpec ? alternateSpec : self.currentSpec()]
+ (fragment ? "#" + fragment : "");
}

0 comments on commit 48c6353

Please sign in to comment.