def stop_scan_api(request, scan_id): scan = get_object_or_404(Scan, id=scan_id) scan.status = "stopping" scan.save() stopscan_task.apply_async(args=[scan.id], queue='scan-' + str(scan.engine_type).lower(), routing_key='scan.' + str(scan.engine_type).lower(), retry=False) return JsonResponse({'status': 'success'}, json_dumps_params={'indent': 2})
def stop_scan_api(request, scan_id): """Stop a scan.""" scan = get_object_or_404(Scan.objects.for_user(request.user), id=scan_id) scan.status = "stopping" scan.save() stopscan_task.apply_async(args=[scan.id], queue='scan', retry=True, ignore_result=False) # args=[scan.id], queue='scan', retry=False, ignore_result=True) return JsonResponse({'status': 'success'})
def stop_scan_api(request, scan_id): """Stop a scan.""" scan = get_object_or_404(Scan.objects.for_user(request.user), id=scan_id) scan.status = "stopping" scan.save() stopscan_task.apply_async( args=[scan.id], queue='scan', retry=True, ignore_result=False) # args=[scan.id], queue='scan', retry=False, ignore_result=True) AuditLog.objects.create( message="Scan '{}' stopped".format(scan), scope='engine', type='scan_stop', owner=request.user, context=request) return JsonResponse({'status': 'success'})
def stop_scans_api(request): """Stop selected scans.""" scans = request.data for scan_id in scans: try: scan = Scan.objects.for_user(request.user).get(id=scan_id) except Scan.DoesNotExist: continue scan.status = "stopping" scan.save() stopscan_task.apply_async(args=[scan.id], queue='scan', retry=True, ignore_result=True) return JsonResponse({'status': 'success'})
def stop_scans_api(request): """Stop selected scans.""" scans = request.data for scan_id in scans: try: scan = Scan.objects.get(id=scan_id) except Scan.DoesNotExist: continue scan.status = "stopping" scan.save() stopscan_task.apply_async( args=[scan.id], queue='scan-'+str(scan.engine_type).lower(), routing_key='scan.'+str(scan.engine_type).lower(), retry=False ) return JsonResponse({'status': 'success'}, json_dumps_params={'indent': 2})
def delete_scan_api(request, scan_id): """Delete selected scan.""" scan = get_object_or_404(Scan.objects.for_user(request.user), id=scan_id) if scan.status not in ['finished', 'error']: res = stopscan_task.apply_async(args=[scan.id], queue='scanmgt', retry=True, ignore_result=False) res.get() scan.delete() return JsonResponse({'status': 'success'})
def stop_scans_api(request): """Stop selected scans.""" scans = request.data for scan_id in scans: try: scan = Scan.objects.for_user(request.user).get(id=scan_id) except Scan.DoesNotExist: continue scan.status = "stopping" scan.save() stopscan_task.apply_async( args=[scan.id], queue='scan', retry=True, ignore_result=True ) AuditLog.objects.create( message="Scan '{}' stopped".format(scan), scope='engine', type='scan_stop', owner=request.user, context=request) return JsonResponse({'status': 'success'})
def delete_scans_api(request): """Delete selected scans.""" scans = request.data for scan_id in scans: try: scan = Scan.objects.for_user(request.user).get(id=scan_id) except Scan.DoesNotExist: continue # Stop scans if possible if scan.status not in ['finished', 'error']: res = stopscan_task.apply_async(args=[scan.id], queue='scanmgt', retry=True, ignore_result=False) res.get() Scan.objects.for_user(request.user).get(id=scan_id).delete() return JsonResponse({'status': 'success'})