def api_get_scan_results():
    scan_id = request.args.get('scan')

    if not scan_id:
        return {'error': 'scan-not-found'}

    # Check for invalid scan_id numbers
    try:
        scan_id = int(scan_id)

        # <3 :atoll
        if scan_id < 1 or scan_id > 2147483646:  # the first rule of autoincrement club
            raise ValueError
    except ValueError:
        return {'error': 'invalid-scan-id'}

    # Get all the test results for the given scan id
    tests = dict(database.select_test_results(scan_id))

    # For each test, get the test score description and add that in
    for test in tests:
        tests[test]['score_description'] = get_score_description(
            tests[test]['result'])

    return tests
Пример #2
0
def api_get_scan_results():
    scan_id = request.args.get('scan')

    if not scan_id:
        return {'error': 'scan-not-found'}

    # Get all the test results for the given scan id
    tests = dict(database.select_test_results(scan_id))

    # For each test, get the test score description and add that in
    for test in tests:
        tests[test]['score_description'] = get_score_description(tests[test]['result'])

    return tests
Пример #3
0
def api_get_scan_results():
    scan_id = request.args.get('scan')

    if not scan_id:
        return {'error': 'scan-not-found'}

    # Get all the test results for the given scan id
    tests = dict(database.select_test_results(scan_id))

    # For each test, get the test score description and add that in
    for test in tests:
        tests[test]['score_description'] = get_score_description(
            tests[test]['result'])

    return tests
Пример #4
0
def grade(scan_id) -> tuple:
    """
    :param scan_id: the scan_id belonging to the tests to grade
    :return: the overall test score and grade
    """
    from httpobs.database import select_test_results, insert_scan_grade  # avoid import loops

    # Get all the tests
    tests = select_test_results(scan_id)

    # TODO: this needs a ton of fleshing out
    score = 100
    for test in tests:
        score += tests[test]['score_modifier']
    score = max(score, 0)  # can't have scores below 0

    # Insert the test grade -- if it's >100, just use the grade for 100, otherwise round down to the nearest multiple
    # of 5
    insert_scan_grade(scan_id, GRADE_CHART[min(score - score % 5, 100)], score)

    return score, grade
Пример #5
0
def api_get_scan_results():
    scan_id = request.args.get('scan')

    if not scan_id:
        return {'error': 'scan-not-found'}

    # Check for invalid scan_id numbers
    try:
        scan_id = int(scan_id)

        # <3 :atoll
        if scan_id < 1 or scan_id > 2147483646:  # the first rule of autoincrement club
            raise ValueError
    except ValueError:
        return {'error': 'invalid-scan-id'}

    # Get all the test results for the given scan id
    tests = dict(database.select_test_results(scan_id))

    # For each test, get the test score description and add that in
    for test in tests:
        tests[test]['score_description'] = get_score_description(tests[test]['result'])

    return tests