parameters: ()
return_statement: return response
docstring: Method to handle Capture creation.
  
      The Default Puppyscript provides all the expected parameters
      for this endpoint.
  
      If you need to modify the default captures, provide the following:
  
      Method:   POST
      Data:     assessment(payload.id will work here), url, referrer, cookies, user_agent, payload,
                screenshot, dom
docstring_summary: Method to handle Capture creation.
docstring_tokens: Method to handle Capture creation .
function: def get_callbacks():
      """
      Method to handle Capture creation.
  
      The Default Puppyscript provides all the expected parameters
      for this endpoint.
  
      If you need to modify the default captures, provide the following:
  
      Method:   POST
      Data:     assessment(payload.id will work here), url, referrer, cookies, user_agent, payload,
                screenshot, dom
      """
      response = Response()
  
      app.logger.info("Inside /callbacks")
  
      if request.method == 'POST':
          try:
              app.logger.info("request.form.get('payload', 0): {}".format(
                  request.form.get('payload', 0)))
  
              url = urllib.unquote(unicode(request.form.get('uri', '')))
  
              if app.config.get('ALLOWED_DOMAINS'):
                  domain = urlparse(url).netloc.split(':')[0]
                  if domain not in app.config.get('ALLOWED_DOMAINS'):
                      app.logger.info(
                          "Ignoring Capture from unapproved domain: [{}]".format(domain))
                      return response
  
              referrer = urllib.unquote(
                  unicode(request.form.get('referrer', '')))
              cookies = urllib.unquote(unicode(request.form.get('cookies', '')))
              user_agent = urllib.unquote(
                  unicode(request.form.get('user_agent', '')))
              payload = Payload.query.filter_by(
                  id=int(request.form.get('payload', 0))).first()
              assessment = Assessment.query.filter_by(
                  id=int(request.form.get('assessment', 0))).first()
              screenshot = unicode(request.form.get('screenshot', ''))
              dom = urllib.unquote(unicode(request.form.get('dom', '')))[:65535]
              # If it's a rogue capture, log it anyway.
              if payload is None or assessment is None:
                  client_info = Capture("Not found",
                                        url,
                                        referrer,
                                        cookies,
                                        user_agent,
                                        0,
                                        screenshot,
                                        dom)
              else:
                  # Create the capture with associated assessment/payload
                  client_info = Capture(assessment.name,
                                        url,
                                        referrer,
                                        cookies,
                                        user_agent,
                                        payload.id,
                                        screenshot,
                                        dom)
  
              db.session.add(client_info)
              db.session.commit()
              # Email users subscribed to the Payload's Assessment
              email_subscription(
                  payload.id, assessment, url, client_info, 'capture')
          except Exception as e:
              app.logger.warn(
                  "Exception in /callbacks {}\n\n{}".format(Exception, str(e)))
              import traceback
              traceback.print_exc()
  
      return response
function_tokens: def get_callbacks ( ) : response = Response ( ) app . logger . info ( "Inside /callbacks" ) if request . method == 'POST' : try : app . logger . info ( "request.form.get('payload', 0): {}" . format ( request . form . get ( 'payload' , 0 ) ) ) url = urllib . unquote ( unicode ( request . form . get ( 'uri' , '' ) ) ) if app . config . get ( 'ALLOWED_DOMAINS' ) : domain = urlparse ( url ) . netloc . split ( ':' ) [ 0 ] if domain not in app . config . get ( 'ALLOWED_DOMAINS' ) : app . logger . info ( "Ignoring Capture from unapproved domain: [{}]" . format ( domain ) ) return response referrer = urllib . unquote ( unicode ( request . form . get ( 'referrer' , '' ) ) ) cookies = urllib . unquote ( unicode ( request . form . get ( 'cookies' , '' ) ) ) user_agent = urllib . unquote ( unicode ( request . form . get ( 'user_agent' , '' ) ) ) payload = Payload . query . filter_by ( id = int ( request . form . get ( 'payload' , 0 ) ) ) . first ( ) assessment = Assessment . query . filter_by ( id = int ( request . form . get ( 'assessment' , 0 ) ) ) . first ( ) screenshot = unicode ( request . form . get ( 'screenshot' , '' ) ) dom = urllib . unquote ( unicode ( request . form . get ( 'dom' , '' ) ) ) [ : 65535 ] # If it's a rogue capture, log it anyway. if payload is None or assessment is None : client_info = Capture ( "Not found" , url , referrer , cookies , user_agent , 0 , screenshot , dom ) else : # Create the capture with associated assessment/payload client_info = Capture ( assessment . name , url , referrer , cookies , user_agent , payload . id , screenshot , dom ) db . session . add ( client_info ) db . session . commit ( ) # Email users subscribed to the Payload's Assessment email_subscription ( payload . id , assessment , url , client_info , 'capture' ) except Exception as e : app . logger . warn ( "Exception in /callbacks {}\n\n{}" . format ( Exception , str ( e ) ) ) import traceback traceback . print_exc ( ) return response