• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / fx-private-relay / e6d2a6e9-0bc0-472e-b2df-511be8d99861

05 May 2025 05:52PM CUT coverage: 85.25% (+0.007%) from 85.243%
e6d2a6e9-0bc0-472e-b2df-511be8d99861

push

circleci

web-flow
Merge pull request #5548 from mozilla/force-debug-safer-report-filter-mpp-4189

fix MPP-4189: force RelaySaferExceptionReporterFilter.is_active = True

2468 of 3605 branches covered (68.46%)

Branch coverage included in aggregate %.

2 of 4 new or added lines in 2 files covered. (50.0%)

17321 of 19608 relevant lines covered (88.34%)

9.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/privaterelay/debug.py
1
import re
1✔
2

3
from django.http.request import HttpRequest
1✔
4
from django.views.debug import SafeExceptionReporterFilter
1✔
5

6

7
class RelaySaferExceptionReporterFilter(SafeExceptionReporterFilter):
1✔
8
    """
9
    Hide all settings EXCEPT ones explicitly allowed by SAFE_PREFIXES or SAFE_NAMES.
10
    """
11

12
    # By default, Django disables the filter if DEBUG=True.
13
    # Django correctly assumes "If DEBUG is True then your site is not safe anyway."
14
    # (https://github.com/django/django/blob/1520d18/django/views/debug.py#L175)
15
    # But, we sometimes temporarily set DEBUG=True in our dev environment to help debug.
16
    # And even in that case, we want as much additional safety as we can get.
17
    def is_active(self, request: HttpRequest | None) -> bool:
1✔
NEW
18
        return True
×
19

20
    # Allow variable values that start with these prefixes
21
    SAFE_PREFIXES: list = []
1✔
22

23
    # Allow variable values named in this list
24
    SAFE_NAMES = [
1✔
25
        "BUNDLE_PLAN_ID_US",
26
        "BUNDLE_PROD_ID",
27
        "RELAY_CHANNEL",
28
        "RELAY_CHANNEL_NAME",
29
        "RELAY_FROM_ADDRESS",
30
        "SUBPLAT3_BUNDLE_PRODUCT_KEY",
31
        "SUBPLAT3_PHONES_PRODUCT_KEY",
32
        "SUBPLAT3_PREMIUM_PRODUCT_KEY",
33
    ]
34

35
    # Match everything EXCEPT safe names and safe prefixes
36
    hidden_settings = re.compile(
1✔
37
        r"^(?!("
38
        + "|".join(f"{re.escape(name)}" for name in SAFE_NAMES)
39
        + "|"
40
        + "|".join(f"{re.escape(prefix)}.*" for prefix in SAFE_PREFIXES)
41
        + r")$).+",
42
        re.IGNORECASE,
43
    )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc