[2.2.x] Refs CVE-2021-31542 -- Skipped mock AWS storage test on Windows.

The validate_file_name() sanitation introduced in
0b79eb3691 correctly rejects the example
file name as containing path elements on Windows. This breaks the test
introduced in 914c72be2a to allow path
components for storages that may allow them.

Test is skipped pending a discussed storage refactoring to support this
use-case.

Backport of a708f39ce6 from main
This commit is contained in:
Carlton Gibson 2021-05-04 14:44:19 +02:00 committed by Mariusz Felisiak
parent bcafd9ba84
commit 163700388c
1 changed files with 3 additions and 0 deletions

View File

@ -1,4 +1,6 @@
import os
import sys
from unittest import skipIf
from django.core.exceptions import SuspiciousFileOperation
from django.core.files.base import ContentFile
@ -93,6 +95,7 @@ class GenerateFilenameStorageTests(SimpleTestCase):
os.path.normpath('some/folder/test_with_space.txt')
)
@skipIf(sys.platform == 'win32', 'Path components in filename are not supported after 0b79eb3.')
def test_filefield_awss3_storage(self):
"""
Simulate a FileField with an S3 storage which uses keys rather than