import React 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"; class ScanView extends React.Component { constructor(props) { super(props); this.state = { loaded: false, rescanInProgress: false }; this.getData = this.getData.bind(this); this.rescan = this.rescan.bind(this); } componentDidMount() { this.getData(); } getData() { fetch( `${window.injectedEnv.COLLECTOR_URL}/sc/v0/get/${this.props.id}`, { headers: { Authorization: "Bearer " + this.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 => { this.setState({ loaded: true, ...json.docs, timestamp: new Date(json.docs.timestamp) }); }) .catch(e => this.props.setError(e)); } // TODO: Trigger a real re-scan rescan() { this.setState({ rescanInProgress: true }); setTimeout( () => this.setState(prevState => ({ rescanInProgress: false, timestamp: Date.now() })), 2000 ); } render() { return ( this.state.loaded && (
#{this.state._id}

General info

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

Custom info

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

{Object.entries(this.state.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;