From 9316517291d17cf4911a3e65f76d3b10ce5c8106 Mon Sep 17 00:00:00 2001 From: Patrik Kernstock Date: Sat, 14 Aug 2021 19:43:39 +0100 Subject: [PATCH] DMARC_BUILDER: specify version, use values when specified (#1236) * Allow version, use values when specified * Updated DMARC_BUILDER docs --- docs/_functions/record/DMARC_BUILDER.md | 1 + pkg/js/helpers.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/_functions/record/DMARC_BUILDER.md b/docs/_functions/record/DMARC_BUILDER.md index 5c0aab29b..5149d19ea 100644 --- a/docs/_functions/record/DMARC_BUILDER.md +++ b/docs/_functions/record/DMARC_BUILDER.md @@ -71,6 +71,7 @@ insecure IN TXT "v=DMARC1; p=none; ruf=mailto:mailauth-reports@example.com; ### Parameters * `label:` The DNS label for the DMARC record (`_dmarc` prefix is added, default: `'@'`) +* `version:` The DMARC version to be used (default: `DMARC1`) * `policy:` The DMARC policy (`p=`), must be one of `'none'`, `'quarantine'`, `'reject'` * `subdomainPolicy:` The DMARC policy for subdomains (`sp=`), must be one of `'none'`, `'quarantine'`, `'reject'` (optional) * `alignmentSPF:` `'strict'`/`'s'` or `'relaxed'`/`'r'` alignment for SPF (`aspf=`, default: `'r'`) diff --git a/pkg/js/helpers.js b/pkg/js/helpers.js index b11859383..6097abe37 100644 --- a/pkg/js/helpers.js +++ b/pkg/js/helpers.js @@ -965,6 +965,7 @@ function CAA_BUILDER(value) { // DMARC_BUILDER takes an object: // label: The DNS label for the DMARC record (_dmarc prefix is added; default: '@') +// version: The DMARC version, by default DMARC1 (optional) // policy: The DMARC policy (p=), must be one of 'none', 'quarantine', 'reject' // subdomainPolicy: The DMARC policy for subdomains (sp=), must be one of 'none', 'quarantine', 'reject' (optional) // alignmentSPF: 'strict'/'s' or 'relaxed'/'r' alignment for SPF (aspf=, default: 'r') @@ -984,6 +985,10 @@ function DMARC_BUILDER(value) { value.label = '@'; } + if (!value.version) { + value.version = 'DMARC1'; + } + var label = '_dmarc'; if (value.label !== '@') { label += '.' + value.label; @@ -997,7 +1002,8 @@ function DMARC_BUILDER(value) { throw 'Invalid DMARC policy'; } - var record = ['v=DMARC1']; + var record = []; + record.push('v=' + value.version); record.push('p=' + value.policy); // Subdomain policy @@ -1045,7 +1051,7 @@ function DMARC_BUILDER(value) { } // Percentage - if (value.percent && value.percent != 100) { + if (value.percent) { record.push('pct=' + value.percent); } @@ -1082,7 +1088,7 @@ function DMARC_BUILDER(value) { } // Failure report format - if (value.ruf && value.failureFormat && value.failureFormat !== 'afrf') { + if (value.ruf && value.failureFormat) { record.push('rf=' + value.failureFormat); }