import React, { useState, useEffect } from "react"; import Alert from "@mui/material/Alert"; import Button from "@mui/material/Button"; import Card from "@mui/material/Card"; import CircularProgress from "@mui/material/CircularProgress"; import Tooltip from "@mui/material/Tooltip"; import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined"; import dateFormat from "dateformat"; import { resultClassName } from "../util"; function ScanView(props) { let [rescanInProgress, setRescanInProgress] = useState(false); let [data, setData] = useState(null); let [timestamp, setTimestamp] = useState(null); useEffect(getData, []); function getData() { fetch(`${window.injectedEnv.COLLECTOR_URL}/sc/v0/get/${props.id}`, { headers: { Authorization: "Bearer " + props.token } }) .then(resp => { if (resp.status !== 200) throw new Error( `Unexpected HTTP response code from soc_collector: ${resp.status} ${resp.statusText}` ); return resp.json(); }) .then(json => { setData(json.docs); setTimestamp(new Date(json.docs.timestamp)); }) .catch(e => props.setError(e.toString())); } // TODO: Trigger a real re-scan function rescan() { setRescanInProgress(true); setTimeout(() => { setRescanInProgress(false); setTimestamp(Date.now()); }, 2000); } if (data === null) return null; else { return (
#{data._id}

General info

Domain {data.domain}
Endpoint {`${data.ip}:${data.port}`}
Hostname {data.ptr}
Owner {data.whois_description}
ASN {`${data.asn} (${data.asn_country_code})`}
Abuse mail {data.abuse_mail}
{data.description && ( <>
{data.description} )}

Custom info

Latest scan:     {dateFormat(timestamp, "isoUtcDateTime")}
{rescanInProgress ? ( ) : ( )}

{Object.entries(data.result) // Sort by vulnerable, investigation_needed, reliability, name .sort((a, b) => a[1].display_name > b[1].display_name ? -1 : 1 ) .sort((a, b) => a[1].reliability < b[1].reliability ? -1 : 1 ) .sort((a, b) => a[1].vulnerable || a[1].investigation_needed ? -1 : 1 ) .sort((a, b) => (a[1].vulnerable ? -1 : 1)) .map(([id, res]) => ( ))}
); } } function Custom(props) { return ( {Object.entries(props).map( ([key, { data, display_name, description }]) => ( ) )}
); } function CustomElement(props) { return ( {props.display_name} {props.data.toString()} {props.description} ); } function Result(props) { return (
{props.display_name} {props.description && ( )} {(props.vulnerable || props.investigation_needed) && ( {props.reliability} )}
); } export default ScanView;