From e1391128ddde63c5192027501e32b2cecaadeddb Mon Sep 17 00:00:00 2001 From: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com> Date: Tue, 9 Feb 2021 10:37:57 +0100 Subject: [PATCH] show malicious website on the landing page (#648) --- .../src/background/handlers/Tabs.ts | 7 +++--- .../src/Popup/PhishingDetected.tsx | 23 +++++++++++++------ packages/extension-ui/src/Popup/index.tsx | 2 +- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/packages/extension-base/src/background/handlers/Tabs.ts b/packages/extension-base/src/background/handlers/Tabs.ts index 4cc974d3..2aa713eb 100644 --- a/packages/extension-base/src/background/handlers/Tabs.ts +++ b/packages/extension-base/src/background/handlers/Tabs.ts @@ -141,8 +141,9 @@ export default class Tabs { return this.#state.rpcUnsubscribe(request, port); } - private redirectPhishingLanding () { - const url = `${chrome.extension.getURL('index.html')}#${PHISHING_PAGE_REDIRECT}`; + private redirectPhishingLanding (phishingWebsite: string) { + const encodedWebsite = encodeURIComponent(phishingWebsite); + const url = `${chrome.extension.getURL('index.html')}#${PHISHING_PAGE_REDIRECT}/${encodedWebsite}`; chrome.tabs.update({ url }); @@ -153,7 +154,7 @@ export default class Tabs { const isInDenyList = await checkIfDenied(url); if (isInDenyList) { - this.redirectPhishingLanding(); + this.redirectPhishingLanding(url); } return false; diff --git a/packages/extension-ui/src/Popup/PhishingDetected.tsx b/packages/extension-ui/src/Popup/PhishingDetected.tsx index fd123240..13fcdb6d 100644 --- a/packages/extension-ui/src/Popup/PhishingDetected.tsx +++ b/packages/extension-ui/src/Popup/PhishingDetected.tsx @@ -5,6 +5,7 @@ import type { ThemeProps } from '../types'; import React from 'react'; import { Trans } from 'react-i18next'; +import { useParams } from 'react-router'; import styled from 'styled-components'; import useTranslation from '../hooks/useTranslation'; @@ -14,25 +15,28 @@ interface Props extends ThemeProps { className?: string; } +interface WebsiteState { + website: string; +} + function PhishingDetected ({ className }: Props): React.ReactElement { const { t } = useTranslation(); + const { website } = useParams(); + const decodedWebsite = decodeURIComponent(website); return ( <>
('Phishing detected')} />

- {t('You have been redirected because the Polkadot{.js} extension believes that this website could compromise the security of your accounts.')} + {t('You have been redirected because the Polkadot{.js} extension believes that this website could compromise the security of your accounts and your tokens.')}

-

- {t('The redirection could also happen on an outright malicious website or on a legitimate websites that has been compromised and flagged.')} -

-

- {t('This redirection is based on a list of websites accessible at https://github.com/polkadot-js/phishing. Note that this is a community-driven, curated list. \n It might be incomplete or inaccurate.')} +

+ {decodedWebsite}

- If you think that this website was flagged incorrectly, please open an issue by clicking here. + Note that this website was reported on a community-driven, curated list. It might be incomplete or inaccurate. If you think that this website was flagged incorrectly, please open an issue by clicking here.

@@ -49,5 +53,10 @@ export default styled(PhishingDetected)(({ theme }: Props) => ` a { color: ${theme.subTextColor}; } + + &.websiteAddress { + font-size: 1.3rem; + text-align: center; + } } `); diff --git a/packages/extension-ui/src/Popup/index.tsx b/packages/extension-ui/src/Popup/index.tsx index 0da3b56b..eabaa7a9 100644 --- a/packages/extension-ui/src/Popup/index.tsx +++ b/packages/extension-ui/src/Popup/index.tsx @@ -142,7 +142,7 @@ export default function Popup (): React.ReactElement { {wrapWithErrorBoundary(, 'restore-json')} {wrapWithErrorBoundary(, 'derived-address-locked')} {wrapWithErrorBoundary(, 'derive-address')} - {wrapWithErrorBoundary(, 'phishing-page-redirect')} + {wrapWithErrorBoundary(, 'phishing-page-redirect')}