From 7f55c7c4851dbeb17f369a857974bc8094fb6d24 Mon Sep 17 00:00:00 2001 From: weidong Date: Fri, 1 Apr 2022 15:34:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=BC=8F=E6=B4=9E?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BF=A1=E6=81=AF=E6=A6=82=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sysom_api/apps/vul/views.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sysom_api/apps/vul/views.py b/sysom_api/apps/vul/views.py index 92c3d2f5..e38f0f1c 100644 --- a/sysom_api/apps/vul/views.py +++ b/sysom_api/apps/vul/views.py @@ -5,6 +5,7 @@ from rest_framework.views import APIView from apscheduler.schedulers.background import BackgroundScheduler from django_apscheduler.jobstores import register_job from tzlocal import get_localzone +from django.utils.timezone import localdate, localtime from lib.response import * from apps.accounts.authentication import Authentication from apps.vul.models import * @@ -171,12 +172,23 @@ class VulSummaryView(APIView): sa_cve_count, sa_high_cve_count, sa_affect_host_count = self.get_vul_info(sa) unfix_vul = get_unfix_cve().exclude(host=None) vul_cve_count, vul_high_cve_count, vul_affect_host_count = self.get_vul_info(unfix_vul) - + try: + latest_scan_time = localtime(SecurityAdvisoryModel.objects.filter(pk=1).first().update_time).strftime( + '%Y-%m-%d %Z %H:%M:%S') + except Exception: + latest_scan_time = "" + cvefix_all = SecurityAdvisoryFixHistoryModel.objects.all().values_list("cve_id") + cvefix_all_count = len(set(cvefix_all)) + cvefix_today = cvefix_all.filter(fixed_at__startswith=localdate().strftime("%Y-%m-%d")) + cvefix_today_count = len(set(cvefix_today)) data = { "fixed_cve": { "affect_host_count": sa_affect_host_count, "cve_count": sa_cve_count, "high_cve_count": sa_high_cve_count, + "cvefix_today_count": cvefix_today_count, + "cvefix_all_count": cvefix_all_count, + "latest_scan_time": latest_scan_time }, "unfixed_cve": { -- Gitee From 0be4fa6edf7552d08dad656ab515beb3942fdae7 Mon Sep 17 00:00:00 2001 From: weidong Date: Fri, 1 Apr 2022 15:58:38 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E9=A1=B9=E8=8E=B7=E5=8F=96=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sysom_api/apps/vul/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysom_api/apps/vul/views.py b/sysom_api/apps/vul/views.py index e38f0f1c..f447a056 100644 --- a/sysom_api/apps/vul/views.py +++ b/sysom_api/apps/vul/views.py @@ -173,7 +173,7 @@ class VulSummaryView(APIView): unfix_vul = get_unfix_cve().exclude(host=None) vul_cve_count, vul_high_cve_count, vul_affect_host_count = self.get_vul_info(unfix_vul) try: - latest_scan_time = localtime(SecurityAdvisoryModel.objects.filter(pk=1).first().update_time).strftime( + latest_scan_time = localtime(SecurityAdvisoryModel.objects.all().first().update_time).strftime( '%Y-%m-%d %Z %H:%M:%S') except Exception: latest_scan_time = "" -- Gitee