Skip to content

Commit

Permalink
Remove bug bounty; improve website security analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
serg-plusplus committed Sep 21, 2024
1 parent 412e2bd commit 42883db
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/app/components/blocks/Sidebar.Links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ const useSidebarLinks = () => {
swapBadgeAmount,
setActivityOpened,
setReceiveOpened,
alert,
]);

const NavLinksSecondary = useMemo(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/core/back/services/pageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function getDefaultAccountAddress() {
}

async function checkForPhishing(hostname: string, callback: () => void) {
const phishing = isPhishingWebsite(hostname);
const phishing = await isPhishingWebsite(hostname);

// TODO: Add checker - is user already allowed this website

Expand Down
27 changes: 21 additions & 6 deletions src/fixtures/phishingDetect.ts
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;
});
15 changes: 9 additions & 6 deletions src/lib/phishing-detect/index.ts
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()),
);

0 comments on commit 42883db

Please sign in to comment.