Repository navigation
fix: reject invalid DMARC_BUILDER policy and tag values - #5013
Merged
TomOnTime merged 1 commit intoOct 18, 2026
Merged
Conversation
The checks for policy, subdomainPolicy, nonexistentSubdomainPolicy, publicSuffixDomain and testMode were written as `!value.x === "lit"`, which parses as `(!value.x) === "lit"` and is never true. A typo such as policy: "quarentine" was written into the TXT record unchanged. Compare the value itself, and for the optional fields only when it is set. Add TestDMARCBuilderValues, which runs the script text with ExecuteJavascriptString.
TomOnTime
approved these changes
Oct 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DMARC_BUILDERhas checks forpolicy,subdomainPolicy,nonexistentSubdomainPolicy,publicSuffixDomainandtestMode, but none of them ever fires. A typo in one of those values goes into the TXT record unchanged.Config:
dnscontrol checkprintsNo errors., anddnscontrol print-irshows the record_dmarcwith the TXT valuev=DMARC1; p=quarentine; rua=mailto:dmarc@example.com.previewwould create that record. After the fixdnscontrol checkstops withexecuting dnsconfig.js: Invalid DMARC policy. The other four options behave the same way. For exampletestMode: "yes"is written ast=yes. The documented values are the ones in DMARC_BUILDER.md.Cause: each check is written as
!value.x === "lit", which parses as(!value.x) === "lit". A boolean never equals a string, so the condition is always false and thethrowis dead code. It is the same in all five places: policy (L1866-L1872), subdomainPolicy (L1879-L1885), nonexistentSubdomainPolicy (L1891-L1897), publicSuffixDomain (L1994-L2000) and testMode (L2008-L2010).Fix: compare the value itself and join the alternatives with
&&: throw when the value is none of the allowed ones.policyalready defaults to"none"above its check.subdomainPolicyandnonexistentSubdomainPolicyare optional, so their checks start withvalue.x &&. The other two sit inside anif (value.x)already. Configs that carry a value outside the documented list now failcheckinstead of publishing it. Matching is case-sensitive, like the documented values and thealignmentSPFandalignmentDKIMoptions, sopolicy: "Reject"now fails too. This is a behaviour change for those configs; I can mark the title with!if you prefer.The new
TestDMARCBuilderValuesinpkg/js/js_test.gohas two rows that must pass (onlypolicy, and every option with a valid value) and one row per option with a bad value. It is not aTestErrorsrow: that table passes the script text toExecuteJavaScript, which expects a file name, so the helper is never reached there. The test callsExecuteJavascriptString.Before the fix the five bad-value rows fail and the two valid rows pass. After the fix all 7 pass, and the package passes. Putting back any one of the five conditions fails its own bad-value row. Dropping the
value.x &&guard fromsubdomainPolicyornonexistentSubdomainPolicymakes an unset option throw, and the rows that do not set it fail.gofmt -l,go vet ./pkg/js/andgit diff --checkare clean, and prettier 3.9.9 leaveshelpers.jsunchanged. No generated file changes.Overlap checked: searched open and closed issues and PRs for
DMARC_BUILDER,DMARC policy validationandDMARC invalid policy, and open PRs forDMARC. #4823 and #4794 changed this helper, #4855 fixed its TypeScript types, and #4378 and #4370 are issues about it. None touches these checks.