Spaces:
Running
Running
Download src/models/url.py from reputeradar/ioc-core: direct link, hf CLI and curl.
- Browser
- Download file 4.18 kB
-
https://huggingface.co/spaces/reputeradar/ioc-core/resolve/main/src/models/url.py
- Command line
-
hf download hf://spaces/reputeradar/ioc-core/src/models/url.py
-
curl -L -o url.py https://huggingface.co/spaces/reputeradar/ioc-core/resolve/main/src/models/url.py
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, | |
| } | |
| } | |