diff --git a/api/malware.js b/api/threats.js similarity index 91% rename from api/malware.js rename to api/threats.js index 3b4e226..edc987c 100644 --- a/api/malware.js +++ b/api/threats.js @@ -52,6 +52,9 @@ const handler = async (url) => { const urlHaus = await getUrlHausResult(url); const phishTank = await getPhishTankResult(url); const cloudmersive = await getCloudmersiveResult(url); + if (urlHaus.error && phishTank.error && cloudmersive.error) { + throw new Error(`All requests failed - ${urlHaus.error} ${phishTank.error} ${cloudmersive.error}`); + } return JSON.stringify({ urlHaus, phishTank, cloudmersive }); } catch (error) { throw new Error(error.message); diff --git a/src/components/Results/Malware.tsx b/src/components/Results/Threats.tsx similarity index 78% rename from src/components/Results/Malware.tsx rename to src/components/Results/Threats.tsx index 1b681a8..a892eaf 100644 --- a/src/components/Results/Malware.tsx +++ b/src/components/Results/Threats.tsx @@ -33,8 +33,22 @@ const convertToDate = (dateString: string): string => { const MalwareCard = (props: {data: any, title: string, actionButtons: any }): JSX.Element => { const urlHaus = props.data.urlHaus; + const phishTank = props.data.phishTank; + const cloudmersive = props.data.cloudmersive; return ( + { cloudmersive && !cloudmersive.error && ( + + )} + { phishTank && !phishTank.error && ( + + )} + { phishTank.url0 && phishTank.url0.phish_detail_page && ( + + Phish Info + {phishTank.url0.phish_id} + + )} { urlHaus.query_status === 'no_results' && } { urlHaus.query_status === 'ok' && ( <> diff --git a/src/components/misc/ProgressBar.tsx b/src/components/misc/ProgressBar.tsx index 0164dfc..81eb98e 100644 --- a/src/components/misc/ProgressBar.tsx +++ b/src/components/misc/ProgressBar.tsx @@ -218,7 +218,7 @@ const jobNames = [ 'rank', 'archives', 'block-lists', - 'malware', + 'threats', ] as const; export const initialJobs = jobNames.map((job: string) => { diff --git a/src/pages/Results.tsx b/src/pages/Results.tsx index a8027a4..69cb682 100644 --- a/src/pages/Results.tsx +++ b/src/pages/Results.tsx @@ -53,7 +53,7 @@ import FirewallCard from 'components/Results/Firewall'; import ArchivesCard from 'components/Results/Archives'; import RankCard from 'components/Results/Rank'; import BlockListsCard from 'components/Results/BlockLists'; -import MalwareCard from 'components/Results/Malware'; +import ThreatsCard from 'components/Results/Threats'; import keys from 'utils/get-keys'; import { determineAddressType, AddressType } from 'utils/address-type-checker'; @@ -450,11 +450,11 @@ const Results = (): JSX.Element => { }); // Check if a host is present on the URLHaus malware list - const [malwareResults, updateMalwareResults] = useMotherHook({ - jobId: 'malware', + const [threatResults, updateThreatResults] = useMotherHook({ + jobId: 'threats', updateLoadingJobs, addressInfo: { address, addressType, expectedAddressTypes: urlTypeOnly }, - fetchRequest: () => fetch(`${api}/malware?url=${address}`).then(res => parseJson(res)), + fetchRequest: () => fetch(`${api}/threats?url=${address}`).then(res => parseJson(res)), }); /* Cancel remaining jobs after 10 second timeout */ @@ -512,7 +512,7 @@ const Results = (): JSX.Element => { { id: 'linked-pages', title: 'Linked Pages', result: linkedPagesResults, Component: ContentLinksCard, refresh: updateLinkedPagesResults }, { id: 'txt-records', title: 'TXT Records', result: txtRecordResults, Component: TxtRecordCard, refresh: updateTxtRecordResults }, { id: 'block-lists', title: 'Block Lists', result: blockListsResults, Component: BlockListsCard, refresh: updateBlockListsResults }, - { id: 'malware', title: 'Malware', result: malwareResults, Component: MalwareCard, refresh: updateMalwareResults }, + { id: 'threats', title: 'Threats', result: threatResults, Component: ThreatsCard, refresh: updateThreatResults }, { id: 'features', title: 'Site Features', result: siteFeaturesResults, Component: SiteFeaturesCard, refresh: updateSiteFeaturesResults }, { id: 'sitemap', title: 'Pages', result: sitemapResults, Component: SitemapCard, refresh: updateSitemapResults }, { id: 'carbon', title: 'Carbon Footprint', result: carbonResults, Component: CarbonFootprintCard, refresh: updateCarbonResults },