Merge pull request #260 from christianlouis/copilot/format-code-with-linters
style: fix black, isort, and flake8 violations across app/ and tests/
This commit is contained in:
@@ -4,11 +4,11 @@ Security tests for path traversal vulnerabilities.
|
||||
Tests all file path operations to ensure they properly prevent path traversal attacks.
|
||||
"""
|
||||
|
||||
import os
|
||||
import json
|
||||
import os
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock, patch, MagicMock
|
||||
from unittest.mock import MagicMock, Mock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -389,9 +389,10 @@ class TestFileUploadSecurity:
|
||||
|
||||
def test_sanitize_after_basename(self):
|
||||
"""Test that sanitization happens after basename extraction."""
|
||||
from app.utils.filename_utils import sanitize_filename
|
||||
import os
|
||||
|
||||
from app.utils.filename_utils import sanitize_filename
|
||||
|
||||
malicious = "../../../passwd.pdf"
|
||||
|
||||
# Step 1: Extract basename (as ui_upload does)
|
||||
@@ -442,10 +443,11 @@ class TestEndToEndPathTraversal:
|
||||
|
||||
def test_full_upload_flow_prevents_traversal(self, tmp_path):
|
||||
"""Test complete upload flow prevents path traversal."""
|
||||
from app.utils.filename_utils import sanitize_filename
|
||||
import os
|
||||
import uuid
|
||||
|
||||
from app.utils.filename_utils import sanitize_filename
|
||||
|
||||
# Simulate ui_upload flow
|
||||
malicious_upload_filename = "../../../etc/passwd"
|
||||
|
||||
@@ -472,9 +474,10 @@ class TestEndToEndPathTraversal:
|
||||
|
||||
def test_metadata_embedding_flow_prevents_traversal(self, tmp_path):
|
||||
"""Test metadata embedding flow prevents path traversal."""
|
||||
from app.utils.filename_utils import sanitize_filename
|
||||
import os
|
||||
|
||||
from app.utils.filename_utils import sanitize_filename
|
||||
|
||||
# Simulate GPT returning malicious filename
|
||||
gpt_metadata = {
|
||||
"filename": "../../../etc/shadow",
|
||||
|
||||
Reference in New Issue
Block a user