8000 feat: Case attachments by topher-lo · Pull Request #1243 · TracecatHQ/tracecat · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Case attachments #1243

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

Open
wants to merge 49 commits into
base: main
Choose a base branch
from
Open

feat: Case attachments #1243

wants to merge 49 commits into from

Conversation

topher-lo
Copy link
Contributor
@topher-lo topher-lo commented Jul 3, 20 8000 25

Summary by cubic

Added support for uploading, listing, downloading, and deleting file attachments on cases, using MinIO for secure blob storage.

  • New Features
    • Users can attach files to cases in the UI.
    • Attachments are stored in MinIO and accessed via presigned URLs.
    • Added backend APIs and database models for case attachments.
    • Includes file validation, security checks, and detailed tests.

QA:

  • Upload file, delete file, reupload file.
  • Test preview and download attachments

Screenshots

Screenshot 2025-07-03 at 8 45 41 PM Screenshot 2025-07-02 at 10 26 01 PM

@topher-lo topher-lo added enhancement New feature or request frontend Improvements or additions to the frontend api Improvements or additions to the backend API labels Jul 3, 2025
Copy link
Contributor
@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic found 7 issues across 26 files. Review them in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.

@topher-lo topher-lo force-pushed the feat/case-attachments-3 branch 2 times, most recently from 4b53071 to d13364c Compare July 4, 2025 04:35
@topher-lo topher-lo requested a review from daryllimyt July 4, 2025 04:35
Copy link
Contributor
@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic found 3 issues across 28 files. Review them in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.

@topher-lo topher-lo force-pushed the feat/case-attachments-3 branch 2 times, most recently from 087abe2 to b3f93a1 Compare July 4, 2025 20:40
@topher-lo topher-lo removed the request for review from daryllimyt July 4, 2025 20:57
topher-lo and others added 27 commits July 4, 2025 22:34
  1. test_validate_pdf_content: Updated to use the correct exception types (FileContentMismatchError and FileSecurityError instead of ValueError) and adjusted test expectations to match the new PDF validation behavior.
  2. test_upload_delete_reupload_cycle: Fixed SQLAlchemy greenlet error by re-fetching database records instead of refreshing them, and updated expectation to match service behavior (reuses same attachment record).
  3. test_upload_delete_reupload_different_case: Updated expectation for upload count - the service doesn't re-upload files that exist (even if soft-deleted).
  4. test_multiple_uploads_same_content_deduplication: Updated expectation to match service behavior - returns the same attachment when uploading duplicate content to the same case.
…tion

- Switch from multipart/form-data to JSON with base64 encoding to bypass AWS WAF restrictions
- Add comprehensive XSS protection for file downloads with Content-Disposition headers
- Block SVG files entirely due to embedded JavaScript risks
- Separate preview functionality from downloads with strict content type controls
- Update all tests to support new base64 upload format and security features
- Add @pytest.mark.anyio decorators to async tests in test_blob_storage.py

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add preview parameter to download endpoint for safe image viewing
- Implement force_download and override_content_type in presigned URLs
- Update file size limits to more conservative values (20MB/200MB/10 files)
- Add SVG validation and blocking for security
- Separate preview vs download functionality for XSS protection
- Add comprehensive test coverage for new security features

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Rename TRACECAT__BLOB_STORAGE_BUCKET to TRACECAT__BLOB_STORAGE_BUCKET_ATTACHMENTS
- Make bucket parameter required in all storage functions
- Update all storage calls to explicitly pass bucket name
- Remove default bucket fallback behavior
- Set default presigned URL endpoint configuration
- Update tests to match new bucket configuration

This change improves storage organization by using separate buckets for different types of data.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove TRACECAT__BLOB_STORAGE_PRESIGNED_URL_ENDPOINT config
- Remove TRACECAT__DISABLE_PRESIGNED_URL_IP_CHECKING config
- Remove client_ip parameter from presigned URL generation
- Simplify URL transformation to directly replace MinIO internal URL
- Update tests to work with simplified storage logic

The presigned URLs now always transform "http://minio:9000" to
"{TRACECAT__PUBLIC_APP_URL}/s3" for proper routing through the proxy.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove client_ip parameter from get_attachment_download_url method
- Update router to stop passing client_ip from request state
- Fix integration tests that were failing due to the parameter mismatch

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@topher-lo topher-lo force-pushed the feat/case-attachments-3 branch from 0aa82ed to 476d72e Compare July 5, 2025 05:37
@topher-lo topher-lo force-pushed the feat/case-attachments-3 branch from 476d72e to b486dda Compare July 5, 2025 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Improvements or additions to the backend API enhancement New feature or request frontend Improvements or additions to the frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0