Exemple #1
0
def _request_end(resp):
    try:
        jsonbody = request.get_json(force=True, silent=True)
    except HTTPException:
        jsonbody = None

    values = request.values.to_dict()

    if jsonbody and not isinstance(jsonbody, dict):
        jsonbody = {"_parsererror": jsonbody}

    if isinstance(values, dict):
        filter_logs(values, FILTERED_VALUES)

    extra = {
        "endpoint": request.endpoint,
        "request_id": request.request_id,
        "remote_addr": request.remote_addr,
        "http_method": request.method,
        "original_url": request.url,
        "path": request.path,
        "parameters": values,
        "json_body": jsonbody,
        "confsha": CONFIG_DIGEST,
    }

    if request.user_agent is not None:
        extra["user-agent"] = request.user_agent.string

    logger.debug("Ending request: %s (%s)", request.request_id, request.path, extra=extra)
    return resp
Exemple #2
0
def test_filter_logs():
    values = {
        "user": {"password": "******"},
        "blob": "1234567890asdfewkqresfdsfewfdsfd",
        "unfiltered": "foo",
    }
    filter_logs(values, FILTERED_VALUES)
    assert values == {"user": {"password": "******"}, "blob": "12345678", "unfiltered": "foo"}
Exemple #3
0
def test_filter_logs():
    values = {
        'user': {
            'password': "******"
        },
        'blob': '1234567890asdfewkqresfdsfewfdsfd',
        'unfiltered': 'foo'
    }
    filter_logs(values, FILTERED_VALUES)
    assert values == {
        'user': {
            'password': '******'
        },
        'blob': '12345678',
        'unfiltered': "foo"
    }