Spaces:
Running
Running
File size: 4,919 Bytes
90531db 7fddf3d 90531db 7fddf3d 90531db 7fddf3d 90531db 7fddf3d 90531db 7fddf3d 90531db 7fddf3d 90531db | 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 117 118 119 120 121 122 123 | """Pydantic models for hash analysis."""
from pydantic import BaseModel, Field
class HashResult(BaseModel):
"""Result model for hash analysis with all VirusTotal fields."""
# Input information
input_hash: str = Field(
..., description="Original hash value submitted for analysis"
)
input_hash_type: str | None = Field(
None, description="Type of the input hash (MD5, SHA1, SHA256)"
)
# All corresponding hashes
md5: str | None = Field(None, description="MD5 hash of the file")
sha1: str | None = Field(None, description="SHA1 hash of the file")
sha256: str | None = Field(None, description="SHA256 hash of the file")
# Additional hashes
vhash: str | None = Field(None, description="VirusTotal perceptual hash")
ssdeep: str | None = Field(None, description="ssdeep fuzzy hash")
tlsh: str | None = Field(None, description="TLSH locality-sensitive hash")
# File information
file_name: str | None = Field(None, description="Primary file name if available")
names: list[str] | None = Field(None, description="All known file names")
file_type: str | None = Field(None, description="Type/description of the file")
file_size: int | None = Field(None, description="Size of the file in bytes")
magic: str | None = Field(None, description="File magic string")
type_tags: list[str] | None = Field(None, description="File type tags")
tags: list[str] | None = Field(None, description="All tags associated with file")
# Detection statistics
malicious_count: int | None = Field(
None, description="Number of engines detecting as malicious", ge=0
)
suspicious_count: int | None = Field(
None, description="Number of engines detecting as suspicious", ge=0
)
harmless_count: int | None = Field(
None, description="Number of engines detecting 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
)
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 file is considered malicious"
)
# Metadata
reputation: int | None = Field(None, description="VirusTotal reputation score")
times_submitted: int | None = Field(
None, description="Number of times file 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)"
)
last_modification_date: str | None = Field(
None, description="Last modification date (ISO format)"
)
# Signature information
signature_info: dict | None = Field(
None, description="Digital signature information"
)
# Error
error: str | None = Field(None, description="Error message if analysis failed")
class Config:
json_schema_extra = {
"example": {
"input_hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"input_hash_type": "SHA256",
"md5": "d41d8cd98f00b204e9800998ecf8427e",
"sha1": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"vhash": "0550101d3z1!z",
"ssdeep": "3::",
"tlsh": None,
"file_name": "example.exe",
"names": ["example.exe", "sample.exe"],
"file_type": "Win32 EXE",
"file_size": 12345,
"magic": "PE32 executable",
"type_tags": ["executable", "windows"],
"tags": ["signed", "peexe"],
"malicious_count": 5,
"suspicious_count": 2,
"harmless_count": 50,
"undetected_count": 18,
"total_engines": 75,
"malicious_percentage": 6.67,
"is_malicious": True,
"reputation": -100,
"times_submitted": 1000,
"first_submission_date": "2020-01-01T00:00:00Z",
"last_submission_date": "2026-01-10T12:00:00Z",
"last_analysis_date": "2026-01-10T12:00:00Z",
"last_modification_date": None,
"signature_info": {"verified": "Signed", "signers": "Microsoft"},
"error": None,
}
}
|