Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
ed514cae
Kaydet (Commit)
ed514cae
authored
Haz 16, 2015
tarafından
rroskam
Kaydeden (comit)
Tim Graham
Tem 15, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #24966 -- Added deployment system check for empty ALLOWED_HOSTS.
üst
c96f1125
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
0 deletions
+26
-0
base.py
django/core/checks/security/base.py
+10
-0
checks.txt
docs/ref/checks.txt
+1
-0
test_security.py
tests/check_framework/test_security.py
+15
-0
No files found.
django/core/checks/security/base.py
Dosyayı görüntüle @
ed514cae
...
@@ -95,6 +95,11 @@ W019 = Warning(
...
@@ -95,6 +95,11 @@ W019 = Warning(
id
=
'security.W019'
,
id
=
'security.W019'
,
)
)
W020
=
Warning
(
"ALLOWED_HOSTS must not be empty in deployment."
,
id
=
'security.W020'
,
)
def
_security_middleware
():
def
_security_middleware
():
return
"django.middleware.security.SecurityMiddleware"
in
settings
.
MIDDLEWARE_CLASSES
return
"django.middleware.security.SecurityMiddleware"
in
settings
.
MIDDLEWARE_CLASSES
...
@@ -182,3 +187,8 @@ def check_xframe_deny(app_configs, **kwargs):
...
@@ -182,3 +187,8 @@ def check_xframe_deny(app_configs, **kwargs):
settings
.
X_FRAME_OPTIONS
==
'DENY'
settings
.
X_FRAME_OPTIONS
==
'DENY'
)
)
return
[]
if
passed_check
else
[
W019
]
return
[]
if
passed_check
else
[
W019
]
@register
(
Tags
.
security
,
deploy
=
True
)
def
check_allowed_hosts
(
app_configs
,
**
kwargs
):
return
[]
if
settings
.
ALLOWED_HOSTS
else
[
W020
]
docs/ref/checks.txt
Dosyayı görüntüle @
ed514cae
...
@@ -476,6 +476,7 @@ of the :djadmin:`check` command:
...
@@ -476,6 +476,7 @@ of the :djadmin:`check` command:
``'DENY'``. The default is ``'SAMEORIGIN'``, but unless there is a good reason
``'DENY'``. The default is ``'SAMEORIGIN'``, but unless there is a good reason
for your site to serve other parts of itself in a frame, you should change
for your site to serve other parts of itself in a frame, you should change
it to ``'DENY'``.
it to ``'DENY'``.
* **security.W020**: :setting:`ALLOWED_HOSTS` must not be empty in deployment.
Sites
Sites
-----
-----
...
...
tests/check_framework/test_security.py
Dosyayı görüntüle @
ed514cae
...
@@ -482,3 +482,18 @@ class CheckDebugTest(SimpleTestCase):
...
@@ -482,3 +482,18 @@ class CheckDebugTest(SimpleTestCase):
@override_settings
(
DEBUG
=
False
)
@override_settings
(
DEBUG
=
False
)
def
test_debug_false
(
self
):
def
test_debug_false
(
self
):
self
.
assertEqual
(
self
.
func
(
None
),
[])
self
.
assertEqual
(
self
.
func
(
None
),
[])
class
CheckAllowedHostsTest
(
SimpleTestCase
):
@property
def
func
(
self
):
from
django.core.checks.security.base
import
check_allowed_hosts
return
check_allowed_hosts
@override_settings
(
ALLOWED_HOSTS
=
[])
def
test_allowed_hosts_empty
(
self
):
self
.
assertEqual
(
self
.
func
(
None
),
[
base
.
W020
])
@override_settings
(
ALLOWED_HOSTS
=
[
'.example.com'
,
])
def
test_allowed_hosts_set
(
self
):
self
.
assertEqual
(
self
.
func
(
None
),
[])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment