from dataclasses import dataclass from datetime import datetime @dataclass class Stats: """ Represents the statistics of the analysis results. Attributes: malicious (int): Number of engines that detected the URL as malicious. suspicious (int): Number of engines that detected the URL as suspicious. undetected (int): Number of engines that did not detect the URL. harmless (int): Number of engines that detected the URL as harmless. timeout (int): Number of engines that timed out during the analysis. """ malicious: int suspicious: int undetected: int harmless: int timeout: int @dataclass class Attributes: """ Represents the attributes of the analysis. If status is queued, retry later. Attributes: date (int): The timestamp of the analysis in Unix epoch format. status (str): The status of the analysis (e.g., "queued"). stats (Stats): An instance of the Stats class containing analysis statistics. """ date: int status: str stats: Stats def get_date_as_datetime(self) -> datetime: """ Convert the Unix epoch timestamp to a datetime object. Returns: datetime: The datetime representation of the analysis date. """ return datetime.fromtimestamp(self.date) @dataclass class Data: """ Represents the data section of the VirusTotal analysis response. Attributes: id (str): The unique identifier for the analysis. type (str): The type of the data, which is "analysis" in this context. attributes (Attributes): An instance of the Attributes class containing analysis details. """ id: str type: str attributes: Attributes @dataclass class GetURLReportResponse: """ Represents the overall response from the VirusTotal API for a URL scan analysis. Attributes: data (Data): An instance of the Data class containing analysis details. """ data: Data