FEATURE: Add TTL() support to CAA_BUILDER() (#2978)

This commit is contained in:
Jeffrey Cafferata 2024-05-29 22:36:26 +02:00 committed by GitHub
parent b786b0efe4
commit 1f4c4c65f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 5 deletions

View file

@ -456,10 +456,11 @@ declare function CAA(name: string, tag: "issue" | "issuewild" | "iodef", value:
* * `issue_critical:` This can be `true` or `false`. If enabled and CA does not support this record, then certificate issue will be refused. (Optional. Default: `false`)
* * `issuewild:` An array of CAs which are allowed to issue wildcard certificates. (Can be simply `"none"` to refuse issuing wildcard certificates for all CAs)
* * `issuewild_critical:` This can be `true` or `false`. If enabled and CA does not support this record, then certificate issue will be refused. (Optional. Default: `false`)
* * `ttl:` Input for `TTL` method (optional)
*
* @see https://docs.dnscontrol.org/language-reference/domain-modifiers/caa_builder
*/
declare function CAA_BUILDER(opts: { label?: string; iodef: string; iodef_critical?: boolean; issue: string[]; issue_critical?: boolean; issuewild: string[]; issuewild_critical?: boolean }): DomainModifier;
declare function CAA_BUILDER(opts: { label?: string; iodef: string; iodef_critical?: boolean; issue: string[]; issue_critical?: boolean; issuewild: string[]; issuewild_critical?: boolean; ttl?: Duration }): DomainModifier;
/**
* `CF_REDIRECT` uses Cloudflare-specific features ("Forwarding URL" Page Rules) to

View file

@ -8,6 +8,7 @@ parameters:
- issue_critical
- issuewild
- issuewild_critical
- ttl
parameters_object: true
parameter_types:
label: string?
@ -17,6 +18,7 @@ parameter_types:
issue_critical: boolean?
issuewild: string[]
issuewild_critical: boolean?
ttl: Duration?
---
DNSControl contains a `CAA_BUILDER` which can be used to simply create
@ -114,3 +116,4 @@ which in turns yield the following records:
* `issue_critical:` This can be `true` or `false`. If enabled and CA does not support this record, then certificate issue will be refused. (Optional. Default: `false`)
* `issuewild:` An array of CAs which are allowed to issue wildcard certificates. (Can be simply `"none"` to refuse issuing wildcard certificates for all CAs)
* `issuewild_critical:` This can be `true` or `false`. If enabled and CA does not support this record, then certificate issue will be refused. (Optional. Default: `false`)
* `ttl:` Input for `TTL` method (optional)

View file

@ -1503,6 +1503,7 @@ function SPF_BUILDER(value) {
// iodef_critical: Boolean if sending report is required/critical. If not supported, certificate should be refused. (optional)
// issue: List of CAs which are allowed to issue certificates for the domain (creates one record for each).
// issuewild: Allowed CAs which can issue wildcard certificates for this domain. (creates one record for each)
// ttl: The time for TTL, integer or string. (default: not defined, using DefaultTTL)
function CAA_BUILDER(value) {
if (!value.label) {
@ -1522,13 +1523,19 @@ function CAA_BUILDER(value) {
throw 'CAA_BUILDER requires at least one entry at issue or issuewild';
}
var CAA_TTL = function () {};
if (value.ttl) {
CAA_TTL = TTL(value.ttl);
}
r = []; // The list of records to return.
if (value.iodef) {
if (value.iodef_critical) {
r.push(CAA(value.label, 'iodef', value.iodef, CAA_CRITICAL));
r.push(
CAA(value.label, 'iodef', value.iodef, CAA_CRITICAL, CAA_TTL)
);
} else {
r.push(CAA(value.label, 'iodef', value.iodef));
r.push(CAA(value.label, 'iodef', value.iodef, CAA_TTL));
}
}
@ -1538,7 +1545,7 @@ function CAA_BUILDER(value) {
flag = CAA_CRITICAL;
}
for (var i = 0, len = value.issue.length; i < len; i++)
r.push(CAA(value.label, 'issue', value.issue[i], flag));
r.push(CAA(value.label, 'issue', value.issue[i], flag, CAA_TTL));
}
if (value.issuewild) {
@ -1547,7 +1554,9 @@ function CAA_BUILDER(value) {
flag = CAA_CRITICAL;
}
for (var i = 0, len = value.issuewild.length; i < len; i++)
r.push(CAA(value.label, 'issuewild', value.issuewild[i], flag));
r.push(
CAA(value.label, 'issuewild', value.issuewild[i], flag, CAA_TTL)
);
}
return r;