2023-06-29 18:26:45 +02:00
|
|
|
import o from "@tutao/otest"
|
2023-02-10 16:27:53 +01:00
|
|
|
import { MailFacade, phishingMarkerValue } from "../../../../../src/api/worker/facades/lazy/MailFacade.js"
|
2023-08-21 09:58:26 +02:00
|
|
|
import { createMail, createMailAddress, createReportedMailFieldMarker } from "../../../../../src/api/entities/tutanota/TypeRefs.js"
|
2022-12-27 15:37:40 +01:00
|
|
|
import { MailAuthenticationStatus, ReportedMailFieldType } from "../../../../../src/api/common/TutanotaConstants.js"
|
|
|
|
|
import { object } from "testdouble"
|
|
|
|
|
import { CryptoFacade } from "../../../../../src/api/worker/crypto/CryptoFacade.js"
|
|
|
|
|
import { IServiceExecutor } from "../../../../../src/api/common/ServiceRequest.js"
|
|
|
|
|
import { EntityClient } from "../../../../../src/api/common/EntityClient.js"
|
2023-02-10 16:27:53 +01:00
|
|
|
import { BlobFacade } from "../../../../../src/api/worker/facades/lazy/BlobFacade.js"
|
2022-12-27 15:37:40 +01:00
|
|
|
import { UserFacade } from "../../../../../src/api/worker/facades/UserFacade"
|
|
|
|
|
import { NativeFileApp } from "../../../../../src/native/common/FileApp.js"
|
2023-07-17 11:42:02 +02:00
|
|
|
import { LoginFacade } from "../../../../../src/api/worker/facades/LoginFacade.js"
|
2020-03-16 17:37:50 +01:00
|
|
|
|
|
|
|
|
o.spec("MailFacade test", function () {
|
|
|
|
|
let facade: MailFacade
|
2022-04-12 14:23:38 +02:00
|
|
|
let userFacade: UserFacade
|
2022-03-09 17:43:29 +01:00
|
|
|
let cryptoFacade: CryptoFacade
|
|
|
|
|
let serviceExecutor: IServiceExecutor
|
|
|
|
|
let entity: EntityClient
|
2022-03-16 10:14:53 +01:00
|
|
|
let blobFacade: BlobFacade
|
2022-08-09 15:04:15 +02:00
|
|
|
let fileApp: NativeFileApp
|
2023-07-17 11:42:02 +02:00
|
|
|
let loginFacade: LoginFacade
|
2022-03-09 17:43:29 +01:00
|
|
|
|
2020-03-16 17:37:50 +01:00
|
|
|
o.beforeEach(function () {
|
2022-04-12 14:23:38 +02:00
|
|
|
userFacade = object()
|
2022-03-16 10:14:53 +01:00
|
|
|
blobFacade = object()
|
2022-03-09 17:43:29 +01:00
|
|
|
entity = object()
|
|
|
|
|
cryptoFacade = object()
|
|
|
|
|
serviceExecutor = object()
|
2022-08-09 15:04:15 +02:00
|
|
|
fileApp = object()
|
2023-07-17 11:42:02 +02:00
|
|
|
loginFacade = object()
|
2023-08-24 14:31:24 +02:00
|
|
|
facade = new MailFacade(userFacade, entity, cryptoFacade, serviceExecutor, blobFacade, fileApp, loginFacade)
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o.spec("checkMailForPhishing", function () {
|
|
|
|
|
o("not phishing if no markers", async function () {
|
|
|
|
|
const mail = createMail({
|
|
|
|
|
subject: "Test",
|
|
|
|
|
authStatus: MailAuthenticationStatus.AUTHENTICATED,
|
|
|
|
|
sender: createMailAddress({
|
|
|
|
|
name: "a",
|
|
|
|
|
address: "test@example.com",
|
2022-12-27 15:37:40 +01:00
|
|
|
}),
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
2022-12-27 15:37:40 +01:00
|
|
|
o(await facade.checkMailForPhishing(mail, [{ href: "https://example.com", innerHTML: "link" }])).equals(false)
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("not phishing if no matching markers", async function () {
|
|
|
|
|
const mail = createMail({
|
|
|
|
|
subject: "Test",
|
|
|
|
|
authStatus: MailAuthenticationStatus.AUTHENTICATED,
|
|
|
|
|
sender: createMailAddress({
|
|
|
|
|
name: "a",
|
2022-12-27 15:37:40 +01:00
|
|
|
address: "test@example.com",
|
|
|
|
|
}),
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
2020-06-02 13:39:22 +02:00
|
|
|
facade.phishingMarkersUpdateReceived([
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2020-06-02 13:39:22 +02:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.SUBJECT, "Test 2"),
|
|
|
|
|
}),
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2022-12-27 15:37:40 +01:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.FROM_DOMAIN, "example2.com"),
|
|
|
|
|
}),
|
2020-06-02 13:39:22 +02:00
|
|
|
])
|
2020-03-16 17:37:50 +01:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
o(await facade.checkMailForPhishing(mail, [{ href: "https://example.com", innerHTML: "link" }])).equals(false)
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("not phishing if only from domain matches", async function () {
|
|
|
|
|
const mail = createMail({
|
|
|
|
|
subject: "Test",
|
|
|
|
|
authStatus: MailAuthenticationStatus.AUTHENTICATED,
|
|
|
|
|
sender: createMailAddress({
|
|
|
|
|
name: "a",
|
2022-12-27 15:37:40 +01:00
|
|
|
address: "test@example.com",
|
|
|
|
|
}),
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
2020-06-02 13:39:22 +02:00
|
|
|
facade.phishingMarkersUpdateReceived([
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2020-06-02 13:39:22 +02:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.SUBJECT, "Test 2"),
|
|
|
|
|
}),
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2022-12-27 15:37:40 +01:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.FROM_DOMAIN, "example.com"),
|
|
|
|
|
}),
|
2020-06-02 13:39:22 +02:00
|
|
|
])
|
2020-03-16 17:37:50 +01:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
o(await facade.checkMailForPhishing(mail, [{ href: "https://example.com", innerHTML: "link" }])).equals(false)
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("not phishing if only subject matches", async function () {
|
|
|
|
|
const mail = createMail({
|
|
|
|
|
subject: "Test",
|
|
|
|
|
authStatus: MailAuthenticationStatus.AUTHENTICATED,
|
|
|
|
|
sender: createMailAddress({
|
|
|
|
|
name: "a",
|
2022-12-27 15:37:40 +01:00
|
|
|
address: "test@example.com",
|
|
|
|
|
}),
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
2020-06-02 13:39:22 +02:00
|
|
|
facade.phishingMarkersUpdateReceived([
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2020-06-02 13:39:22 +02:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.SUBJECT, "Test"),
|
|
|
|
|
}),
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2022-12-27 15:37:40 +01:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.FROM_DOMAIN, "example2.com"),
|
|
|
|
|
}),
|
2020-06-02 13:39:22 +02:00
|
|
|
])
|
2020-03-16 17:37:50 +01:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
o(await facade.checkMailForPhishing(mail, [{ href: "https://example.com", innerHTML: "link" }])).equals(false)
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("is phishing if subject and sender domain matches", async function () {
|
|
|
|
|
const mail = createMail({
|
|
|
|
|
subject: "Test",
|
|
|
|
|
authStatus: MailAuthenticationStatus.AUTHENTICATED,
|
|
|
|
|
sender: createMailAddress({
|
|
|
|
|
name: "a",
|
2022-12-27 15:37:40 +01:00
|
|
|
address: "test@example.com",
|
|
|
|
|
}),
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
2020-06-02 13:39:22 +02:00
|
|
|
facade.phishingMarkersUpdateReceived([
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2020-06-02 13:39:22 +02:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.SUBJECT, "Test"),
|
|
|
|
|
}),
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2022-12-27 15:37:40 +01:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.FROM_DOMAIN, "example.com"),
|
|
|
|
|
}),
|
2020-06-02 13:39:22 +02:00
|
|
|
])
|
2020-03-16 17:37:50 +01:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
o(await facade.checkMailForPhishing(mail, [{ href: "https://example.com", innerHTML: "link" }])).equals(true)
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("is phishing if subject with whitespaces and sender domain matches", async function () {
|
|
|
|
|
const mail = createMail({
|
|
|
|
|
subject: "\tTest spaces \n",
|
|
|
|
|
authStatus: MailAuthenticationStatus.AUTHENTICATED,
|
|
|
|
|
sender: createMailAddress({
|
|
|
|
|
name: "a",
|
2022-12-27 15:37:40 +01:00
|
|
|
address: "test@example.com",
|
|
|
|
|
}),
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
2020-06-02 13:39:22 +02:00
|
|
|
facade.phishingMarkersUpdateReceived([
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2020-06-02 13:39:22 +02:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.SUBJECT, "Testspaces"),
|
|
|
|
|
}),
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2022-12-27 15:37:40 +01:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.FROM_DOMAIN, "example.com"),
|
|
|
|
|
}),
|
2020-06-02 13:39:22 +02:00
|
|
|
])
|
2020-03-16 17:37:50 +01:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
o(await facade.checkMailForPhishing(mail, [{ href: "https://example.com", innerHTML: "link" }])).equals(true)
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("is not phishing if subject and sender domain matches but not authenticated", async function () {
|
|
|
|
|
const mail = createMail({
|
|
|
|
|
subject: "Test",
|
|
|
|
|
authStatus: MailAuthenticationStatus.SOFT_FAIL,
|
|
|
|
|
sender: createMailAddress({
|
|
|
|
|
name: "a",
|
2022-12-27 15:37:40 +01:00
|
|
|
address: "test@example.com",
|
|
|
|
|
}),
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
2020-06-02 13:39:22 +02:00
|
|
|
facade.phishingMarkersUpdateReceived([
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2020-06-02 13:39:22 +02:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.SUBJECT, "Test"),
|
|
|
|
|
}),
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2022-12-27 15:37:40 +01:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.FROM_DOMAIN, "example.com"),
|
|
|
|
|
}),
|
2020-06-02 13:39:22 +02:00
|
|
|
])
|
2020-03-16 17:37:50 +01:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
o(await facade.checkMailForPhishing(mail, [{ href: "https://example.com", innerHTML: "link" }])).equals(false)
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("is phishing if subject and sender address matches", async function () {
|
|
|
|
|
const mail = createMail({
|
|
|
|
|
subject: "Test",
|
|
|
|
|
authStatus: MailAuthenticationStatus.AUTHENTICATED,
|
|
|
|
|
sender: createMailAddress({
|
|
|
|
|
name: "a",
|
2022-12-27 15:37:40 +01:00
|
|
|
address: "test@example.com",
|
|
|
|
|
}),
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
2020-06-02 13:39:22 +02:00
|
|
|
facade.phishingMarkersUpdateReceived([
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2020-06-02 13:39:22 +02:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.SUBJECT, "Test"),
|
|
|
|
|
}),
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2022-12-27 15:37:40 +01:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.FROM_ADDRESS, "test@example.com"),
|
|
|
|
|
}),
|
2020-06-02 13:39:22 +02:00
|
|
|
])
|
2020-03-16 17:37:50 +01:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
o(await facade.checkMailForPhishing(mail, [{ href: "https://example.com", innerHTML: "link" }])).equals(true)
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("is not phishing if subject and sender address matches but not authenticated", async function () {
|
|
|
|
|
const mail = createMail({
|
|
|
|
|
subject: "Test",
|
|
|
|
|
authStatus: MailAuthenticationStatus.SOFT_FAIL,
|
|
|
|
|
sender: createMailAddress({
|
|
|
|
|
name: "a",
|
2022-12-27 15:37:40 +01:00
|
|
|
address: "test@example.com",
|
|
|
|
|
}),
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
2020-06-02 13:39:22 +02:00
|
|
|
facade.phishingMarkersUpdateReceived([
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2020-06-02 13:39:22 +02:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.SUBJECT, "Test"),
|
|
|
|
|
}),
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2022-12-27 15:37:40 +01:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.FROM_ADDRESS, "test@example.com"),
|
|
|
|
|
}),
|
2020-06-02 13:39:22 +02:00
|
|
|
])
|
2020-03-16 17:37:50 +01:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
o(await facade.checkMailForPhishing(mail, [{ href: "https://example.com", innerHTML: "link" }])).equals(false)
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("is phishing if subject and non auth sender domain matches", async function () {
|
|
|
|
|
const mail = createMail({
|
|
|
|
|
subject: "Test",
|
|
|
|
|
authStatus: MailAuthenticationStatus.SOFT_FAIL,
|
|
|
|
|
sender: createMailAddress({
|
|
|
|
|
name: "a",
|
2022-12-27 15:37:40 +01:00
|
|
|
address: "test@example.com",
|
|
|
|
|
}),
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
2020-06-02 13:39:22 +02:00
|
|
|
facade.phishingMarkersUpdateReceived([
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2020-06-02 13:39:22 +02:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.SUBJECT, "Test"),
|
|
|
|
|
}),
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2022-12-27 15:37:40 +01:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.FROM_DOMAIN_NON_AUTH, "example.com"),
|
|
|
|
|
}),
|
2020-06-02 13:39:22 +02:00
|
|
|
])
|
2020-03-16 17:37:50 +01:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
o(await facade.checkMailForPhishing(mail, [{ href: "https://example.com", innerHTML: "link" }])).equals(true)
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("is phishing if subject and non auth sender address matches", async function () {
|
|
|
|
|
const mail = createMail({
|
|
|
|
|
subject: "Test",
|
|
|
|
|
authStatus: MailAuthenticationStatus.SOFT_FAIL,
|
|
|
|
|
sender: createMailAddress({
|
|
|
|
|
name: "a",
|
2022-12-27 15:37:40 +01:00
|
|
|
address: "test@example.com",
|
|
|
|
|
}),
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
2020-06-02 13:39:22 +02:00
|
|
|
facade.phishingMarkersUpdateReceived([
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2020-06-02 13:39:22 +02:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.SUBJECT, "Test"),
|
|
|
|
|
}),
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2022-12-27 15:37:40 +01:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.FROM_ADDRESS_NON_AUTH, "test@example.com"),
|
|
|
|
|
}),
|
2020-06-02 13:39:22 +02:00
|
|
|
])
|
2020-03-16 17:37:50 +01:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
o(await facade.checkMailForPhishing(mail, [{ href: "https://example.com", innerHTML: "link" }])).equals(true)
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("is phishing if subject and link matches", async function () {
|
|
|
|
|
const mail = createMail({
|
|
|
|
|
subject: "Test",
|
|
|
|
|
authStatus: MailAuthenticationStatus.AUTHENTICATED,
|
|
|
|
|
sender: createMailAddress({
|
|
|
|
|
name: "a",
|
2022-12-27 15:37:40 +01:00
|
|
|
address: "test@example.com",
|
|
|
|
|
}),
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
2020-06-02 13:39:22 +02:00
|
|
|
facade.phishingMarkersUpdateReceived([
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2020-06-02 13:39:22 +02:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.SUBJECT, "Test"),
|
|
|
|
|
}),
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2022-12-27 15:37:40 +01:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.LINK, "https://example.com"),
|
|
|
|
|
}),
|
2020-06-02 13:39:22 +02:00
|
|
|
])
|
2020-03-16 17:37:50 +01:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
o(await facade.checkMailForPhishing(mail, [{ href: "https://example.com", innerHTML: "link" }])).equals(true)
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("is not phishing if just two links match", async function () {
|
|
|
|
|
const mail = createMail({
|
|
|
|
|
subject: "Test",
|
|
|
|
|
authStatus: MailAuthenticationStatus.AUTHENTICATED,
|
|
|
|
|
sender: createMailAddress({
|
|
|
|
|
name: "a",
|
2022-12-27 15:37:40 +01:00
|
|
|
address: "test@example.com",
|
|
|
|
|
}),
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
2020-06-02 13:39:22 +02:00
|
|
|
facade.phishingMarkersUpdateReceived([
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2020-06-02 13:39:22 +02:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.LINK, "https://example.com"),
|
|
|
|
|
}),
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2022-12-27 15:37:40 +01:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.LINK, "https://example2.com"),
|
|
|
|
|
}),
|
2020-06-02 13:39:22 +02:00
|
|
|
])
|
2020-03-16 17:37:50 +01:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
o(
|
|
|
|
|
await facade.checkMailForPhishing(mail, [
|
|
|
|
|
{ href: "https://example.com", innerHTML: "link1" },
|
|
|
|
|
{ href: "https://example2.com", innerHTML: "link2" },
|
|
|
|
|
]),
|
|
|
|
|
).equals(false)
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("is phishing if subject and link domain matches", async function () {
|
|
|
|
|
const mail = createMail({
|
|
|
|
|
subject: "Test",
|
|
|
|
|
authStatus: MailAuthenticationStatus.AUTHENTICATED,
|
|
|
|
|
sender: createMailAddress({
|
|
|
|
|
name: "a",
|
2022-12-27 15:37:40 +01:00
|
|
|
address: "test@example.com",
|
|
|
|
|
}),
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
2020-06-02 13:39:22 +02:00
|
|
|
facade.phishingMarkersUpdateReceived([
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2020-06-02 13:39:22 +02:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.SUBJECT, "Test"),
|
|
|
|
|
}),
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2022-12-27 15:37:40 +01:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.LINK_DOMAIN, "example.com"),
|
|
|
|
|
}),
|
2020-06-02 13:39:22 +02:00
|
|
|
])
|
2020-03-16 17:37:50 +01:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
o(await facade.checkMailForPhishing(mail, [{ href: "https://example.com", innerHTML: "link" }])).equals(true)
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
2020-04-14 15:28:24 +02:00
|
|
|
|
|
|
|
|
o("does not throw on invalid link", async function () {
|
|
|
|
|
const mail = createMail({
|
|
|
|
|
subject: "Test",
|
|
|
|
|
authStatus: MailAuthenticationStatus.AUTHENTICATED,
|
|
|
|
|
sender: createMailAddress({
|
|
|
|
|
name: "a",
|
2022-12-27 15:37:40 +01:00
|
|
|
address: "test@example.com",
|
|
|
|
|
}),
|
2020-04-14 15:28:24 +02:00
|
|
|
})
|
2020-06-02 13:39:22 +02:00
|
|
|
facade.phishingMarkersUpdateReceived([
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2020-06-02 13:39:22 +02:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.SUBJECT, "Test"),
|
|
|
|
|
}),
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2022-12-27 15:37:40 +01:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.LINK_DOMAIN, "example.com"),
|
|
|
|
|
}),
|
2020-06-02 13:39:22 +02:00
|
|
|
])
|
2020-04-14 15:28:24 +02:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
o(
|
|
|
|
|
await facade.checkMailForPhishing(mail, [
|
|
|
|
|
{ href: "/example1", innerHTML: "link1" },
|
|
|
|
|
{ href: "example2", innerHTML: "link2" },
|
|
|
|
|
{ href: "http:/", innerHTML: "link3" },
|
|
|
|
|
]),
|
|
|
|
|
).equals(false)
|
2021-01-28 12:15:10 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("is phishing if subject and suspicious link", async function () {
|
|
|
|
|
const mail = createMail({
|
|
|
|
|
subject: "Test",
|
|
|
|
|
authStatus: MailAuthenticationStatus.AUTHENTICATED,
|
|
|
|
|
sender: createMailAddress({
|
|
|
|
|
name: "a",
|
2022-12-27 15:37:40 +01:00
|
|
|
address: "test@example.com",
|
|
|
|
|
}),
|
2021-01-28 12:15:10 +01:00
|
|
|
})
|
|
|
|
|
facade.phishingMarkersUpdateReceived([
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2021-01-28 12:15:10 +01:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.SUBJECT, "Test"),
|
|
|
|
|
}),
|
|
|
|
|
])
|
|
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
o(await facade.checkMailForPhishing(mail, [{ href: "https://example.com", innerHTML: "https://evil-domain.com" }])).equals(true)
|
2021-01-28 12:15:10 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("link is not suspicious if on the same domain", async function () {
|
|
|
|
|
const mail = createMail({
|
|
|
|
|
subject: "Test",
|
|
|
|
|
authStatus: MailAuthenticationStatus.AUTHENTICATED,
|
|
|
|
|
sender: createMailAddress({
|
|
|
|
|
name: "a",
|
2022-12-27 15:37:40 +01:00
|
|
|
address: "test@example.com",
|
|
|
|
|
}),
|
2021-01-28 12:15:10 +01:00
|
|
|
})
|
|
|
|
|
facade.phishingMarkersUpdateReceived([
|
2023-08-21 09:58:26 +02:00
|
|
|
createReportedMailFieldMarker({
|
2021-01-28 12:15:10 +01:00
|
|
|
marker: phishingMarkerValue(ReportedMailFieldType.SUBJECT, "Test"),
|
|
|
|
|
}),
|
|
|
|
|
])
|
|
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
o(await facade.checkMailForPhishing(mail, [{ href: "https://example.com", innerHTML: "https://example.com/test" }])).equals(false)
|
2020-04-14 15:28:24 +02:00
|
|
|
})
|
2020-03-16 17:37:50 +01:00
|
|
|
})
|
2022-12-27 15:37:40 +01:00
|
|
|
})
|