Skip to content

Commit

Permalink
Fix: correctly process phishing domains
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jan 21, 2024
1 parent 725f26b commit 3edfa84
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 14 deletions.
3 changes: 1 addition & 2 deletions Build/build-anti-bogus-domain.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// @ts-check
import path from 'path';
import { createRuleset } from './lib/create-file';
import { fetchRemoteTextByLine, readFileByLine, readFileIntoProcessedArray } from './lib/fetch-text-by-line';
import { processLine } from './lib/process-line';
import { fetchRemoteTextByLine, readFileIntoProcessedArray } from './lib/fetch-text-by-line';
import { task } from './trace';
import { SHARED_DESCRIPTION } from './lib/constants';
import { isProbablyIpv4, isProbablyIpv6 } from './lib/is-fast-ip';
Expand Down
1 change: 0 additions & 1 deletion Build/build-reject-domainset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { createTrie } from './lib/trie';

import { HOSTS, ADGUARD_FILTERS, PREDEFINED_WHITELIST, DOMAIN_LISTS } from './lib/reject-data-source';
import { createRuleset, compareAndWriteFile } from './lib/create-file';
import { processLine } from './lib/process-line';
import { domainDeduper } from './lib/domain-deduper';
import createKeywordFilter from './lib/aho-corasick';
import { readFileByLine, readFileIntoProcessedArray } from './lib/fetch-text-by-line';
Expand Down
1 change: 0 additions & 1 deletion Build/download-mock-assets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import picocolors from 'picocolors';
import { task } from './trace';
import path from 'path';
import { fetchWithRetry } from './lib/fetch-retry';
Expand Down
1 change: 0 additions & 1 deletion Build/lib/create-file.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @ts-check
import { readFileByLine } from './fetch-text-by-line';
import { surgeDomainsetToClashDomainset, surgeRulesetToClashClassicalTextRuleset } from './clash';
import { traceAsync } from './trace-runner';
import picocolors from 'picocolors';
import type { Span } from '../trace';
import path from 'path';
Expand Down
4 changes: 2 additions & 2 deletions Build/lib/fetch-text-by-line.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { BunFile } from 'bun';
import { fetchWithRetry, defaultRequestInit } from './fetch-retry';

import { TextLineStream } from './text-line-transform-stream';
import { PolyfillTextDecoderStream } from './text-decoder-stream';
// import { TextLineStream } from './text-line-transform-stream';
// import { PolyfillTextDecoderStream } from './text-decoder-stream';
import { processLine } from './process-line';
// function createTextLineStreamFromStreamSource(stream: ReadableStream<Uint8Array>) {
// return stream
Expand Down
7 changes: 3 additions & 4 deletions Build/lib/get-phishing-domains.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { getGorhillPublicSuffixPromise } from './get-gorhill-publicsuffix';
import { processDomainLists, processHosts } from './parse-filter';
import { traceAsync, traceSync } from './trace-runner';
import { processDomainLists } from './parse-filter';
import * as tldts from 'tldts';
import { createTrie } from './trie';
import { createCachedGorhillGetDomain } from './cached-tld-parse';
Expand Down Expand Up @@ -182,8 +181,8 @@ export const getPhishingDomains = (parentSpan: Span) => parentSpan.traceChild('g
const results = span.traceChild('get final phishing results').traceSyncFn(() => {
const results: string[] = [];
for (const domain in domainCountMap) {
if (domainCountMap[domain] > 5) {
results.push(domain);
if (domainCountMap[domain] >= 5) {
results.push(`.${domain}`);
}
}
return results;
Expand Down
3 changes: 1 addition & 2 deletions Build/lib/parse-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import { processLine } from './process-line';
import { getGorhillPublicSuffixPromise } from './get-gorhill-publicsuffix';
import type { PublicSuffixList } from '@gorhill/publicsuffixlist';

import { traceAsync } from './trace-runner';
import picocolors from 'picocolors';
import { normalizeDomain } from './normalize-domain';
import { fetchAssets } from './fetch-assets';
import { deserializeSet, fsCache, serializeSet } from './cache-filesystem';
import type { Span } from '../trace';

const DEBUG_DOMAIN_TO_FIND: string | null = null; // example.com | null
const DEBUG_DOMAIN_TO_FIND: string | null = '7bam.top'; // example.com | null
let foundDebugDomain = false;

export function processDomainLists(span: Span, domainListsUrl: string, includeAllSubDomain = false, ttl: number | null = null) {
Expand Down
1 change: 0 additions & 1 deletion Build/lib/trace-runner.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import path from 'path';
import picocolors from 'picocolors';

type Formatter = (result: string) => string;
Expand Down

0 comments on commit 3edfa84

Please sign in to comment.