(self, workspace_name)
return send_file(memory_file,
                         attachment_filename=f"Faraday-SR-{workspace_name}.csv",
                         as_attachment=True,
                         cache_timeout=-1)
---
        get:
          tags: ["Vulnerability", "File"]
          description: Get a CSV file with all vulns from a workspace
          responses:
            200:
              description: Ok
        tags: ["Vulnerability", "File"]
        responses:
          200:
            description: Ok
---
        get:
          tags: ["Vulnerability", "File"]
          description: Get a CSV file with all vulns from a workspace
          responses:
            200:
              description: Ok
        tags: ["Vulnerability", "File"]
        responses:
          200:
            description: Ok
--- get : tags : [ Vulnerability File ] description : Get a CSV file with all vulns from a workspace responses : 200 : description : Ok tags : [ Vulnerability File ] responses : 200 : description : Ok
def export_csv(self, workspace_name):
        """
        ---
        get:
          tags: ["Vulnerability", "File"]
          description: Get a CSV file with all vulns from a workspace
          responses:
            200:
              description: Ok
        tags: ["Vulnerability", "File"]
        responses:
          200:
            description: Ok
        """
        confirmed = bool(request.args.get('confirmed'))
        filters = request.args.get('q', '{}')
        custom_fields_columns = []
        for custom_field in db.session.query(CustomFieldsSchema).order_by(CustomFieldsSchema.field_order):
            custom_fields_columns.append(custom_field.field_name)
        if confirmed:
            if 'filters' not in filters:
                filters = {}
                filters['filters'] = []
            filters['filters'].append({
                "name": "confirmed",
                "op": "==",
                "val": "true"
            })
            filters = json.dumps(filters)
        vulns_query, _ = self._filter(filters, workspace_name)
        memory_file = export_vulns_to_csv(vulns_query, custom_fields_columns)
        return send_file(memory_file,
                         attachment_filename=f"Faraday-SR-{workspace_name}.csv",
                         as_attachment=True,
                         cache_timeout=-1)
def export_csv ( self , workspace_name ) : confirmed = bool ( request . args . get ( 'confirmed' ) ) filters = request . args . get ( 'q' , '{}' ) custom_fields_columns = [ ] for custom_field in db . session . query ( CustomFieldsSchema ) . order_by ( CustomFieldsSchema . field_order ) : custom_fields_columns . append ( custom_field . field_name ) if confirmed : if 'filters' not in filters : filters = { } filters [ 'filters' ] = [ ] filters [ 'filters' ] . append ( { "name" : "confirmed" , "op" : "==" , "val" : "true" } ) filters = json . dumps ( filters ) vulns_query , _ = self . _filter ( filters , workspace_name ) memory_file = export_vulns_to_csv ( vulns_query , custom_fields_columns ) return send_file ( memory_file , attachment_filename = f"Faraday-SR-{workspace_name}.csv" , as_attachment = True , cache_timeout = - 1 )