コード例 #1
0
ファイル: updateReport.py プロジェクト: saakai-dev/abpssembly
def handleRequest(environ, start_response):
    setupStderr(environ['wsgi.errors'])

    if environ['REQUEST_METHOD'].upper() != 'POST' or not environ.get('CONTENT_TYPE', '').startswith('application/x-www-form-urlencoded'):
        return showError('Unsupported request method', start_response)

    try:
        request_body_length = int(environ['CONTENT_LENGTH'])
    except:
        return showError('Invalid or missing Content-Length header', start_response)

    request_body = environ['wsgi.input'].read(request_body_length)
    params = {}
    for key, value in parse_qsl(request_body):
        params[key] = value.decode('utf-8')

    guid = params.get('guid', '').lower()
    if not re.match(r'^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$', guid):
        return showError('Invalid or missing report GUID', start_response)

    reportData = getReport(guid)

    if reportData == None:
        return showError('Report does not exist', start_response)

    secret = calculateReportSecret(guid)
    if params.get('secret', '') != secret and params.get('secret', '') != calculateReportSecret_compat(guid):
        return showError('Wrong secret value', start_response)

    reportData['status'] = params.get('status', '')
    if len(reportData['status']) > 1024:
        reportData['status'] = reportData['status'][:1024]

    oldusefulness = reportData.get('usefulness', '0')
    reportData['usefulness'] = params.get('usefulness', '0')
    if 'email' in reportData:
        updateUserUsefulness(getUserId(reportData['email']), reportData['usefulness'], oldusefulness)

    saveReport(guid, reportData)

    if params.get('notify', '') and 'email' in reportData:
        email = reportData['email']
        email = re.sub(r' at ', r'@', email)
        email = re.sub(r' dot ', r'.', email)
        if re.match(r'^[\w.%+-]+@[\w.%+-]+(\.[\w.%+-]+)+', email):
            sendUpdateNotification({
                'email': email,
                'url': get_config().get('reports', 'urlRoot') + guid,
                'status': reportData['status'],
            })

    newURL = get_config().get('reports', 'urlRoot') + guid
    newURL += '?updated=' + str(int(random.uniform(0, 10000)))
    newURL += '#secret=' + secret
    start_response('302 Found', [('Location', newURL.encode('utf-8'))])
    return []
コード例 #2
0
ファイル: updateReport.py プロジェクト: chinnurtb/sitescripts
def handleRequest(environ, start_response):
  setupStderr(environ['wsgi.errors'])

  if environ['REQUEST_METHOD'].upper() != 'POST' or not environ.get('CONTENT_TYPE', '').startswith('application/x-www-form-urlencoded'):
    return showError('Unsupported request method', start_response)

  try:
    request_body_length = int(environ['CONTENT_LENGTH'])
  except:
    return showError('Invalid or missing Content-Length header', start_response)

  request_body = environ['wsgi.input'].read(request_body_length)
  params = {}
  for key, value in parse_qsl(request_body):
    params[key] = value.decode('utf-8')

  guid = params.get('guid', '').lower()
  if not re.match(r'^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$', guid):
    return showError('Invalid or missing report GUID', start_response)

  reportData = getReport(guid)    

  if reportData == None:
    return showError('Report does not exist', start_response)

  secret = calculateReportSecret(guid)
  if params.get('secret', '') != secret and params.get('secret', '') != calculateReportSecret_compat(guid):
    return showError('Wrong secret value', start_response)

  reportData['status'] = params.get('status', '')
  if len(reportData['status']) > 1024:
    reportData['status'] = reportData['status'][:1024]

  oldusefulness = reportData.get('usefulness', '0')
  reportData['usefulness'] = params.get('usefulness', '0')
  if ('email' in reportData):
    updateUserUsefulness(getUserId(reportData['email']), reportData['usefulness'], oldusefulness)

  saveReport(guid, reportData)

  if params.get('notify', '') and 'email' in reportData:
    email = reportData['email']
    email = re.sub(r' at ', r'@', email)
    email = re.sub(r' dot ', r'.', email)
    if re.match(r'^[\w.%+-]+@[\w.%+-]+(\.[\w.%+-]+)+', email):
      sendUpdateNotification({
        'email': email,
        'url': get_config().get('reports', 'urlRoot') + guid,
        'status': reportData['status'],
      })

  newURL = get_config().get('reports', 'urlRoot') + guid
  newURL += '?updated=' + str(int(random.uniform(0, 10000)))
  newURL += '#secret=' + secret
  start_response('302 Found', [('Location', newURL.encode('utf-8'))])
  return []
