Skip to content

Conversation

LomaxOnTheRun
Copy link
Contributor

@LomaxOnTheRun LomaxOnTheRun commented May 19, 2023

Reference to #31949.

This PR makes the sensitive_variables and sensitive_post_parameters decorators able to handle both sync and async views.

@LomaxOnTheRun LomaxOnTheRun changed the title Async debug view decorators Refs #31949 -- Made @sensitive_variables and @sensitive_post_parameters work with async functions May 19, 2023
@LomaxOnTheRun LomaxOnTheRun force-pushed the async-debug-view-decorators branch from a482727 to fb529b8 Compare May 19, 2023 15:24
@LomaxOnTheRun LomaxOnTheRun force-pushed the async-debug-view-decorators branch from fb529b8 to 2d262c9 Compare May 19, 2023 15:28
@felixxm
Copy link
Member

felixxm commented May 19, 2023

@LomaxOnTheRun Unfortunately, it's much more complicated, see 23cbed2 which was reverted 7330408, and a new PR from Jon.

@felixxm felixxm closed this May 19, 2023
@bigfootjon
Copy link
Contributor

@LomaxOnTheRun if you can figure out a solution to the problem with my original PR (and my attempt to solve it in the new PR) then I'm all ears!

Basically, write a test case that uses @sensitive_variables on a nested async function and have the nested async function throw. In this case the sensitive variables will not be hidden :/

E.g.:

@sensitive_variables("sauce")
@sensitive_post_parameters("bacon-key", "sausage-key")
async def async_sensitive_function(request):
    # Do not just use plain strings for the variables' values in the code
    # so that the tests don't return false positives when the function's source
    # is displayed in the exception report.
    cooked_eggs = "".join(["s", "c", "r", "a", "m", "b", "l", "e", "d"])  # NOQA
    sauce = "".join(  # NOQA
        ["w", "o", "r", "c", "e", "s", "t", "e", "r", "s", "h", "i", "r", "e"]
    )
    raise Exception


async def async_sensitive_view_nested(request):
    try:
        await async_sensitive_function(request)
    except Exception:
        exc_info = sys.exc_info()
        send_log(request, exc_info)
        return technical_500_response(request, *exc_info)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants