From 6feaa856fcbcfe65d8f3c773c878f0ce99f70ef5 Mon Sep 17 00:00:00 2001 From: Yogesh Ojha Date: Sat, 21 Nov 2020 13:46:30 +0530 Subject: [PATCH] Currently scanning added --- dashboard/templates/dashboard/index.html | 66 ++++++-- dashboard/views.py | 23 +-- startScan/templates/startScan/history.html | 174 ++++++++++----------- 3 files changed, 152 insertions(+), 111 deletions(-) diff --git a/dashboard/templates/dashboard/index.html b/dashboard/templates/dashboard/index.html index cbf96540..e3c9053c 100644 --- a/dashboard/templates/dashboard/index.html +++ b/dashboard/templates/dashboard/index.html @@ -197,11 +197,10 @@ Dashboard {% endif %}
- -
+
-
Recent Scans
+
Recently completed Scans
@@ -215,7 +214,7 @@ Dashboard
{% endif %} - {% for item in recent_scans %} + {% for item in recent_completed_scans %}
-
+ +
Upcoming Scans
- {% if upcoming_scans.count == 0 %} - - {% endif %} - - {% for item in upcoming_scans %} + {% for item in pending_scans %} + {% empty %} + {% endfor %} -
diff --git a/dashboard/views.py b/dashboard/views.py index 1a1ea728..e835acdd 100644 --- a/dashboard/views.py +++ b/dashboard/views.py @@ -9,7 +9,7 @@ from django.contrib.auth.signals import user_logged_out, user_logged_in from django.contrib import messages from django.contrib.auth import update_session_auth_hash from django.contrib.auth.forms import PasswordChangeForm -from django.db.models import Count, Value, CharField +from django.db.models import Count, Value, CharField, Q def index(request): @@ -23,25 +23,25 @@ def index(request): WayBackEndPoint.objects.filter(http_status__exact=200).count() on_going_scan_count = \ ScanHistory.objects.filter(scan_status=1).count() - recent_scans = ScanHistory.objects.all().order_by( - '-last_scan_date').exclude(scan_status=-1)[:4] - upcoming_scans = ScanHistory.objects.filter(scan_status=-1)[:4] + recent_completed_scans = ScanHistory.objects.all().order_by( + '-last_scan_date').filter(Q(scan_status=0) | Q(scan_status=2) | Q(scan_status=3))[:4] + currently_scanning = ScanHistory.objects.filter(scan_status=1)[:4] + pending_scans = ScanHistory.objects.filter(scan_status=-1)[:4] info_count = VulnerabilityScan.objects.filter(severity=0).count() low_count = VulnerabilityScan.objects.filter(severity=1).count() medium_count = VulnerabilityScan.objects.filter(severity=2).count() high_count = VulnerabilityScan.objects.filter(severity=3).count() critical_count = VulnerabilityScan.objects.filter(severity=4).count() - total_vul_count = info_count + low_count + medium_count + high_count + critical_count + total_vul_count = info_count + low_count + \ + medium_count + high_count + critical_count # most_vulnerable_target = Domain.objects.exclude( # scanhistory__scannedhost__vulnerabilityscan__severity=0).annotate( # num_vul=Count( # 'scanhistory__scannedhost__vulnerabilityscan__name', # distinct=True)).order_by('-num_vul')[ # :5] - most_vulnerable_target = Domain.objects.annotate( - num_vul=Count( - 'scanhistory__scannedhost__vulnerabilityscan__name')).order_by('-num_vul')[ - :7] + most_vulnerable_target = Domain.objects.annotate(num_vul=Count( + 'scanhistory__scannedhost__vulnerabilityscan__name')).order_by('-num_vul')[:7] most_common_vulnerability = VulnerabilityScan.objects.values("name", "severity").exclude( severity=0).annotate(count=Count('name')).order_by("-count")[:7] context = { @@ -53,8 +53,9 @@ def index(request): 'alive_count': alive_count, 'endpoint_alive_count': endpoint_alive_count, 'on_going_scan_count': on_going_scan_count, - 'recent_scans': recent_scans, - 'upcoming_scans': upcoming_scans, + 'recent_completed_scans': recent_completed_scans, + 'pending_scans': pending_scans, + 'currently_scanning': currently_scanning, 'info_count': info_count, 'low_count': low_count, 'medium_count': medium_count, diff --git a/startScan/templates/startScan/history.html b/startScan/templates/startScan/history.html index 98e39df9..44d680c7 100644 --- a/startScan/templates/startScan/history.html +++ b/startScan/templates/startScan/history.html @@ -23,77 +23,77 @@ Scan History {% block main_content %}
-
-
-
-
-
-

Scan History

-
-
-
-
-
- - - - - - - - - - - - - - {% for scan_history in scan_history.all %} - - - - - - - - + + {% endfor %} + +
SerialDomain NameScan TypeLast Scanned OnStatusResultAction
{{ scan_history.id }} {{ scan_history.domain_name }}{{ scan_history.scan_type }}{{ scan_history.last_scan_date }} - {% if scan_history.scan_status == -1 %} - {% include 'base/_items/progress_spin.html' %}Pending - {% elif scan_history.scan_status == 0 %} - Failed - {% elif scan_history.scan_status == 1 %} - {% include 'base/_items/progress_spin.html' %}Scanning - {% elif scan_history.scan_status == 2 %} - Succesful - {% elif scan_history.scan_status == 3 %} - Aborted - {% else %} - Unknown - {% endif %} - - View - - {% if scan_history.scan_status == 1 or scan_history.scan_status == -1%} - - - - {% endif %} - - - - - - - +
+
+
+
+
+

Scan History

+
+
+
+
+
+ + + + + + + + + + + + + + {% for scan_history in scan_history.all %} + + + + + + + + - - {% endfor %} - -
SerialDomain NameScan TypeLast Scanned OnStatusResultAction
{{ scan_history.id }} {{ scan_history.domain_name }}{{ scan_history.scan_type }}{{ scan_history.last_scan_date }} + {% if scan_history.scan_status == -1 %} + {% include 'base/_items/progress_spin.html' %}Pending + {% elif scan_history.scan_status == 0 %} + Failed + {% elif scan_history.scan_status == 1 %} + {% include 'base/_items/progress_spin.html' %}Scanning + {% elif scan_history.scan_status == 2 %} + Succesful + {% elif scan_history.scan_status == 3 %} + Aborted + {% else %} + Unknown + {% endif %} + + View + + {% if scan_history.scan_status == 1 or scan_history.scan_status == -1%} + + + + {% endif %} + + + + + + + -
-
-
-
-
+
+
+
+
+
{% endblock main_content %} @@ -107,23 +107,23 @@ Scan History