コード例 #3
0
def handleRequest(environ, start_response):
    setupStderr(environ["wsgi.errors"])

    if environ["REQUEST_METHOD"].upper() != "POST" or not environ.get("CONTENT_TYPE", "").startswith(
        "application/x-www-form-urlencoded"
    ):
        return showError("Unsupported request method", start_response)

    try:
        request_body_length = int(environ["CONTENT_LENGTH"])
    except:
        return showError("Invalid or missing Content-Length header", start_response)

    request_body = environ["wsgi.input"].read(request_body_length)
    params = {}
    for key, value in parse_qsl(request_body):
        params[key] = value.decode("utf-8")

    guid = params.get("guid", "").lower()
    if not re.match(r"^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$", guid):
        return showError("Invalid or missing report GUID", start_response)

    reportData = getReport(guid)

    if reportData == None:
        return showError("Report does not exist", start_response)

    secret = calculateReportSecret(guid)
    if params.get("secret", "") != secret and params.get("secret", "") != calculateReportSecret_compat(guid):
        return showError("Wrong secret value", start_response)

    reportData["status"] = params.get("status", "")
    if len(reportData["status"]) > 1024:
        reportData["status"] = reportData["status"][:1024]

    oldusefulness = reportData.get("usefulness", "0")
    reportData["usefulness"] = params.get("usefulness", "0")
    if "email" in reportData:
        updateUserUsefulness(getUserId(reportData["email"]), reportData["usefulness"], oldusefulness)

    saveReport(guid, reportData)

    if params.get("notify", "") and "email" in reportData:
        email = reportData["email"]
        email = re.sub(r" at ", r"@", email)
        email = re.sub(r" dot ", r".", email)
        if re.match(r"^[\w.%+-]+@[\w.%+-]+(\.[\w.%+-]+)+", email):
            sendUpdateNotification(
                {"email": email, "url": get_config().get("reports", "urlRoot") + guid, "status": reportData["status"]}
            )

    newURL = get_config().get("reports", "urlRoot") + guid
    newURL += "?updated=" + str(int(random.uniform(0, 10000)))
    newURL += "#secret=" + secret
    start_response("302 Found", [("Location", newURL.encode("utf-8"))])
    return []
コード例 #4
0
def handleRequest(environ, start_response, params):
    guid = params.get('guid', '').lower()
    if not re.match(GUID_REGEX, guid):
        return showError('Invalid or missing report GUID', start_response)

    reportData = getReport(guid)

    if reportData is None:
        return showError('Report does not exist', start_response)

    secret = calculateReportSecret(guid)
    if (params.get('secret', '') != secret and
            params.get('secret', '') != calculateReportSecret_compat(guid)):
        return showError('Wrong secret value', start_response)

    reportData['status'] = params.get('status', '')
    if len(reportData['status']) > 1024:
        reportData['status'] = reportData['status'][:1024]

    oldusefulness = reportData.get('usefulness', '0')
    reportData['usefulness'] = params.get('usefulness', '0')

    if 'email' in reportData:
        updateUserUsefulness(getUserId(reportData['email']),
                             reportData['usefulness'], oldusefulness)

    saveReport(guid, reportData)

    if params.get('notify', '') and 'email' in reportData:
        email = reportData['email']
        email = re.sub(r' at ', r'@', email)
        email = re.sub(r' dot ', r'.', email)
        if re.match(r'^[\w.%+-]+@[\w.%+-]+(\.[\w.%+-]+)+', email):
            sendUpdateNotification({
                'email':
                email,
                'url':
                get_config().get('reports', 'urlRoot') + guid,
                'status':
                reportData['status'],
            })

    newURL = get_config().get('reports', 'urlRoot') + guid
    newURL += '?updated=' + str(int(random.uniform(0, 10000)))
    newURL += '#secret=' + secret
    start_response('302 Found', [('Location', newURL.encode('utf-8'))])
    return []
コード例 #5
0
def handleRequest(environ, start_response, params):
    guid = params.get('guid', '').lower()
    if not re.match(GUID_REGEX, guid):
        return showError('Invalid or missing report GUID', start_response)

    reportData = getReport(guid)

    if reportData is None:
        return showError('Report does not exist', start_response)

    secret = calculateReportSecret(guid)
    if (params.get('secret', '') != secret and
       params.get('secret', '') != calculateReportSecret_compat(guid)):
        return showError('Wrong secret value', start_response)

    reportData['status'] = params.get('status', '')
    if len(reportData['status']) > 1024:
        reportData['status'] = reportData['status'][:1024]

    oldusefulness = reportData.get('usefulness', '0')
    reportData['usefulness'] = params.get('usefulness', '0')

    if 'email' in reportData:
        updateUserUsefulness(getUserId(reportData['email']),
                             reportData['usefulness'], oldusefulness)

    saveReport(guid, reportData)

    if params.get('notify', '') and 'email' in reportData:
        email = reportData['email']
        email = re.sub(r' at ', r'@', email)
        email = re.sub(r' dot ', r'.', email)
        if re.match(r'^[\w.%+-]+@[\w.%+-]+(\.[\w.%+-]+)+', email):
            sendUpdateNotification({
                'email': email,
                'url': get_config().get('reports', 'urlRoot') + guid,
                'status': reportData['status'],
            })

    newURL = get_config().get('reports', 'urlRoot') + guid
    newURL += '?updated=' + str(int(random.uniform(0, 10000)))
    newURL += '#secret=' + secret
    start_response('302 Found', [('Location', newURL.encode('utf-8'))])
    return []
コード例 #6
0
ファイル: processReports.py プロジェクト: kzar/sitescripts
def processReports():
    for report in getReports():
        guid = report.get('guid', None)
        reportData = getReport(guid)
        if 'screenshot' in reportData:
            saveReport(guid, reportData)
コード例 #7
0
def processReports():
    for report in getReports():
        guid = report.get('guid', None)
        reportData = getReport(guid)
        if 'screenshot' in reportData:
            saveReport(guid, reportData)