mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-15 18:50:34 +08:00
Perf: bail out phishing calculation early
This commit is contained in:
parent
f61804ff51
commit
48e8808511
@ -100,7 +100,7 @@ const BLACK_TLD = new Set([
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const WHITELIST_MAIN_DOMAINS = new Set([
|
const WHITELIST_MAIN_DOMAINS = new Set([
|
||||||
'w3s.link', // ipfs gateway
|
// 'w3s.link', // ipfs gateway
|
||||||
// 'dweb.link', // ipfs gateway
|
// 'dweb.link', // ipfs gateway
|
||||||
// 'nftstorage.link', // ipfs gateway
|
// 'nftstorage.link', // ipfs gateway
|
||||||
'fleek.cool', // ipfs gateway
|
'fleek.cool', // ipfs gateway
|
||||||
@ -196,19 +196,22 @@ export const getPhishingDomains = (parentSpan: Span) => parentSpan.traceChild('g
|
|||||||
domainScoreMap[apexDomain] += 2;
|
domainScoreMap[apexDomain] += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
subdomain
|
||||||
|
&& !WHITELIST_MAIN_DOMAINS.has(apexDomain)
|
||||||
|
) {
|
||||||
domainScoreMap[apexDomain] += calcDomainAbuseScore(subdomain);
|
domainScoreMap[apexDomain] += calcDomainAbuseScore(subdomain);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const domain in domainCountMap) {
|
for (const apexDomain in domainCountMap) {
|
||||||
if (
|
if (
|
||||||
!WHITELIST_MAIN_DOMAINS.has(domain)
|
// !WHITELIST_MAIN_DOMAINS.has(apexDomain)
|
||||||
&& (
|
domainScoreMap[apexDomain] >= 12
|
||||||
domainScoreMap[domain] >= 12
|
|| (domainScoreMap[apexDomain] >= 5 && domainCountMap[apexDomain] >= 4)
|
||||||
|| (domainScoreMap[domain] >= 5 && domainCountMap[domain] >= 4)
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
domainArr.push(`.${domain}`);
|
domainArr.push(`.${apexDomain}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,10 +220,9 @@ export const getPhishingDomains = (parentSpan: Span) => parentSpan.traceChild('g
|
|||||||
return domainArr;
|
return domainArr;
|
||||||
});
|
});
|
||||||
|
|
||||||
export function calcDomainAbuseScore(subdomain: string | null) {
|
export function calcDomainAbuseScore(subdomain: string) {
|
||||||
let weight = 0;
|
let weight = 0;
|
||||||
|
|
||||||
if (subdomain) {
|
|
||||||
const hitLowKeywords = lowKeywords(subdomain);
|
const hitLowKeywords = lowKeywords(subdomain);
|
||||||
const sensitiveKeywordsHit = sensitiveKeywords(subdomain);
|
const sensitiveKeywordsHit = sensitiveKeywords(subdomain);
|
||||||
|
|
||||||
@ -259,7 +261,6 @@ export function calcDomainAbuseScore(subdomain: string | null) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return weight;
|
return weight;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user