コード例 #1
0
def do_cgi():
    try:
        elec = election.Election()
        evlog.AppLog().set_app(APP)

        # Create a list of pairs from the form parameters. Don't use a dictionary
        # because that will overwrite recurring keys.
        form = cgi.FieldStorage()
        params = []
        for key in form:
            for value in form.getlist(key):
                params.append((key, value))

        # Only accept up to a single parameter
        if len(params) > 1:

            def keys(pairs):
                """Return a comma-separated list of the keys."""
                return ", ".join([pair[0] for pair in pairs])

            evlog.log_error("Too many query parameters: " + keys(params))
            bad_parameters()
            return

        # Only accept the POST_VERIFY_VOTE parameter.
        if len(params) and params[0][0] != evcommon.POST_VERIFY_VOTE:
            evlog.log_error('Unknown query parameter "%s"' % params[0][0])
            bad_parameters()
            return

        # Make sure the parameter is correctly formatted.
        if not formatutil.is_vote_verification_id(params[0][1]):
            # Don't write to disk; we don't know how large the value is
            evlog.log_error("Malformed vote ID")
            bad_parameters()
            return

        evlog.log("verif/auth REMOTE_ADDR: " + evlogdata.get_remote_ip())
        evlog.log("verif/auth VOTE-ID: " + params[0][1])

        params.append((evcommon.POST_SESS_ID, sessionid.voting()))

        url = "http://" + elec.get_hts_ip() + "/" + elec.get_hts_verify_path()
        conn = urllib.urlopen(url, urllib.urlencode(params))
        protocol.http_response(conn.read())
    except:
        evlog.log_exception()
        technical_error()
コード例 #2
0
ファイル: cgilog.py プロジェクト: 100dBsound/evalimine
def get_loglines(prefix):
    to_alog = []
    to_elog = []

    to_alog.append(prefix + " REMOTE_ADDR: " + evlogdata.get_remote_ip())
    to_alog.append(prefix + " HTTP_USER_AGENT: " + evlogdata.get_user_agent())

    if evcommon.HTTP_CERT in os.environ:
        cert = os.environ[evcommon.HTTP_CERT]
        if len(cert) > 0:
            alog, elog = evlogdata.get_cert_data_log(cert, prefix)
            to_alog.append(alog)
            if elog:
                to_elog.append(elog)

    return to_alog, to_elog
コード例 #3
0
def get_loglines(prefix):
    to_alog = []
    to_elog = []

    to_alog.append(prefix + " REMOTE_ADDR: " + evlogdata.get_remote_ip())
    to_alog.append(prefix + " HTTP_USER_AGENT: " + evlogdata.get_user_agent())

    if evcommon.HTTP_CERT in os.environ:
        cert = os.environ[evcommon.HTTP_CERT]
        if len(cert) > 0:
            alog, elog = evlogdata.get_cert_data_log(cert, prefix)
            to_alog.append(alog)
            if elog:
                to_elog.append(elog)

    return to_alog, to_elog
コード例 #4
0
def do_cgi():
    try:
        elec = election.Election()
        evlog.AppLog().set_app(APP)

        # Create a list of pairs from the form parameters. Don't use a dictionary
        # because that will overwrite recurring keys.
        form = cgi.FieldStorage()
        params = []
        for key in form:
            for value in form.getlist(key):
                params.append((key, value))

        # Only accept up to a single parameter
        if len(params) > 1:
            def keys(pairs):
                """Return a comma-separated list of the keys."""
                return ", ".join([pair[0] for pair in pairs])

            evlog.log_error("Too many query parameters: " + keys(params))
            bad_parameters()
            return

        # Only accept the POST_VERIFY_VOTE parameter.
        if len(params) and params[0][0] != evcommon.POST_VERIFY_VOTE:
            evlog.log_error("Unknown query parameter \"%s\"" % params[0][0])
            bad_parameters()
            return

        # Make sure the parameter is correctly formatted.
        if not formatutil.is_vote_verification_id(params[0][1]):
            # Don't write to disk; we don't know how large the value is
            evlog.log_error("Malformed vote ID")
            bad_parameters()
            return

        evlog.log("verif/auth REMOTE_ADDR: " + evlogdata.get_remote_ip())
        evlog.log("verif/auth VOTE-ID: " + params[0][1])

        params.append((evcommon.POST_SESS_ID, sessionid.voting()))

        url = "http://" + elec.get_hts_ip() + "/" + elec.get_hts_verify_path()
        conn = urllib.urlopen(url, urllib.urlencode(params))
        protocol.http_response(conn.read())
    except:
        evlog.log_exception()
        technical_error()
コード例 #5
0
        def keys(pairs):
            """Return a comma-separated list of the keys."""
            return ", ".join([pair[0] for pair in pairs])

        evlog.log_error("Too many query parameters: " + keys(params))
        bad_parameters()

    # Only accept the POST_VERIFY_VOTE parameter.
    if len(params) and params[0][0] != evcommon.POST_VERIFY_VOTE:
        evlog.log_error('Unknown query parameter "%s"' % params[0][0])
        bad_parameters()

    # Make sure the parameter is correctly formatted.
    if not formatutil.is_vote_verification_id(params[0][1]):
        # Don't write to disk; we don't know how large the value is
        evlog.log_error("Malformed vote ID")
        bad_parameters()

    evlog.log("verif/auth REMOTE_ADDR: " + evlogdata.get_remote_ip())
    evlog.log("verif/auth VOTE-ID: " + params[0][1])

    params.append((evcommon.POST_SESS_ID, sessionid.voting()))

    url = "http://" + elec.get_hts_ip() + "/" + elec.get_hts_verify_path()
    conn = urllib.urlopen(url, urllib.urlencode(params))
    protocol.http_response(conn.read())
    cgi.sys.exit(0)

# vim:set ts=4 sw=4 et fileencoding=utf8: