A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/django/django/commit/08892bffd275c79ee1f8f67639eb170aaaf1181e below:

[3.0.x] Fixed CVE-2020-24583, #31921 -- Fixed permissions on intermed… · django/django@08892bf · GitHub

4 4

import tempfile

5 5

import unittest

6 6

from io import StringIO

7 +

from pathlib import Path

7 8

from unittest import mock

8 9 9 10

from django.conf import settings

@@ -530,25 +531,39 @@ def run_collectstatic(self, **kwargs):

530 531

)

531 532

def test_collect_static_files_permissions(self):

532 533

call_command('collectstatic', **self.command_params)

533 -

test_file = os.path.join(settings.STATIC_ROOT, "test.txt")

534 -

test_dir = os.path.join(settings.STATIC_ROOT, "subdir")

535 -

file_mode = os.stat(test_file)[0] & 0o777

536 -

dir_mode = os.stat(test_dir)[0] & 0o777

534 +

static_root = Path(settings.STATIC_ROOT)

535 +

test_file = static_root / 'test.txt'

536 +

file_mode = test_file.stat().st_mode & 0o777

537 537

self.assertEqual(file_mode, 0o655)

538 -

self.assertEqual(dir_mode, 0o765)

538 +

tests = [

539 +

static_root / 'subdir',

540 +

static_root / 'nested',

541 +

static_root / 'nested' / 'css',

542 +

]

543 +

for directory in tests:

544 +

with self.subTest(directory=directory):

545 +

dir_mode = directory.stat().st_mode & 0o777

546 +

self.assertEqual(dir_mode, 0o765)

539 547 540 548

@override_settings(

541 549

FILE_UPLOAD_PERMISSIONS=None,

542 550

FILE_UPLOAD_DIRECTORY_PERMISSIONS=None,

543 551

)

544 552

def test_collect_static_files_default_permissions(self):

545 553

call_command('collectstatic', **self.command_params)

546 -

test_file = os.path.join(settings.STATIC_ROOT, "test.txt")

547 -

test_dir = os.path.join(settings.STATIC_ROOT, "subdir")

548 -

file_mode = os.stat(test_file)[0] & 0o777

549 -

dir_mode = os.stat(test_dir)[0] & 0o777

554 +

static_root = Path(settings.STATIC_ROOT)

555 +

test_file = static_root / 'test.txt'

556 +

file_mode = test_file.stat().st_mode & 0o777

550 557

self.assertEqual(file_mode, 0o666 & ~self.umask)

551 -

self.assertEqual(dir_mode, 0o777 & ~self.umask)

558 +

tests = [

559 +

static_root / 'subdir',

560 +

static_root / 'nested',

561 +

static_root / 'nested' / 'css',

562 +

]

563 +

for directory in tests:

564 +

with self.subTest(directory=directory):

565 +

dir_mode = directory.stat().st_mode & 0o777

566 +

self.assertEqual(dir_mode, 0o777 & ~self.umask)

552 567 553 568

@override_settings(

554 569

FILE_UPLOAD_PERMISSIONS=0o655,

@@ -557,12 +572,19 @@ def test_collect_static_files_default_permissions(self):

557 572

)

558 573

def test_collect_static_files_subclass_of_static_storage(self):

559 574

call_command('collectstatic', **self.command_params)

560 -

test_file = os.path.join(settings.STATIC_ROOT, "test.txt")

561 -

test_dir = os.path.join(settings.STATIC_ROOT, "subdir")

562 -

file_mode = os.stat(test_file)[0] & 0o777

563 -

dir_mode = os.stat(test_dir)[0] & 0o777

575 +

static_root = Path(settings.STATIC_ROOT)

576 +

test_file = static_root / 'test.txt'

577 +

file_mode = test_file.stat().st_mode & 0o777

564 578

self.assertEqual(file_mode, 0o640)

565 -

self.assertEqual(dir_mode, 0o740)

579 +

tests = [

580 +

static_root / 'subdir',

581 +

static_root / 'nested',

582 +

static_root / 'nested' / 'css',

583 +

]

584 +

for directory in tests:

585 +

with self.subTest(directory=directory):

586 +

dir_mode = directory.stat().st_mode & 0o777

587 +

self.assertEqual(dir_mode, 0o740)

566 588 567 589 568 590

@override_settings(


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4