Ejemplo n.º 1
0
from exercises.registry import register_grader


def validate(metadata, input_pass):
    '''
    Check if password in metadata and user input match.
    '''
    return True if metadata['password'] == input_pass else False


register_grader('1.1', validate)
register_grader('1.2', validate)
register_grader('1.3', validate)
Ejemplo n.º 2
0
from exercises.registry import register_grader

def validate(metadata, input_pass):
    """
    Check if private-key in metadata matches the user input
    """
    return metadata['private-key'] == input_pass

register_grader('14.0', validate)
Ejemplo n.º 3
0
from exercises.registry import register_grader

def validate(metadata, input_pass):
    '''
    Check if password in metadata and user input match.
    '''
    return metadata['password'] == input_pass

register_grader('1.1', validate)
register_grader('1.2', validate)
register_grader('1.3', validate)
Ejemplo n.º 4
0
import re
import requests
from exercises.registry import register_grader

def validate(metadata, onion_url):
    for prefix in ['http://', 'https://']:
        if onion_url.startswith(prefix):
            onion_url = onion_url[len(prefix):]
            break

    pattern = re.compile("^[A-Za-z0-9]+\.onion$")
    if not pattern.search(onion_url):
        return False
    try:
        r = requests.get('https://' + onion_url + '.to', timeout=3)
        if r.status_code != 200:
            return False
    except requests.exceptions.Timeout:
        return False

    return metadata['user_email'] in r.text

register_grader('20.0', validate)
Ejemplo n.º 5
0
    result = gpg.search_keys(verified.key_id, 'pgp.mit.edu')
    return len(result) > 0


# Assumes lookupMIT works, otherwise I can't fetch the pub key
def importKeyFromData(signed_data):
    verified = gpg.verify(signed_data)
    result = gpg.recv_keys(verified.key_id, 'pgp.mit.edu')
    return


def validate(metadata, signed_data):
    #importKeyFromData(signed_data)
    verified = gpg.verify(signed_data)

    # Check is msg was signed. If not, there's no need to continue!
    if not verified.key_id:
        return False

    lookedup = lookupMIT(verified)
    hasEmail = hasStudentEmail(verified, metadata['user_email'])
    oneSignature = hasAtLeastOneSignature(verified)
    hasExpiration = hasExpirationDate(verified)
    has4096 = has4096Length(verified)

    #print_info(verified)
    return verified and lookedup and hasEmail and oneSignature and hasExpiration and has4096


register_grader('20.1', validate)
Ejemplo n.º 6
0
from exercises.registry import register_grader


def validate(metadata, input_pass):
    """
    Check if private-key in metadata matches the user input
    """
    return True if metadata['private-key'] == input_pass else False


register_grader('14.0', validate)