Exemple #1
0
def export(request):
    """
    :param request:
    :return:
    """

    if request.method == 'POST':
        scan_id = request.POST.get("scan_id")
        report_type = request.POST.get("type")

        zap_resource = AcunetixResource()
        queryset = acunetix_scan_result_db.objects.filter(scan_id=scan_id)
        dataset = zap_resource.export(queryset)
        if report_type == 'csv':
            response = HttpResponse(dataset.csv, content_type='text/csv')
            response[
                'Content-Disposition'] = 'attachment; filename="%s.csv"' % scan_id
            return response
        if report_type == 'json':
            response = HttpResponse(dataset.json,
                                    content_type='application/json')
            response[
                'Content-Disposition'] = 'attachment; filename="%s.json"' % scan_id
            return response
        if report_type == 'yaml':
            response = HttpResponse(dataset.yaml,
                                    content_type='application/x-yaml')
            response[
                'Content-Disposition'] = 'attachment; filename="%s.yaml"' % scan_id
            return response
Exemple #2
0
def export(request):
    """
    :param request:
    :return:
    """
    username = request.user.username
    if request.method == 'POST':
        scan_id = request.POST.get("scan_id")
        report_type = request.POST.get("type")

        scan_item = str(scan_id)
        value = scan_item.replace(" ", "")
        value_split = value.split(',')

        arcunetix_resource = AcunetixResource()
        queryset = acunetix_scan_result_db.objects.filter(
            username=username, scan_id__in=value_split)
        dataset = arcunetix_resource.export(queryset)
        if report_type == 'csv':
            response = HttpResponse(dataset.csv, content_type='text/csv')
            response[
                'Content-Disposition'] = 'attachment; filename="%s.csv"' % 'arcunetix_results'
            return response
        if report_type == 'json':
            response = HttpResponse(dataset.json,
                                    content_type='application/json')
            response[
                'Content-Disposition'] = 'attachment; filename="%s.json"' % 'arcunetix_results'
            return response
        if report_type == 'yaml':
            response = HttpResponse(dataset.yaml,
                                    content_type='application/x-yaml')
            response[
                'Content-Disposition'] = 'attachment; filename="%s.yaml"' % 'arcunetix_results'
            return response