Spaces:
Running

File size: 4,180 Bytes
7fddf3d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
"""Pydantic models for URL reputation analysis."""

from pydantic import BaseModel, Field


class UrlResult(BaseModel):
    """Result model for URL reputation analysis with all VirusTotal fields."""

    url: str = Field(..., description="URL analyzed")

    # Resolved information
    final_url: str | None = Field(None, description="Final URL after redirects")
    title: str | None = Field(None, description="Page title")

    # Detection statistics
    malicious_count: int | None = Field(
        None, description="Number of engines flagging as malicious", ge=0
    )
    suspicious_count: int | None = Field(
        None, description="Number of engines flagging as suspicious", ge=0
    )
    harmless_count: int | None = Field(
        None, description="Number of engines flagging as harmless", ge=0
    )
    undetected_count: int | None = Field(
        None, description="Number of engines with no detection", ge=0
    )
    total_engines: int | None = Field(
        None, description="Total number of engines that scanned", ge=0
    )
    timeout_count: int | None = Field(
        None, description="Number of engines that timed out", ge=0
    )
    malicious_percentage: float | None = Field(
        None,
        description="Percentage of engines that flagged as malicious",
        ge=0,
        le=100,
    )
    is_malicious: bool | None = Field(
        None, description="Whether the URL is considered malicious"
    )

    # Reputation and categorization
    reputation_score: int | None = Field(
        None, description="VirusTotal reputation score"
    )
    categories: dict | None = Field(
        None, description="URL categories from various engines"
    )
    tags: list[str] | None = Field(None, description="Tags associated with URL")

    # Metadata
    times_submitted: int | None = Field(
        None, description="Number of times URL was submitted"
    )
    first_submission_date: str | None = Field(
        None, description="First submission date (ISO format)"
    )
    last_submission_date: str | None = Field(
        None, description="Last submission date (ISO format)"
    )
    last_analysis_date: str | None = Field(
        None, description="Last analysis date (ISO format)"
    )

    # HTTP response info
    last_http_response_code: int | None = Field(
        None, description="Last HTTP response status code"
    )
    last_http_response_content_length: int | None = Field(
        None, description="Last HTTP response content length"
    )
    last_http_response_content_sha256: str | None = Field(
        None, description="SHA256 of last HTTP response content"
    )

    # Trackers and outgoing links
    trackers: dict | None = Field(None, description="Trackers found on the page")
    outgoing_links: list[str] | None = Field(
        None, description="External links found on the page"
    )

    # Error
    error: str | None = Field(None, description="Error message if analysis failed")

    class Config:
        json_schema_extra = {
            "example": {
                "url": "https://google.com",
                "final_url": "https://www.google.com/",
                "title": "Google",
                "malicious_count": 0,
                "suspicious_count": 0,
                "harmless_count": 70,
                "undetected_count": 15,
                "total_engines": 85,
                "timeout_count": 0,
                "malicious_percentage": 0.0,
                "is_malicious": False,
                "reputation_score": 100,
                "categories": {"Forcepoint": "search engines"},
                "tags": ["top-1m"],
                "times_submitted": 100000,
                "first_submission_date": "2010-01-01T00:00:00Z",
                "last_submission_date": "2026-01-10T12:00:00Z",
                "last_analysis_date": "2026-01-10T12:00:00Z",
                "last_http_response_code": 200,
                "last_http_response_content_length": 12345,
                "last_http_response_content_sha256": None,
                "trackers": {},
                "outgoing_links": ["https://accounts.google.com"],
                "error": None,
            }
        }