-
Notifications
You must be signed in to change notification settings - Fork 46.3k
feat(backend): Add ClamAV scanning for local file paths #11988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…a_file Files processed via local paths in store_media_file() were not being scanned through ClamAV, unlike URLs, data URIs, cloud paths, and workspace references which already had scanning. This gap affected video processing blocks (LoopVideoBlock, AddAudioToVideoBlock, etc.) that write output to temp directories then pass filenames to store_media_file(). Changes: - Add virus scanning to the local file path branch in store_media_file() - Add file size limit check consistent with other input types - Add unit tests for local file scanning behavior Closes SECRT-1904
WalkthroughReads local file bytes in store_media_file, enforces MAX_FILE_SIZE_BYTES, and performs an asynchronous virus scan (scan_content_safe) with the sanitized filename before continuing; tests added to validate scanning and virus-detection propagation for local paths. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Store as store_media_file
participant FS as LocalFS
participant Scanner as ClamAVScanner
Client->>Store: submit local file path
Store->>FS: resolve & open file (read bytes)
FS-->>Store: file bytes
Store->>Scanner: scan_content_safe(bytes, sanitized_filename)
alt scan ok
Scanner-->>Store: scan result OK
Store->>Client: continue processing / return local filename
else virus detected
Scanner-->>Store: raises VirusDetectedError
Store-->>Client: propagate error
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
✏️ Tip: You can disable this entire section by setting Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ntindle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Reviewed: Closes security gap where local file paths weren't virus-scanned.
- Reads file bytes, checks size, calls existing
scan_content_safe() - Good test coverage (scan called + virus detected scenarios)
- Simple, focused fix
LGTM
ⓘ Your monthly quota for Qodo has expired. Upgrade your plan ⓘ Paying users. Check that your Qodo account is linked with this Git user account |
Context
From PR #11796 review discussion. Files processed by the video blocks (downloads, uploads, generated videos) should be scanned through ClamAV for malware detection.
Problem
store_media_file()inbackend/util/file.pyalready scans:workspace://referencesdata:...)But local file paths were NOT scanned. The
elsebranch only verified the file exists.This gap affected video processing blocks (e.g.,
LoopVideoBlock,AddAudioToVideoBlock) that:store_media_file(output_filename, ...)with a local path → skipped virus scanningSolution
Added virus scanning to the local file path branch:
Changes
backend/util/file.py- Added ~7 lines to scan local files (consistent with other input types)backend/util/file_test.py- Added 2 test cases for local file scanningRisk Assessment
Closes SECRT-1904