Beispiel #1
0
def validation_result(validated):
    if bool(validated['invalid']):
        # if the profile is invalid
        return [False, decode_to_string(validated['invalid'])]
    elif bool(validated['custom']):
        # if the profile has custom permissions
        message = get_message(
            validated, 'valid', 'Your user\'s role set ',
            ' seem to be ok, but we couldn\'t do an exhaustive check.')
        return [2, message]
    # if everything seems to be ok
    return [True, decode_to_string(validated['valid'])]
Beispiel #2
0
def validation_result(validated):
    if bool(validated['invalid']):
        # if the profile is invalid
        return TestResult(success=False,
                          message=decode_to_string(validated['invalid']))
    elif bool(validated['custom']):
        # if the profile has custom permissions
        message = get_message(
            validated, 'valid', 'Your user\'s role set ',
            ' seems to be ok, but we couldn\'t do an exhaustive check.')
        return TestResult(success=True, severity=WARNING, message=message)
    # if everything seems to be ok
    return TestResult(success=True,
                      message=decode_to_string(validated['valid']))
Beispiel #3
0
def try_dedicated_user(test):
    """
    Verify that the role only applies to one database
    """
    roles = test.tester.get_roles()
    user_role_dbs = set()
    for role in roles['roles']:
        user_role_dbs.add(role['db'])

    return [bool(len(user_role_dbs)), decode_to_string(user_role_dbs)]
Beispiel #4
0
def get_message(validated, state, text1, text2):
    return text1 + decode_to_string(validated[state]) + text2