Spaces:
Sleeping
Sleeping
File size: 2,017 Bytes
a6ba120 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
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
|