diff --git a/gerobug_dashboard/dashboards/forms.py b/gerobug_dashboard/dashboards/forms.py index 9acfa84..fcd5616 100644 --- a/gerobug_dashboard/dashboards/forms.py +++ b/gerobug_dashboard/dashboards/forms.py @@ -11,6 +11,9 @@ class Requestform(forms.Form): class CompleteRequestform(forms.Form): completereasons = forms.CharField(widget=forms.Textarea(attrs={"id":"completereasons","name":"completereasons","placeholder":"Write the reason here ..."}),required=True) +class Invalidform(forms.Form): + invalidreasons = forms.CharField(widget=forms.Textarea(attrs={"id":"invalidreasons","name":"invalidreasons","placeholder":"Write the reason here ..."}),required=True) + class RulesGuidelineForm(forms.ModelForm): class Meta: model = StaticRules diff --git a/gerobug_dashboard/dashboards/urls.py b/gerobug_dashboard/dashboards/urls.py index da9ca65..5551c81 100644 --- a/gerobug_dashboard/dashboards/urls.py +++ b/gerobug_dashboard/dashboards/urls.py @@ -1,5 +1,5 @@ from django.urls import path -from .views import LogoutForm, ReportFiles, ReportStatusView, ReportUpdateStatus, FormHandler, AdminSetting, OWASPCalculator, CVSSCalculator, ManageRoles, ReviewerDelete, NotificationDelete, RenderDashboardAdmin, ReportDetails, UpdateDetails, AppealDetails, NDADetails, ReportUpdate, ReportDelete +from .views import LogoutForm, ReportFiles, ReportStatusView, ReportUpdateStatus, FormHandler, InvalidHandler, AdminSetting, OWASPCalculator, CVSSCalculator, ManageRoles, ReviewerDelete, NotificationDelete, RenderDashboardAdmin, ReportDetails, UpdateDetails, AppealDetails, NDADetails, ReportUpdate, ReportDelete urlpatterns = [ path("", RenderDashboardAdmin.as_view(), name="dashboard"), @@ -17,6 +17,7 @@ path("report-files/", ReportFiles, name="report_files"), path("form-handling//", FormHandler, name="form_handler"), + path("invalid-handling/", InvalidHandler, name="invalid_handler"), path("review-delete/", ReviewerDelete,name="reviewer_handler"), path("notification-delete/", NotificationDelete,name="notification_handler"), diff --git a/gerobug_dashboard/dashboards/views.py b/gerobug_dashboard/dashboards/views.py index 82af3c8..71b07dc 100644 --- a/gerobug_dashboard/dashboards/views.py +++ b/gerobug_dashboard/dashboards/views.py @@ -18,7 +18,7 @@ from django.middleware.csrf import get_token from prerequisites.models import MailBox, Webhook from .models import BugHunter, BugReport, BugReportUpdate, BugReportAppeal, BugReportNDA, ReportStatus, StaticRules, BlacklistRule, CertificateData, Personalization -from .forms import Requestform, RulesGuidelineForm, CompleteRequestform, MailboxForm, AccountForm, ReviewerForm, WebhookForm, BlacklistForm, TemplateReportForm, TemplateNDAForm, TemplateCertForm, CertDataForm, PersonalizationForm, CompanyIdentityForm +from .forms import Requestform, RulesGuidelineForm, CompleteRequestform, MailboxForm, AccountForm, ReviewerForm, WebhookForm, BlacklistForm, TemplateReportForm, TemplateNDAForm, TemplateCertForm, CertDataForm, PersonalizationForm, CompanyIdentityForm, Invalidform from sys import platform from geromail import geromailer, gerofilter, geroparser, gerocalculator from gerobug.settings import MEDIA_ROOT, BASE_DIR @@ -68,6 +68,7 @@ def get_context_data(self, **kwargs): context = super(ReportDetails, self).get_context_data(**kwargs) context['reportstatus'] = ReportStatus.objects.filter(status_id=BugReport.objects.get(report_id=self.kwargs.get('pk')).report_status)[0].status_name context['requestform'] = Requestform() + context['invalidform'] = Invalidform() context['completeform'] = CompleteRequestform() return context @@ -214,23 +215,7 @@ def FormHandler(request, id, complete): if form.is_valid(): reasons = form.cleaned_data.get('reasons') code = 0 - if status == "Need to Review" and complete == "0": - # MARK AS INVALID - report.report_status = 0 - report.save() - - logging.getLogger("Gerologger").info("REPORT "+str(id)+" STATUS UPDATED (INVALID) BY "+str(request.user.username)) - - def trigger_geromailer(report): - payload = [report.report_id, report.report_title, report.report_status, reasons, report.report_severity] - destination = report.hunter_email - geromailer.notify(destination, payload) # TRIGGER GEROMAILER TO SEND UPDATE NOTIFICATION - - # SEND NOTIFICATION AND REASON WITH THREADING - trigger = threading.Thread(target=trigger_geromailer, args=(report,)) - trigger.start() - - elif (status == "In Review" or status == "Fixing" or status == "Fixing (Retest)") and complete == "0": + if (status == "In Review" or status == "Fixing" or status == "Fixing (Retest)") and complete == "0": code = 701 #REQUEST AMEND logging.getLogger("Gerologger").info("REPORT "+str(id)+" REQUESTED AMEND BY "+str(request.user.username)) @@ -256,12 +241,55 @@ def trigger_company_action(report): trigger.start() return redirect('dashboard') + else: + messages.error(request,"Form invalid. Please report to the Admin for checking the logs.") + logging.getLogger("Gerologger").error("Form invalid: "+str(request)) + + return redirect('dashboard') + + else: + messages.error(request,"Something's wrong with form handler. Please report to the Admin for checking the logs.") + logging.getLogger("Gerologger").error("Something's wrong with form handler: "+str(request)) + return redirect('dashboard') + + +@login_required +def InvalidHandler(request, id): + if gerofilter.validate_id(id): + report = BugReport.objects.get(report_id=id) + status = ReportStatus.objects.get(status_id=report.report_status) + status = status.status_name + + if request.method == "POST": + form = Invalidform(request.POST) + if form.is_valid(): + reasons = form.cleaned_data.get('reasons') + + # MARK AS INVALID + report.report_status = 0 + report.save() + + logging.getLogger("Gerologger").info("REPORT "+str(id)+" MARKED AS INVALID BY "+str(request.user.username)) + + def trigger_geromailer(report): + payload = [report.report_id, report.report_title, report.report_status, reasons, report.report_severity] + destination = report.hunter_email + geromailer.notify(destination, payload) # TRIGGER GEROMAILER TO SEND UPDATE NOTIFICATION + + # SEND NOTIFICATION AND REASON WITH THREADING + trigger = threading.Thread(target=trigger_geromailer, args=(report,)) + trigger.start() + + messages.success(request,"Email is successfully being processed and sent to the bug hunter with your reason.") + else: + messages.error(request,"Form invalid. Please report to the Admin for checking the logs.") + logging.getLogger("Gerologger").error("Form invalid: "+str(request)) return redirect('dashboard') else: - messages.error(request,"Something's wrong. Please report to the Admin for checking the logs.") - logging.getLogger("Gerologger").error(str(request)) + messages.error(request,"Something's wrong with invalid handler. Please report to the Admin for checking the logs.") + logging.getLogger("Gerologger").error("Something's wrong with invalid handler: "+str(request)) return redirect('dashboard') diff --git a/gerobug_dashboard/geromail/gerofilter.py b/gerobug_dashboard/geromail/gerofilter.py index e1e5e64..99ee71b 100644 --- a/gerobug_dashboard/geromail/gerofilter.py +++ b/gerobug_dashboard/geromail/gerofilter.py @@ -159,14 +159,14 @@ def parse_body(body): summary = '' try: - type = re.search('(TYPE=|TYPE =|TYPE)((.|\n)*)(ENDPOINT=|ENDPOINT =|ENDPOINT)', body) + type = re.search('(TYPE=|TYPE =|TYPE)((.|\n)*)(ENDPOINT=|ENDPOINT =|ENDPOINT)', body.replace('*', '')) if type != None: type = type.group(2) type = str(type.replace("\n","")) else: type = '' - endpoint = re.search('(ENDPOINT=|ENDPOINT =|ENDPOINT)((.|\n)*)(SUMMARY=|SUMMARY =|SUMMARY)', body) + endpoint = re.search('(ENDPOINT=|ENDPOINT =|ENDPOINT)((.|\n)*)(SUMMARY=|SUMMARY =|SUMMARY)', body.replace('*', '')) if endpoint != None: endpoint = endpoint.group(2) endpoint = re.sub(r"<.*>", "", str(endpoint)) @@ -174,7 +174,7 @@ def parse_body(body): else: endpoint = '' - summary = re.search('(SUMMARY=|SUMMARY =|SUMMARY)(.*)', body.replace('\n', ' ')) + summary = re.search('(SUMMARY=|SUMMARY =|SUMMARY)(.*)', body.replace('\n', ' ').replace('*', '')) if summary != None: summary = summary.group(2) else: diff --git a/gerobug_dashboard/static/css/reportDetail.css b/gerobug_dashboard/static/css/reportDetail.css index 44d0038..db5b6b3 100644 --- a/gerobug_dashboard/static/css/reportDetail.css +++ b/gerobug_dashboard/static/css/reportDetail.css @@ -318,6 +318,18 @@ label { padding-right: 10px; } +.delete-btn{ + background-color: red; + border-width: 0; + color: #f9f3f3; + border-radius: 20px; + margin: 28px; + height: 42px; + min-width: 150px; + padding-left: 10px; + padding-right: 10px; +} + .update-btn{ background-color: var(--button-1); border-width: 0; diff --git a/gerobug_dashboard/templates/dashboard_varieties/detail_report.html b/gerobug_dashboard/templates/dashboard_varieties/detail_report.html index dc8c87f..9fd5b33 100644 --- a/gerobug_dashboard/templates/dashboard_varieties/detail_report.html +++ b/gerobug_dashboard/templates/dashboard_varieties/detail_report.html @@ -43,6 +43,28 @@ +