2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-08-30 22:05:21 +00:00

Merge pull request #1260 from Aravindh-Raju/aravindhr/add-naptr-record-validations

Add additional NAPTR validations
This commit is contained in:
Nicholas Spadaccino
2023-05-30 17:15:09 -04:00
committed by GitHub
5 changed files with 26 additions and 19 deletions

View File

@@ -169,6 +169,8 @@ trait DnsJsonProtocol extends JsonValidation {
}
def checkDomainNameLen(s: String): Boolean = s.length <= 255
def validateNaptrFlag(flag: String): Boolean = flag == "U" || flag == "S" || flag == "A" || flag == "P"
def validateNaptrRegexp(regexp: String): Boolean = regexp.startsWith("!") && regexp.endsWith("!") || regexp == ""
def nameContainsDots(s: String): Boolean = s.contains(".")
def nameDoesNotContainSpaces(s: String): Boolean = !s.contains(" ")
@@ -514,7 +516,7 @@ trait DnsJsonProtocol extends JsonValidation {
(js \ "flags")
.required[String]("Missing NAPTR.flags")
.check(
"NAPTR.flags must be less than 2 characters" -> (_.length < 2)
"Invalid NAPTR.flag. Valid NAPTR flag value must be U, S, A or P" -> validateNaptrFlag
),
(js \ "service")
.required[String]("Missing NAPTR.service")
@@ -524,7 +526,7 @@ trait DnsJsonProtocol extends JsonValidation {
(js \ "regexp")
.required[String]("Missing NAPTR.regexp")
.check(
"NAPTR.regexp must be less than 255 characters" -> checkDomainNameLen
"Invalid NAPTR.regexp. Valid NAPTR regexp value must start and end with '!' or can be empty" -> validateNaptrRegexp
),
(js \ "replacement")

View File

@@ -1480,11 +1480,11 @@ class RecordSetRoutingSpec
}
"return errors for invalid NAPTR record data" in {
val validFlags = List("U", "S", "A", "P")
validateErrors(
testRecordType(
RecordType.NAPTR,
("replacement" -> Random.alphanumeric.take(260).mkString) ~~
// should check regex better
("regexp" -> Random.alphanumeric.take(260).mkString) ~~
("service" -> Random.alphanumeric.take(260).mkString) ~~
("flags" -> Random.alphanumeric.take(2).mkString) ~~
@@ -1493,18 +1493,18 @@ class RecordSetRoutingSpec
),
"NAPTR.order must be an unsigned 16 bit number",
"NAPTR.preference must be an unsigned 16 bit number",
"NAPTR.flags must be less than 2 characters",
"Invalid NAPTR.flag. Valid NAPTR flag value must be U, S, A or P",
"NAPTR.service must be less than 255 characters",
"NAPTR.regexp must be less than 255 characters",
"Invalid NAPTR.regexp. Valid NAPTR regexp value must start and end with '!' or can be empty",
"NAPTR.replacement must be less than 255 characters"
)
validateErrors(
testRecordType(
RecordType.NAPTR,
("regexp" -> Random.alphanumeric.take(10).mkString) ~~
("regexp" -> "") ~~
("service" -> Random.alphanumeric.take(10).mkString) ~~
("replacement" -> Random.alphanumeric.take(10).mkString) ~~
("flags" -> Random.alphanumeric.take(1).mkString) ~~
("flags" -> validFlags.take(1).mkString) ~~
("order" -> -1) ~~
("preference" -> -1)
),

View File

@@ -538,6 +538,8 @@ input[type="file"] {
padding: 0px;
margin: 0px;
}
/* Ending of css override for cron library and it's associated elements used in zone sync scheduling */
#set-dropdown-width {
width: 4em;
}

View File

@@ -29,6 +29,7 @@ angular.module('controller.records', [])
$scope.recordTypes = ['A', 'AAAA', 'CNAME', 'DS', 'MX', 'NS', 'PTR', 'SRV', 'NAPTR', 'SSHFP', 'TXT'];
$scope.readRecordTypes = ['A', 'AAAA', 'CNAME', 'DS', 'MX', 'NS', 'PTR', "SOA", 'SRV', 'NAPTR', 'SSHFP', 'TXT'];
$scope.selectedRecordTypes = [];
$scope.naptrFlags = ["U", "S", "A", "P"];
$scope.sshfpAlgorithms = [{name: '(1) RSA', number: 1}, {name: '(2) DSA', number: 2}, {name: '(3) ECDSA', number: 3},
{name: '(4) Ed25519', number: 4}];
$scope.sshfpTypes = [{name: '(1) SHA-1', number: 1}, {name: '(2) SHA-256', number: 2}];

View File

@@ -324,7 +324,7 @@
required/>
</td>
<td ng-class="{'has-error': addRecordForm.$submitted && addRecordForm['preference_' + ($index)].$invalid}">
<input name="weight_{{$index}}"
<input name="preference_{{$index}}"
class="form-control"
ng-model="item.preference"
ng-class="recordModal.details.class"
@@ -332,15 +332,17 @@
required/>
</td>
<td ng-class="{'has-error': addRecordForm.$submitted && addRecordForm['flags_' + ($index)].$invalid}">
<input name="flags_{{$index}}"
class="form-control"
ng-model="item.flags"
ng-class="recordModal.details.class"
ng-readonly="recordModal.details.readOnly"
required/>
<select name="flags_{{$index}}"
class="form-control"
id="set-dropdown-width"
ng-model="item.flags"
ng-class="recordModal.details.class"
ng-options="flag for flag in naptrFlags"
required>
</select>
</td>
<td ng-class="{'has-error': addRecordForm.$submitted && addRecordForm['service_' + ($index)].$invalid}">
<input name="flags_{{$index}}"
<input name="service_{{$index}}"
class="form-control"
ng-model="item.service"
ng-class="recordModal.details.class"
@@ -348,14 +350,14 @@
required/>
</td>
<td ng-class="{'has-error': addRecordForm.$submitted && addRecordForm['regexp_' + ($index)].$invalid}">
<input name="flags_{{$index}}"
<input name="regexp_{{$index}}"
class="form-control"
ng-model="item.regexp"
ng-class="recordModal.details.class"
ng-readonly="recordModal.details.readOnly"/>
</td>
<td ng-class="{'has-error': addRecordForm.$submitted && addRecordForm['replacement_' + ($index)].$invalid}">
<input name="target_{{$index}}"
<input name="replacement_{{$index}}"
class="form-control"
ng-model="item.replacement"
ng-class="recordModal.details.class"