-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove bug bounty; improve website security analyzer
- Loading branch information
1 parent
412e2bd
commit 42883db
Showing
4 changed files
with
31 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
import BASE from "eth-phishing-detect/src/config.json"; | ||
import defaultConfig from "eth-phishing-detect/src/config.json"; | ||
|
||
const WEBSITE_ORIGIN = process.env.WIGWAM_WEBSITE_ORIGIN; | ||
const WEBSITE_HOST = WEBSITE_ORIGIN && new URL(WEBSITE_ORIGIN).host; | ||
|
||
export const PHISHING_DETECT_CONFIG = { | ||
...BASE, | ||
fuzzylist: [...BASE.fuzzylist, WEBSITE_HOST], | ||
whitelist: [...BASE.whitelist, WEBSITE_HOST], | ||
}; | ||
export const getPhishingDetectConfig = () => | ||
getBase().then((base) => ({ | ||
...base, | ||
fuzzylist: [...base.fuzzylist, WEBSITE_HOST], | ||
whitelist: [...base.whitelist, WEBSITE_HOST], | ||
})); | ||
|
||
export const getBase = (): Promise<typeof defaultConfig> => | ||
fetch( | ||
"https://raw.githubusercontent.com/MetaMask/eth-phishing-detect/refs/heads/main/src/config.json", | ||
) | ||
.then((res) => { | ||
if (!res.ok) throw new Error(res.statusText); | ||
|
||
return res.json(); | ||
}) | ||
.catch((err) => { | ||
console.error("Failed to obtain config", err); | ||
return defaultConfig; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
import memoize from "mem"; | ||
import memoizeOne from "memoize-one"; | ||
import PhishingDetector from "eth-phishing-detect/src/detector"; | ||
import { PHISHING_DETECT_CONFIG } from "fixtures/phishingDetect"; | ||
import { getPhishingDetectConfig } from "fixtures/phishingDetect"; | ||
|
||
export const isPhishingWebsite = memoize((hostname: string): boolean => { | ||
const reason = getDetector().check(hostname); | ||
export const isPhishingWebsite = memoize( | ||
async (hostname: string): Promise<boolean> => { | ||
const detector = await getDetector(); | ||
const reason = detector.check(hostname); | ||
|
||
return reason.result && reason.type === "blacklist"; | ||
}); | ||
return reason.result && reason.type === "blacklist"; | ||
}, | ||
); | ||
|
||
const getDetector = memoizeOne( | ||
() => new PhishingDetector(PHISHING_DETECT_CONFIG), | ||
async () => new PhishingDetector(await getPhishingDetectConfig()), | ||
); |