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

mozilla / fx-private-relay / d3128616-238d-446e-82c5-ab66cd38ceaf

09 May 2024 06:22PM CUT coverage: 84.07% (-0.6%) from 84.64%
d3128616-238d-446e-82c5-ab66cd38ceaf

push

circleci

web-flow
Merge pull request #4684 from mozilla/enable-flak8-bandit-checks-mpp-3802

fix MPP-3802: stop ignoring bandit security checks

3601 of 4734 branches covered (76.07%)

Branch coverage included in aggregate %.

74 of 158 new or added lines in 24 files covered. (46.84%)

5 existing lines in 5 files now uncovered.

14686 of 17018 relevant lines covered (86.3%)

10.86 hits per line

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

81.82
/api/views/__init__.py
1
"""Shared API views code"""
2

3
from typing import Any
1✔
4

5
from rest_framework.response import Response
1✔
6
from rest_framework.views import exception_handler
1✔
7

8
from ..exceptions import RelayAPIException
1✔
9

10

11
class SaveToRequestUser:
1✔
12
    """ModelViewSet mixin for creating object for the authenticated user."""
13

14
    def perform_create(self, serializer):
1✔
15
        if not hasattr(self, "request"):
1!
NEW
16
            raise AttributeError("self must have request attribute.")
×
17
        if not hasattr(self.request, "user"):
1!
NEW
18
            raise AttributeError("self.request must have user attribute.")
×
19
        serializer.save(user=self.request.user)
1✔
20

21

22
def relay_exception_handler(exc: Exception, context: dict[str, Any]) -> Response | None:
1✔
23
    """
24
    Add error information to response data.
25

26
    When the error is a RelayAPIException, fields may be changed or added:
27

28
    detail - Translated to the best match from the request's Accept-Language header.
29
    error_code - A string identifying the error, for client-side translation.
30
    error_context - Additional data needed for client-side translation, if non-empty
31
    """
32
    response = exception_handler(exc, context)
1✔
33
    if response and isinstance(exc, RelayAPIException):
1✔
34
        response.data.update(exc.error_data())
1✔
35
    return response
1✔
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