Spaces:
Running

ioc-core / src /models /url.py
hellium1999's picture
feat: Add unified API, URLScan integration, IOC limit, updated README
7fddf3d
Raw History Blame
4.18 kB
"""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,
}
}