瀏覽代碼

Fixed #35646 -- Extended SafeExceptionReporterFilter.hidden_settings to treat `AUTH` as a sensitive match.

Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
Markus Holtermann 7 月之前
父節點
當前提交
aa90795050
共有 4 個文件被更改,包括 11 次插入4 次删除
  1. 1 1
      django/views/debug.py
  2. 5 1
      docs/howto/error-reporting.txt
  3. 2 1
      docs/releases/5.2.txt
  4. 3 1
      tests/view_tests/tests/test_debug.py

+ 1 - 1
django/views/debug.py

@@ -113,7 +113,7 @@ class SafeExceptionReporterFilter:
 
     cleansed_substitute = "********************"
     hidden_settings = _lazy_re_compile(
-        "API|TOKEN|KEY|SECRET|PASS|SIGNATURE|HTTP_COOKIE", flags=re.I
+        "API|AUTH|TOKEN|KEY|SECRET|PASS|SIGNATURE|HTTP_COOKIE", flags=re.I
     )
 
     def cleanse_setting(self, key, value):

+ 5 - 1
docs/howto/error-reporting.txt

@@ -282,7 +282,11 @@ following attributes and methods:
 
             import re
 
-            re.compile(r"API|TOKEN|KEY|SECRET|PASS|SIGNATURE|HTTP_COOKIE", flags=re.IGNORECASE)
+            re.compile(r"API|AUTH|TOKEN|KEY|SECRET|PASS|SIGNATURE|HTTP_COOKIE", flags=re.IGNORECASE)
+
+        .. versionchanged:: 5.2
+
+            The term ``AUTH`` was added.
 
     .. method:: is_active(request)
 

+ 2 - 1
docs/releases/5.2.txt

@@ -150,7 +150,8 @@ Email
 Error Reporting
 ~~~~~~~~~~~~~~~
 
-* ...
+* The attribute :attr:`.SafeExceptionReporterFilter.hidden_settings` now
+  treats values as sensitive if their name includes ``AUTH``.
 
 File Storage
 ~~~~~~~~~~~~

+ 3 - 1
tests/view_tests/tests/test_debug.py

@@ -1557,7 +1557,8 @@ class ExceptionReporterFilterTests(
         "SECRET_KEY_FALLBACKS",
         "PASSWORD",
         "API_KEY",
-        "AUTH_TOKEN",
+        "SOME_TOKEN",
+        "MY_AUTH",
     ]
 
     def test_non_sensitive_request(self):
@@ -1885,6 +1886,7 @@ class ExceptionReporterFilterTests(
             "PASSWORD": "super secret",
             "SECRET_VALUE": "super secret",
             "SOME_TOKEN": "super secret",
+            "THE_AUTH": "super secret",
         }
         request = self.rf.get("/", headers=headers)
         reporter_filter = SafeExceptionReporterFilter()