From 1f4c4c65f50bb99d0c57ff95384f502551bf07c0 Mon Sep 17 00:00:00 2001 From: Jeffrey Cafferata Date: Wed, 29 May 2024 22:36:26 +0200 Subject: [PATCH] FEATURE: Add TTL() support to CAA_BUILDER() (#2978) --- commands/types/dnscontrol.d.ts | 3 ++- .../domain-modifiers/CAA_BUILDER.md | 3 +++ pkg/js/helpers.js | 17 +++++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/commands/types/dnscontrol.d.ts b/commands/types/dnscontrol.d.ts index c868413a9..79f8b921e 100644 --- a/commands/types/dnscontrol.d.ts +++ b/commands/types/dnscontrol.d.ts @@ -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 diff --git a/documentation/language-reference/domain-modifiers/CAA_BUILDER.md b/documentation/language-reference/domain-modifiers/CAA_BUILDER.md index dd1c9274d..3d3c0662b 100644 --- a/documentation/language-reference/domain-modifiers/CAA_BUILDER.md +++ b/documentation/language-reference/domain-modifiers/CAA_BUILDER.md @@ -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) diff --git a/pkg/js/helpers.js b/pkg/js/helpers.js index 1ecb348ef..669702066 100644 --- a/pkg/js/helpers.js +++ b/pkg/js/helpers.js @@ -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;