Expand FileValidator.SAFE_EXTENSIONS for better test flexibility #161

Open
opened 2025-10-14 22:07:07 +00:00 by tegwick · 0 comments
Owner

Problem

Tests fail when using common file extensions like '.dat' because FileValidator.SAFE_EXTENSIONS has a limited whitelist. This makes test data creation restrictive and can block legitimate use cases.

Evidence

  • tests/test_issue_144_integration_workflow.py:504 had to change from .dat to .txt files
  • FileValidator.SAFE_EXTENSIONS only includes: '.md', '.mdx', '.txt', '.json', '.yaml', '.yml', '.png', '.jpg', '.jpeg', '.gif', '.svg', '.webp', '.pdf', '.zip', '.tar', '.gz'
  • Many legitimate file types are rejected

Impact

  • Test authors must use specific extensions, reducing test realism
  • Users might be blocked from importing legitimate file types
  • Creates unnecessary friction in testing workflows

Proposed Solution

Option A (Recommended): Make FileValidator configurable

Option B: Expand the default SAFE_EXTENSIONS list

  • Add common data/test extensions: '.dat', '.bin', '.tmp', '.test'
  • Add more document types: '.docx', '.xlsx', '.pptx', '.odt'

Option C: Add test-specific override mechanism

Benefits

  • More flexible testing without compromising security
  • Better user experience for legitimate file types
  • Configurable security policy per use case

Files Affected

  • markitect/assets/utils.py:FileValidator class
  • Tests that need broader file type support

Priority

Low - Quality of life improvement for testing and development

## Problem Tests fail when using common file extensions like '.dat' because FileValidator.SAFE_EXTENSIONS has a limited whitelist. This makes test data creation restrictive and can block legitimate use cases. ## Evidence - tests/test_issue_144_integration_workflow.py:504 had to change from .dat to .txt files - FileValidator.SAFE_EXTENSIONS only includes: '.md', '.mdx', '.txt', '.json', '.yaml', '.yml', '.png', '.jpg', '.jpeg', '.gif', '.svg', '.webp', '.pdf', '.zip', '.tar', '.gz' - Many legitimate file types are rejected ## Impact - Test authors must use specific extensions, reducing test realism - Users might be blocked from importing legitimate file types - Creates unnecessary friction in testing workflows ## Proposed Solution **Option A (Recommended)**: Make FileValidator configurable **Option B**: Expand the default SAFE_EXTENSIONS list - Add common data/test extensions: '.dat', '.bin', '.tmp', '.test' - Add more document types: '.docx', '.xlsx', '.pptx', '.odt' **Option C**: Add test-specific override mechanism ## Benefits - More flexible testing without compromising security - Better user experience for legitimate file types - Configurable security policy per use case ## Files Affected - markitect/assets/utils.py:FileValidator class - Tests that need broader file type support ## Priority Low - Quality of life improvement for testing and development
tegwick added this to the Images And File Attachments project 2025-10-14 22:21:06 +00:00
Sign in to join this conversation.