fix(check): two false-confident answers neither author could see from inside the module

mail-transport recorded truncation but never surfaced it, so a policy file cut off at the 32 KB
limit could still be reported as mode=enforce from a partial parse. hardening's CAA comparison
matched issuer tokens blindly, so a certificate naming only its profile (CN: R11, no O) against a
CAA record for another CA produced "a renewal would be refused" out of nothing. Both now say
they could not judge instead.
This commit is contained in:
hoelee committed 2026-11-10 19:32:51 +08:00
1 parent 8925d10424
commit 85ec724928
4 files changed
+72

No files matched your search

+25
View File
@@ -671,3 +671,28 @@ test('no scenario in this file can reach state "fail"', () => {
assert.ok(['ok', 'warn', 'not-evaluated'].includes(result.state));
}
});
test('a CAA mismatch is never claimed from a profile identifier like R11', () => {
// Let's Encrypt certificates often carry only "R11"/"E6" as CN, with no O and no company name.
// Comparing that to a CAA record naming another CA would invent "your renewal would be refused".
const result = analyseHardening(
facts({
certificate: { issuer: { CN: 'R11' } },
caa: { name: 'example.com', records: [{ critical: 0, issue: 'digicert.com' }] }
}),
{ now: NOW }
);
assert.equal(result.findings.find((f) => f.code === 'hardening_caa_issuer_mismatch'), undefined);
assert.ok(result.findings.some((f) => f.code === 'hardening_caa_not_compared'));
});
test('a real company name still produces the mismatch warning', () => {
const result = analyseHardening(
facts({
certificate: { issuer: LETS_ENCRYPT },
caa: { name: 'example.com', records: [{ critical: 0, issue: 'digicert.com' }] }
}),
{ now: NOW }
);
assert.ok(result.findings.some((f) => f.code === 'hardening_caa_issuer_mismatch'));
});
+16
View File
@@ -737,3 +737,19 @@ test('buildSummary has a sentence for the enforce case that names the file, not
assert.match(summary, /policy file says mode=enforce/);
assert.doesNotMatch(summary, /TXT record (protects|is enforcing)/);
});
test('a policy file cut off at the size limit is not judged, because half a policy reads like a whole one', () => {
// The header lines arrive before the mx: list, so a truncated file still parses. Claiming
// mode=enforce from it would promise protection the sender does not get.
const result = analyseMailTransport(
gatheredFixture({
mtaSts: { checked: true, present: true, valid: true, record: 'v=STSv1; id=20261110T000000', id: '20261110T000000', count: 1 },
policy: { ...policyOk(), truncated: true }
}),
{ now: NOW }
);
assert.ok(codes(result).includes('mta_sts_policy_truncated'));
assert.ok(!codes(result).includes('mta_sts_mode_enforce'));
assert.equal(result.findings.find((finding) => finding.code === 'mta_sts_policy_truncated').level, 'info');
assert.equal(result.state, 'not-evaluated');
});