Repository Public
1import assert from "node:assert/strict"2import { test } from "node:test"3import { dedupeAddrs, formatAddress, initials, isValidEmail, parseAddressList, spoofedDisplayName } from "./address"4import { attachmentRisk, canPreviewInline, extensionOf, formatSize, safeFileName } from "./attachments"5import { parseAuthenticationResults, summarizeAuth } from "./authResults"6import { buildForwardQuote, buildReplyQuote, decodeEntities, forwardSubject, htmlToText, quoteText, replyRecipients, replySubject, textToHtml, threadHeaders, type ReplyLabels } from "./compose"7import { hostClaimedByText, linkWarnings, safeLinkHref } from "./links"8import { asctime, buildMbox, buildZip, crc32, escapeFromLines, uniqueNames } from "./mbox"9import { emptySearch, parseSearch, searchToConditions, stringifySearch } from "./search"10import { emptySieveConfig, generateSieve, parseSieveConfig, sieveQuote, type SieveConfig } from "./sieve"1112const dec = new TextDecoder()13const enc = new TextEncoder()1415// ---------------------------------------------------------------- adresses16test("adresses : analyse d'une saisie libre", () => {17 const r = parseAddressList(`Alice <alice@example.org>, "Tremblay, Bob" <bob@example.org>; carol@example.org\n<dave@example.org>, pas une adresse, "x" <mauvais@>`)18 assert.deepEqual(r.valid, [{ name: "Alice", email: "alice@example.org" }, { name: "Tremblay, Bob", email: "bob@example.org" }, { email: "carol@example.org" }, { email: "dave@example.org" }])19 assert.deepEqual(r.invalid, ["pas une adresse", `"x" <mauvais@>`])20 assert.deepEqual(parseAddressList("mailto:a@b.ca").valid, [{ email: "a@b.ca" }])21 assert.deepEqual(parseAddressList(`"A \\"B\\" C" <a@b.ca>`).valid, [{ name: `A "B" C`, email: "a@b.ca" }])22})23test("adresses : validation, formatage, initiales, dédoublonnage", () => {24 for (const ok of ["a@b.ca", "prenom.nom+tag@sous.domaine.example", "x_y@stg.spboucher.ai"]) assert.ok(isValidEmail(ok), ok)25 for (const ko of ["", "a", "a@", "@b.ca", "a@b", "a b@c.ca", "a@b..ca", "a@-b.ca", "a<b@c.ca"]) assert.ok(!isValidEmail(ko), ko)26 assert.equal(formatAddress({ name: "Tremblay, Bob", email: "b@x.ca" }), `"Tremblay, Bob" <b@x.ca>`)27 assert.equal(formatAddress({ name: "Alice", email: "a@x.ca" }), "Alice <a@x.ca>")28 assert.equal(formatAddress({ email: "a@x.ca" }), "a@x.ca")29 assert.equal(initials({ name: "Simon-Pierre Boucher", email: "s@x.ca" }), "SB")30 assert.equal(initials({ email: "zoe@x.ca" }), "Z")31 assert.deepEqual(dedupeAddrs([{ email: "A@x.ca" }, { name: "a", email: "a@x.ca" }, { email: "b@x.ca" }]).map((a) => a.email), ["A@x.ca", "b@x.ca"])32})33test("usurpation du nom affiché", () => {34 assert.equal(spoofedDisplayName({ name: "service@desjardins.com", email: "x@evil.example" }), "name-has-other-address")35 assert.equal(spoofedDisplayName({ name: "Desjardins (desjardins.com)", email: "x@evil.example" }), "name-has-other-domain")36 assert.equal(spoofedDisplayName({ name: "alice@example.org", email: "alice@example.org" }), null)37 assert.equal(spoofedDisplayName({ name: "Infolettre example.org", email: "news@mail.example.org" }), null)38 assert.equal(spoofedDisplayName({ name: "Alice Tremblay", email: "alice@example.org" }), null)39 assert.equal(spoofedDisplayName({ email: "alice@example.org" }), null)40})4142// ---------------------------------------------------------------- liens43test("liens : protocoles permis", () => {44 assert.equal(safeLinkHref("https://example.org/a b"), "https://example.org/a%20b")45 assert.equal(safeLinkHref("mailto:a@b.ca?subject=x"), "mailto:a@b.ca?subject=x")46 for (const bad of ["javascript:alert(1)", "java\tscript:alert(1)", " \u0001javascript:alert(1)", "JAVASCRIPT:alert(1)", "data:text/html,x", "vbscript:x", "file:///etc/passwd", "/relatif", "example.org", "", null, "blob:https://x/y", "ftp://x/y"]) assert.equal(safeLinkHref(bad), null, String(bad))47})48test("liens : libellé trompeur", () => {49 assert.equal(hostClaimedByText("www.desjardins.com"), "www.desjardins.com")50 assert.equal(hostClaimedByText("https://accesd.desjardins.com/connexion?x=1"), "accesd.desjardins.com")51 assert.equal(hostClaimedByText("Cliquez ici"), null)52 assert.equal(hostClaimedByText("Allez sur https://banque.example.ca maintenant"), "banque.example.ca")53 assert.equal(hostClaimedByText("version 2.0"), null)54 assert.deepEqual(linkWarnings("www.desjardins.com", "https://evil.example/d"), ["text-domain-mismatch"])55 assert.deepEqual(linkWarnings("desjardins.com", "https://www.desjardins.com/"), [])56 assert.deepEqual(linkWarnings("accesd.desjardins.com", "https://desjardins.com/"), [])57 assert.deepEqual(linkWarnings("Cliquez ici", "https://example.org/"), [])58 assert.deepEqual(linkWarnings("ici", "https://paypal.com@evil.example/"), ["credentials-in-url"])59 assert.deepEqual(linkWarnings("ici", "http://192.168.1.10/x"), ["ip-host"])60 assert.deepEqual(linkWarnings("ici", "https://xn--pypal-4ve.com/"), ["punycode-host"])61 assert.deepEqual(linkWarnings("a@b.ca", "mailto:c@d.ca"), [])62})6364// ---------------------------------------------------------------- pièces jointes65test("pièces jointes : types dangereux et double extension", () => {66 for (const n of ["setup.exe", "script.JS", "ecran.scr", "macro.docm", "page.html", "page.HTM", "image.svg", "raccourci.lnk", "install.msi", "a.ps1", "a.vbs", "a.jar", "a.bat", "a.xlsm", "a.iso", "a.hta", "a.sh"]) assert.equal(attachmentRisk(n, "application/octet-stream"), "dangerous-type", n)67 assert.equal(attachmentRisk("facture.pdf.exe", null), "double-extension")68 assert.equal(attachmentRisk("photo.jpg.js", null), "double-extension")69 assert.equal(attachmentRisk("facture\u202efdp.exe", null), "dangerous-type")70 assert.equal(attachmentRisk("rapport\u202eexe.pdf", "application/pdf"), "double-extension")71 assert.equal(attachmentRisk("sans-extension", "text/html"), "dangerous-type")72 assert.equal(attachmentRisk("x.bin2", "application/x-msdownload"), "dangerous-type")73 for (const n of ["rapport.pdf", "photo.jpeg", "notes.txt", "tableau.xlsx", "archive.zip", "présentation.pptx", "données.csv"]) assert.equal(attachmentRisk(n, "application/octet-stream"), null, n)74 assert.equal(extensionOf("a.tar.gz"), "gz")75 assert.equal(extensionOf(".bashrc"), "")76 assert.equal(extensionOf("fichier.exe. "), "exe")77})78test("pièces jointes : aperçu en ligne, tailles, noms", () => {79 for (const t of ["image/png", "image/jpeg", "image/gif", "image/webp"]) assert.ok(canPreviewInline(t))80 for (const t of ["image/svg+xml", "text/html", "application/pdf", "image/tiff", null, ""]) assert.ok(!canPreviewInline(t))81 assert.equal(formatSize(0), "0\u00a0o")82 assert.equal(formatSize(1500), "1,5\u00a0ko")83 assert.equal(formatSize(52_000_000, "en"), "52\u00a0MB")84 assert.equal(safeFileName("../../etc/pass:wd"), ".._.._etc_pass_wd")85 assert.equal(safeFileName(""), "fichier")86})8788// ---------------------------------------------------------------- Authentication-Results89test("Authentication-Results : analyse", () => {90 const r = parseAuthenticationResults(`mx1.spboucher.ai;\r\n\tdkim=pass (2048-bit key; secure) header.d=example.org header.s=sel header.b="abc;def";\r\n\tspf=pass (sender is 1.2.3.4) smtp.mailfrom=bounce@example.org;\r\n\tdmarc=pass (policy=reject) header.from=example.org; arc=none`)!91 assert.equal(r.authserv, "mx1.spboucher.ai")92 assert.deepEqual(r.results.map((x) => [x.method, x.result]), [["dkim", "pass"], ["spf", "pass"], ["dmarc", "pass"], ["arc", "none"]])93 assert.equal(r.results[0].props["header.d"], "example.org")94 assert.equal(r.results[0].props["header.b"], "abc;def")95 assert.equal(parseAuthenticationResults("mx.example.org; none")!.results.length, 0)96 assert.equal(parseAuthenticationResults(""), null)97 assert.equal(parseAuthenticationResults(`mx 1; spf=fail reason="not (really) permitted" smtp.mailfrom=x@y.z`)!.results[0].reason, "not (really) permitted")98})99test("Authentication-Results : verdict global", () => {100 const ok = summarizeAuth(["mx1; dkim=pass header.d=example.org; spf=pass smtp.mailfrom=example.org; dmarc=pass header.from=example.org"], "example.org")101 assert.deepEqual([ok.spf, ok.dkim, ok.dmarc, ok.level, ok.dkimDomain], ["pass", "pass", "pass", "ok", "example.org"])102 assert.equal(summarizeAuth(["mx1; dkim=fail header.d=example.org; spf=softfail; dmarc=fail"], "example.org").level, "danger")103 assert.equal(summarizeAuth(["mx1; spf=fail smtp.mailfrom=x@evil.example"], "example.org").level, "danger")104 assert.equal(summarizeAuth(["mx1; spf=pass; dkim=none; dmarc=none"], "example.org").level, "warn")105 assert.equal(summarizeAuth(["mx1; spf=softfail; dkim=pass header.d=example.org"], "example.org").level, "warn")106 assert.deepEqual(summarizeAuth([], "example.org"), { empty: true, level: "unknown" })107 // seul le premier en-tête (ajouté par notre serveur) compte : un en-tête forgé plus bas est ignoré108 const forged = summarizeAuth(["mx1.spboucher.ai; spf=fail; dkim=fail; dmarc=fail", "mx1.spboucher.ai; spf=pass; dkim=pass; dmarc=pass"], "example.org")109 assert.equal(forged.level, "danger")110 assert.equal(summarizeAuth(["forged.example; spf=pass; dkim=pass; dmarc=pass"], "example.org", "mx1.spboucher.ai").level, "unknown")111 // plusieurs signatures : celle alignée sur le domaine de l'expéditeur prime112 const multi = summarizeAuth(["mx1; dkim=fail header.d=liste.example; dkim=pass header.d=example.org; spf=pass; dmarc=pass"], "example.org")113 assert.deepEqual([multi.dkim, multi.dkimDomain], ["pass", "example.org"])114})115116// ---------------------------------------------------------------- Sieve117test("Sieve : génération des règles", () => {118 const cfg: SieveConfig = {119 rules: [120 { id: "1", name: "Factures", enabled: true, match: "any", conditions: [{ field: "from", op: "contains", value: "factures@" }, { field: "subject", op: "contains", value: 'Facture "2026"' }], actions: [{ type: "markRead" }, { type: "move", folder: "Comptabilité/Factures" }] },121 { id: "2", name: "Pub", enabled: true, match: "all", conditions: [{ field: "to", op: "is", value: "promo@example.org" }], actions: [{ type: "trash" }] },122 { id: "3", name: "Important", enabled: true, match: "all", conditions: [{ field: "subject", op: "contains", value: "urgent" }], actions: [{ type: "flag" }] },123 { id: "4", name: "désactivée", enabled: false, match: "all", conditions: [{ field: "subject", op: "contains", value: "x" }], actions: [{ type: "trash" }] },124 { id: "5", name: "incomplète", enabled: true, match: "all", conditions: [{ field: "subject", op: "contains", value: " " }], actions: [{ type: "trash" }] },125 ],126 vacation: emptySieveConfig().vacation,127 }128 const s = generateSieve(cfg, "Deleted Items")129 assert.match(s, /^# SP Mail/)130 assert.match(s, /require \["fileinto", "imap4flags", "mailbox"\];/)131 assert.ok(s.includes(`if anyof (address :contains "from" "factures@", header :contains "subject" "Facture \\"2026\\"") {\r\n addflag "\\\\Seen";\r\n fileinto :create "Comptabilité/Factures";\r\n stop;\r\n}`), s)132 assert.ok(s.includes(`if address :is ["to", "cc"] "promo@example.org" {\r\n fileinto "Deleted Items";\r\n stop;\r\n}`), s)133 assert.ok(s.includes(`if header :contains "subject" "urgent" {\r\n addflag "\\\\Flagged";\r\n}`), s)134 assert.ok(!s.includes("désactivée") && !s.includes("incomplète"))135 assert.ok(!/[^\r]\n/.test(s), "fins de ligne CRLF")136 assert.deepEqual(parseSieveConfig(s), cfg, "la configuration se relit à l'identique")137})138test("Sieve : réponse automatique, bornes de dates, injection impossible", () => {139 const cfg: SieveConfig = { rules: [], vacation: { enabled: true, subject: "Absent", text: 'De retour lundi.\n"; redirect "evil@example.org"; #', from: "2026-12-20", to: "2027-01-03", days: 3 } }140 const s = generateSieve(cfg)141 assert.match(s, /require \["date", "relational", "vacation"\];/)142 assert.ok(s.includes(`if allof (currentdate :value "ge" "date" "2026-12-20", currentdate :value "le" "date" "2027-01-03") {`))143 assert.ok(s.includes(`vacation :days 3 :subject "Absent" "De retour lundi.\r\n\\"; redirect \\"evil@example.org\\"; #";`), s)144 assert.ok(!/^\s*redirect/m.test(s))145 const open = generateSieve({ rules: [], vacation: { enabled: true, subject: "", text: "Absent.", days: 99 } })146 assert.ok(open.includes(`vacation :days 30 "Absent.";`) && !open.includes("currentdate"))147 assert.ok(!generateSieve({ rules: [], vacation: { enabled: true, subject: "x", text: " " } }).includes("vacation"))148 assert.equal(sieveQuote('a\\b"c'), '"a\\\\b\\"c"')149 assert.equal(parseSieveConfig('require ["fileinto"];\r\nkeep;'), null)150 assert.equal(parseSieveConfig("# spmail-config: pas-du-base64-json"), null)151})152153// ---------------------------------------------------------------- mbox / zip154test("mbox : séparateurs, échappement « From », fin de message", () => {155 assert.equal(asctime(new Date(Date.UTC(2026, 10, 9, 2, 4, 5))), "Mon Nov 9 02:04:05 2026")156 const raw = enc.encode("From: a@x.ca\r\nSubject: t\r\n\r\nFrom the start\n>From quoted\n>>From deeper\nFromage\n From spaced\nfin")157 assert.equal(dec.decode(escapeFromLines(raw)), "From: a@x.ca\r\nSubject: t\r\n\r\n>From the start\n>>From quoted\n>>>From deeper\nFromage\n From spaced\nfin")158 const same = enc.encode("rien à échapper\n")159 assert.equal(escapeFromLines(same), same)160 const mbox = dec.decode(Buffer.concat(buildMbox([{ data: enc.encode("Subject: 1\n\nun\n"), sender: "a@x.ca", date: new Date(Date.UTC(2026, 0, 2)) }, { data: enc.encode("Subject: 2\n\nFrom deux"), sender: " <b@x.ca> ", date: new Date(Date.UTC(2026, 0, 3)) }])))161 assert.equal(mbox, "From a@x.ca Fri Jan 2 00:00:00 2026\nSubject: 1\n\nun\n\nFrom b@x.ca Sat Jan 3 00:00:00 2026\nSubject: 2\n\n>From deux\n\n")162})163test("zip : CRC, noms uniques, structure lisible", () => {164 assert.equal(crc32(enc.encode("123456789")), 0xcbf43926)165 assert.deepEqual(uniqueNames(["a.eml", "A.eml", "a.eml", "b/c.eml", "", "..caché"]), ["a.eml", "A (2).eml", "a (3).eml", "b_c.eml", "message", "_caché"])166 const zip = Buffer.concat(buildZip([{ name: "été.eml", data: enc.encode("bonjour"), date: new Date(2026, 10, 18, 12, 30, 10) }, { name: "b.eml", data: new Uint8Array(0), date: new Date(2026, 0, 1) }]))167 assert.equal(zip.readUInt32LE(0), 0x04034b50)168 assert.equal(zip.readUInt32LE(14), crc32(enc.encode("bonjour")))169 const eocd = zip.length - 22170 assert.equal(zip.readUInt32LE(eocd), 0x06054b50)171 assert.equal(zip.readUInt16LE(eocd + 10), 2)172 const cdOffset = zip.readUInt32LE(eocd + 16)173 assert.equal(zip.readUInt32LE(cdOffset), 0x02014b50)174 assert.equal(zip.subarray(30, 39).toString("utf8"), "été.eml")175 assert.equal(zip.subarray(39, 46).toString("utf8"), "bonjour")176})177178// ---------------------------------------------------------------- réponses / transferts179const labels: ReplyLabels = { wrote: (d, w) => `Le ${d}, ${w} a écrit :`, forwardedHeader: "Message transféré", from: "De :", date: "Date :", subject: "Objet :", to: "À :", cc: "Cc :" }180test("réponse : objet, en-têtes de fil, destinataires", () => {181 assert.equal(replySubject("Bonjour"), "Re: Bonjour")182 assert.equal(replySubject("RE: Re : rép: Bonjour"), "Re: Bonjour")183 assert.equal(replySubject(null), "Re:")184 assert.equal(forwardSubject("Fwd: TR: Rapport"), "Fwd: Rapport")185 assert.equal(forwardSubject("Re: Rapport"), "Fwd: Re: Rapport")186 assert.deepEqual(threadHeaders({ messageId: ["c@x"], references: ["a@x", "b@x"] }), { inReplyTo: ["c@x"], references: ["a@x", "b@x", "c@x"] })187 assert.deepEqual(threadHeaders({ messageId: ["c@x"], references: null }), { inReplyTo: ["c@x"], references: ["c@x"] })188 assert.deepEqual(threadHeaders({ messageId: null }), { inReplyTo: null, references: null })189 const src = { from: [{ name: "Alice", email: "alice@x.ca" }], to: [{ email: "moi@x.ca" }, { email: "bob@x.ca" }], cc: [{ email: "carol@x.ca" }, { email: "MOI@x.ca" }] }190 assert.deepEqual(replyRecipients(src, ["moi@x.ca"], false), { to: [{ name: "Alice", email: "alice@x.ca" }], cc: [] })191 assert.deepEqual(replyRecipients(src, ["moi@x.ca"], true), { to: [{ name: "Alice", email: "alice@x.ca" }, { email: "bob@x.ca" }], cc: [{ email: "carol@x.ca" }] })192 assert.deepEqual(replyRecipients({ ...src, replyTo: [{ email: "liste@x.ca" }] }, ["moi@x.ca"], false).to, [{ email: "liste@x.ca" }])193 // réponse à un message que j'ai envoyé : on écrit de nouveau aux destinataires194 assert.deepEqual(replyRecipients({ from: [{ email: "moi@x.ca" }], to: [{ email: "bob@x.ca" }], cc: [{ email: "carol@x.ca" }] }, ["moi@x.ca"], true), { to: [{ email: "bob@x.ca" }], cc: [{ email: "carol@x.ca" }] })195})196test("HTML → texte, texte → HTML, citations", () => {197 assert.equal(htmlToText(`<p>Bonjour <b>à</b> tous,</p><p>Voir <a href="https://example.org/x">le site</a> ou <a href="https://example.org/">https://example.org/</a>.</p><ul><li>un</li><li>deux & trois</li></ul><script>x</script><style>p{}</style>`), "Bonjour à tous,\n\nVoir le site <https://example.org/x> ou https://example.org/.\n\n• un\n• deux & trois")198 assert.equal(htmlToText(`<div>a</div><div><br></div><div>b c</div><blockquote>cité<br>encore<blockquote>profond</blockquote></blockquote>`), "a\n\nb c\n\n> cité\n> encore\n> > profond")199 assert.equal(htmlToText(`<a href="javascript:alert(1)">piège</a> <b> é €`), "piège <b> é €")200 assert.equal(decodeEntities("é &unknown;�"), "é\u00a0&unknown;")201 assert.equal(textToHtml(`a <b> & "c"\n\n d`), `<div>a <b> & "c"</div><div><br></div><div> d</div>`)202 assert.equal(quoteText("a\n> b\n\nc"), "> a\n>> b\n>\n> c")203 const src = { from: [{ name: "Alice <script>", email: "alice@x.ca" }], to: [{ email: "moi@x.ca" }], subject: "Objet <b>" }204 const q = buildReplyQuote(src, null, "ligne 1\nligne <2>", "9 nov. 2026", labels)205 assert.ok(q.html.includes(`<blockquote class="spm-quote" type="cite"><div>ligne 1</div><div>ligne <2></div></blockquote>`), q.html)206 assert.ok(q.html.includes("<script>") && !q.html.includes("<script>"))207 assert.equal(q.text, `\n\nLe 9 nov. 2026, "Alice <script>" <alice@x.ca> a écrit :\n> ligne 1\n> ligne <2>\n`)208 const f = buildForwardQuote(src, "<p>corps</p>", "corps", "9 nov. 2026", labels)209 assert.ok(f.html.includes("---------- Message transféré ----------") && f.html.includes("<b>Objet :</b> Objet <b>") && f.html.includes("<p>corps</p>"))210 assert.ok(f.text.includes("De : \"Alice <script>\" <alice@x.ca>\nDate : 9 nov. 2026\nObjet : Objet <b>\nÀ : moi@x.ca\n\ncorps"))211})212213// ---------------------------------------------------------------- recherche214test("recherche : analyse, sérialisation, filtre JMAP", () => {215 const q = parseSearch(`from:alice sujet:"rapport final" has:attachment after:2026-01-01 avant:2026-02-01 budget "mot exact" inconnu:x after:hier`)216 assert.deepEqual(q, { text: `budget "mot exact" inconnu:x after:hier`, from: "alice", to: "", subject: "rapport final", hasAttachment: true, after: "2026-01-01", before: "2026-02-01" })217 assert.equal(stringifySearch(q), `from:alice subject:"rapport final" has:attachment after:2026-01-01 before:2026-02-01 budget "mot exact" inconnu:x after:hier`)218 assert.deepEqual(parseSearch(stringifySearch(q)), q)219 assert.deepEqual(parseSearch(""), emptySearch())220 const c = searchToConditions({ ...emptySearch(), text: "budget", from: "alice", hasAttachment: true, after: "2026-01-01", before: "2026-01-01" })221 assert.deepEqual(c.slice(0, 3), [{ text: "budget" }, { from: "alice" }, { hasAttachment: true }])222 assert.equal(new Date(c[4].before!).getTime() - new Date(c[3].after!).getTime(), 86400_000, "« before » inclut la journée entière")223 assert.match(c[3].after!, /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/)224})225226// ---------------------------------------------------------------- expéditeur de confiance : authentification alignée (point A9)227test("images d'un expéditeur de confiance : seulement si DMARC ou un DKIM aligné a réussi", async () => {228 const { senderAuthenticated } = await import("./authResults")229 const ok = (h: string, d = "banque.example") => senderAuthenticated([h], d)230 assert.equal(ok("mx1.spboucher.ai; dkim=pass header.d=banque.example header.s=s1; spf=pass smtp.mailfrom=banque.example; dmarc=pass header.from=banque.example"), true)231 assert.equal(ok("mx1.spboucher.ai; dmarc=pass header.from=banque.example"), true)232 assert.equal(ok("mx1.spboucher.ai; dkim=pass header.d=mail.banque.example; dmarc=none"), true, "sous-domaine aligné")233 // usurpation : From affiche banque.example, mais seule une signature d'un autre domaine passe234 assert.equal(ok("mx1.spboucher.ai; dkim=pass header.d=evil.example; spf=pass smtp.mailfrom=evil.example; dmarc=fail header.from=banque.example"), false)235 assert.equal(ok("mx1.spboucher.ai; dkim=pass header.d=evil.example"), false, "DKIM valide mais non aligné")236 assert.equal(ok("mx1.spboucher.ai; spf=pass smtp.mailfrom=banque.example"), false, "SPF seul ne suffit pas")237 assert.equal(ok("mx1.spboucher.ai; dmarc=pass header.from=evil.example"), false, "DMARC d'un autre domaine")238 assert.equal(ok("mx1.spboucher.ai; none"), false)239 assert.equal(senderAuthenticated([], "banque.example"), false, "aucun résultat (courrier non vérifié)")240 assert.equal(senderAuthenticated(["mx1.spboucher.ai; dmarc=pass"], undefined), false)241 // seul le premier en-tête (celui de notre serveur) compte : un en-tête forgé plus bas est ignoré242 assert.equal(senderAuthenticated(["mx1.spboucher.ai; dmarc=fail header.from=banque.example", "forge.example; dmarc=pass header.from=banque.example"], "banque.example"), false)243})244