SaaS · APIs · Cybersecurity
फ़ाइल निरीक्षण API: एक REST कॉल में SHA-256, वास्तविक MIME, एंटीवायरस संकेत और metadata
फ़ाइल निरीक्षण API: एक REST कॉल में SHA-256, वास्तविक MIME, एंटीवायरस संकेत और metadata
जो application upload स्वीकार करती हैं, उन्हें अक्सर किसी parser, workflow या storage pipeline को फ़ाइल देने से पहले एक छोटा तकनीकी checkpoint चाहिए। Marketplace को seller documents मिल सकते हैं, SaaS product customer attachments स्वीकार कर सकता है और sharing platform को यह दर्ज करना पड़ सकता है कि system में क्या आया। हर team hash, MIME detection, metadata extraction और शुरुआती malware triage अलग से बना सकती है, लेकिन इन checks को लगातार एक जैसा चलाना हमेशा आसान नहीं होता। FileInspection इन्हें asynchronous REST contract में एक साथ देती है और एक JSON report लौटाती है।
Multipart request
Authenticated client POST /api/files/start-process पर multipart request भेजते हैं। इसमें actionName=FileInspection, file field में एक फ़ाइल, parameters=[] और async=true होना चाहिए। एक call में एक non-empty फ़ाइल, अधिकतम 50 MB, स्वीकार होती है और extension filter नहीं है। Server request और size को स्वयं validate करता है; browser का accept attribute, filename या घोषित MIME security boundary नहीं है।
पहला response queued action को दिखाता है, तैयार report को नहीं। Process ID और trackingUrl सुरक्षित रखें और authenticated context से /api/actions/get-action-infos/{id} को poll करें। इससे MIME detection, एंटीवायरस इंजन triage, metadata extraction या media probing के दौरान upload request खुली रखने की आवश्यकता नहीं रहती।
JSON report में क्या होता है
सफल FileInspection result एक JSON file है। इसमें original filename और size, SHA-256 hash तथा वास्तविक detected MIME type दर्ज होता है। MIME value content से निकाली जाती है, browser से मिली value को प्रमाण नहीं माना जाता। इससे application के पास logging, routing या आगे parser को भेजने का अधिक विश्वसनीय आधार होता है।
Format support होने पर ExifTool filtered EXIF metadata दे सकता है। Audio और video के लिए FFprobe codec, resolution, duration और bitrate दे सकता है। Images और PDF को 500 characters तक का OCR preview मिल सकता है। ये fields format पर निर्भर हैं; इनके absent या empty होने का अर्थ यह नहीं कि upload fail हुआ।
Triage signals की सीमाएँ
Antivirus section एंटीवायरस इंजन का clean, infected या error status देता है। यह प्रारंभिक triage signal है, antivirus guarantee कभी नहीं। खासकर clean का अर्थ केवल यह है कि इस inspection ने कोई detection report नहीं की; इसे user interface या automated policy में “certified safe” नहीं बनाया जा सकता। error को clean से अलग रखना जरूरी है, ताकि integrator सावधान fallback चुन सके।
डिटेक्शन नियम-संग्रह section clean, matched या not_run देती है। Starter rules न्यूनतम हैं, exhaustive detection base नहीं। matched review का कारण हो सकता है, जबकि clean या not_run किसी threat की अनुपस्थिति सिद्ध नहीं करते। Documentation, logs और product messages में यह अंतर बनाए रखें।
मजबूत integration तैयार करें
Action ID को asynchronous job का durable reference मानकर रखें। कम-से-कम rejected validation, processing, failed processing और completed result को अलग states की तरह संभालें। Polling timeout होने पर दूसरा submission करने से पहले मौजूदा action पढ़ें। केवल status request के जवाब न देने पर फिर से inspection शुरू करना duplicate work और अनावश्यक token खर्च पैदा कर सकता है।
Success के बाद server की दी हुई result reference और authenticated download flow से JSON लें। केवल integer ID से result URL न बनाएं और client द्वारा भेजे गए action ID को authorization न मानें। अपनी application में upload record से report जोड़ते समय ownership भी जांचें। Hash deduplication और traceability में मदद करता है, फ़ाइल तक पहुँच नहीं देता।
कीमत और व्यावहारिक दायरा
सफल inspection की कीमत 12 tokens है। Empty file या 50 MB से बड़ी फ़ाइल समेत validation failures पर शुल्क नहीं लगता। यह parsing या human review से पहले एक सीमित technical checkpoint है, complete malware-analysis platform या अपनी content policy का विकल्प नहीं।
एक asynchronous REST call से integration को SHA-256, वास्तविक MIME, प्रारंभिक एंटीवायरस इंजन signal, minimal डिटेक्शन नियम-संग्रह status, filtered metadata और format के अनुसार media या OCR details मिलती हैं। साफ asynchronous contract calling system को अपनी queue चलाते हुए inspection का audit योग्य reference रखने देता है।