feat: implement modular content scanning pipeline for image validatio… - #622
Merged
Qoder-Undefined merged 1 commit intoJul 28, 2026
Merged
Conversation
…n and virus detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#Closes
#613
Pull Request: Secure Upload Pipeline (Scanners, Deduplication & Sanitization)
Description
This Pull Request secures the file upload endpoint in
meridian-apiagainst malicious payloads, image decompression bombs, stored XSS / file-name reflection vectors, and prevents duplicated object store usage.Key Changes
1. Strategy Interface & Content Scanners
ContentScannerStrategy: Created a strategy interfaceContentScannerunder content-scanner.interface.ts.ImageDimensionsScanner): Checks logical screen dimensions for PNG, GIF, and JPEG images by stream-decoding header metadata from raw file buffers in image-dimensions.scanner.ts. Avoids loading the full pixel array into memory, fast-failing if width or height exceeds limits (default 4096px).ClamAvScanner): Implemented clamd antivirus scan in clam-av.scanner.ts usingINSTREAMprotocol over TCP. Falls back to spawning a localclamscanchild process on temporary workspace files if TCP clamd is not configured.2. Idempotency & Hashing
UploadServicenow computes a SHA-256 hash of every uploaded file buffer. If the hash matches an existing record in the database, the service immediately returns the cached URL and sanitized name, avoiding storage replication and redundant network writes.UploadEntity: Added upload.entity.ts to trackcontentHash,url,originalName,mimeType, andsize.3. File Name Sanitization
../../)..jpgforimage/jpeg).Security Mitigations
ImageDimensionsScanner.ClamAvScanner.<script>) reflect payload to client UI.originalNamestem inUploadService.Verification
Automated Tests
The following unit test suites were added or updated to cover all scanning, sanitization, and deduplication logic:
src/upload/upload.service.spec.tssrc/upload/providers/image-dimensions.scanner.spec.tssrc/upload/providers/clam-av.scanner.spec.tsRun Jest:
Results:
Build verification:
Results: