add phishing check
This commit is contained in:
parent
0f15e2fb2c
commit
a2e1e1a3cf
4 changed files with 128 additions and 1 deletions
38
badLinks.ts
Normal file
38
badLinks.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
import { FiltersEngine, Request } from '@cliqz/adblocker';
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
let engine: FiltersEngine;
|
||||
|
||||
const init = async () => {
|
||||
if (engine) return;
|
||||
|
||||
console.log('initializing FiltersEngine');
|
||||
|
||||
engine = await FiltersEngine.fromLists(
|
||||
fetch,
|
||||
[
|
||||
'https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/badware.txt',
|
||||
'https://malware-filter.gitlab.io/malware-filter/phishing-filter.txt',
|
||||
],
|
||||
{
|
||||
enableInMemoryCache: true,
|
||||
enableOptimizations: true,
|
||||
enableCompression: true,
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export const isBad = async (url: string) => {
|
||||
await init();
|
||||
|
||||
const { match } = engine.match(
|
||||
Request.fromRawDetails({
|
||||
type: 'mainFrame',
|
||||
url,
|
||||
})
|
||||
);
|
||||
|
||||
console.log('Testing URL', url, match);
|
||||
|
||||
return match;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue