def view_traffic_analysis(request, subscriber): res, show_time, start_date, end_date = get_base_results_for_traffic_analysis(request, subscriber) res['traffic_analysis_result'] = get_n_displayble_traffic_details( res['traffic_analysis'], n=10, show_time=show_time, timezone=subscriber.timezone, start_date=start_date, end_date=end_date) dates_with_data = set() for values in RulesSummary.objects.filter(sid=subscriber, dt__range=[start_date, end_date]).values_list('dt', flat=True): dates_with_data.add(values) dates_with_data = [datetime.datetime.strptime(values, '%Y-%m-%d').strftime('%b %d') for values in dates_with_data] dates_in_given_range = [dt.strftime('%b %d') for dt in list(rrule.rrule(rrule.DAILY, dtstart=start_date, until=end_date))] missing_data_date_range = ta_service.get_missing_data_in_given_date_range(dates_in_given_range, dates_with_data) is_data_missing = True if len(missing_data_date_range) else False can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber,request.user) is_demo_user = is_demo_user_account(request.user) return render(request, 'dashboard.html', {'res' : res, 'can_edit' : can_edit, 'is_monitor' : is_monitor, 'is_demo_user' : is_demo_user, 'show_time' : show_time, 'is_data_missing' : is_data_missing})
def list_user_access_status(request, subscriber): # @UndefinedVariable page_no = request.GET.get('page', 1) form = UserAccessStatusSearchForm(request.GET) search_user_id = None if form.is_valid(): search_user_id = form.cleaned_data['user_id'] # Call service layer to persist paginator = Paginator( page_authorization.get_user_access_status_list(subscriber, search_user_id), 15) user_access_status_list = None try: user_access_status_list = paginator.page(page_no) except PageNotAnInteger: user_access_status_list = paginator.page(page_no) except EmptyPage: user_access_status_list = paginator.page(paginator.num_pages) user_access_status_table = [] # List of dicts for HTML rendering for user_access_status in user_access_status_list: try: user_access_status_table.append({ 'id': user_access_status.pk, 'user_id': user_access_status.user_id, 'date_added': user_access_status.change_dt.strftime('%b %d, %Y') }) except ObjectDoesNotExist: print user_access_status.pk # Is search requested -> to display the search boxes if no results found in the search search = False if any([search_user_id]): search = True can_edit = any(is_admin(request.user)) is_demo_user = is_demo_user_account(request.user) is_monitor = is_monitor_mode(subscriber, request.user) authorized_page_list = get_authorized_pages(subscriber) return render( request, 'user_accesslist.html', { 'user_access_status_table': user_access_status_table, 'user_access_status_search_from': form, 'user_access_status_add_form': UserAccessStatusForm(), 'user_access_status_delete_form': UserAccessStatusDeleteForm(), 'user_access_status_list': user_access_status_list, 'is_demo_user': is_demo_user, 'can_edit': can_edit, 'search': search, 'is_monitor': is_monitor, 'auth_pages': authorized_page_list })
def list_ip_access_status(request, subscriber): # @UndefinedVariable page_no = request.GET.get('page', 1) form = IpAccessStatusSearchForm(request.GET) search_ip_address = None if form.is_valid(): search_ip_address = form.cleaned_data['ip_address'].strip() # Call service layer to persist paginator = Paginator( configuration_ip_access_list.get_ip_access_status_list( subscriber, search_ip_address), 15) try: ip_access_status_list = paginator.page(page_no) except PageNotAnInteger: ip_access_status_list = paginator.page(page_no) except EmptyPage: ip_access_status_list = paginator.page(paginator.num_pages) ip_access_status_table = [] # List of dicts for HTML rendering for ip_access_status in ip_access_status_list: try: ip_access_status_table.append({ 'id': ip_access_status.pk, 'ip_address': ip_access_status.ipaddress }) except ObjectDoesNotExist: print ip_access_status.pk # Is search requested -> to display the search boxes if no results found in the search search = False if any([search_ip_address]): search = True can_edit = any(is_admin(request.user)) is_demo_user = is_demo_user_account(request.user) is_monitor = is_monitor_mode(subscriber, request.user) authorized_page_list = get_authorized_pages(subscriber) return render( request, 'ip_accesslist.html', { 'ip_access_status_table': ip_access_status_table, 'search_from': form, 'access_status_add_form': IpAccessStatusForm(), 'access_status_delete_form': IpAccessStatusWithNoInputForm(), 'ip_access_status_list': ip_access_status_list, 'is_demo_user': is_demo_user, 'can_edit': can_edit, 'search': search, 'is_monitor': is_monitor, 'auth_pages': authorized_page_list })
def list_user_access_status(request, subscriber): # @UndefinedVariable page_no = request.GET.get('page', 1) form = UserAccessStatusSearchForm(request.GET) search_user_id = None if form.is_valid(): search_user_id = form.cleaned_data['user_id'] # Call service layer to persist paginator = Paginator(page_authorization.get_user_access_status_list(subscriber, search_user_id),15) user_access_status_list = None try: user_access_status_list = paginator.page(page_no) except PageNotAnInteger: user_access_status_list = paginator.page(page_no) except EmptyPage: user_access_status_list = paginator.page(paginator.num_pages) user_access_status_table = [] # List of dicts for HTML rendering for user_access_status in user_access_status_list: try: user_access_status_table.append({'id' : user_access_status.pk, 'user_id' : user_access_status.user_id, 'date_added': user_access_status.change_dt.strftime('%b %d, %Y') }) except ObjectDoesNotExist: print user_access_status.pk # Is search requested -> to display the search boxes if no results found in the search search = False if any([search_user_id]): search = True can_edit = any(is_admin(request.user)) is_demo_user = is_demo_user_account(request.user) is_monitor = is_monitor_mode(subscriber,request.user) authorized_page_list = get_authorized_pages(subscriber) return render(request, 'user_accesslist.html', { 'user_access_status_table' : user_access_status_table, 'user_access_status_search_from' : form, 'user_access_status_add_form' : UserAccessStatusForm(), 'user_access_status_delete_form' : UserAccessStatusDeleteForm(), 'user_access_status_list' : user_access_status_list, 'is_demo_user' : is_demo_user, 'can_edit' : can_edit, 'search' : search, 'is_monitor' : is_monitor, 'auth_pages' : authorized_page_list } )
def getting_started_page(request, subscriber): can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber,request.user) is_demo_user = is_demo_user_account(request.user) authorized_page_list = get_authorized_pages(subscriber) return render(request, 'getting_started.html', { 'can_edit' : can_edit, 'is_monitor' : is_monitor, 'is_demo_user' : is_demo_user, 'auth_pages' : authorized_page_list })
def getting_started_page(request, subscriber): can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber, request.user) is_demo_user = is_demo_user_account(request.user) authorized_page_list = get_authorized_pages(subscriber) return render( request, 'getting_started.html', { 'can_edit': can_edit, 'is_monitor': is_monitor, 'is_demo_user': is_demo_user, 'auth_pages': authorized_page_list })
def list_ip_access_status(request, subscriber): # @UndefinedVariable page_no = request.GET.get('page', 1) form = IpAccessStatusSearchForm(request.GET) search_ip_address = None if form.is_valid(): search_ip_address = form.cleaned_data['ip_address'].strip() # Call service layer to persist paginator = Paginator(configuration_ip_access_list.get_ip_access_status_list(subscriber, search_ip_address),15) try: ip_access_status_list = paginator.page(page_no) except PageNotAnInteger: ip_access_status_list = paginator.page(page_no) except EmptyPage: ip_access_status_list = paginator.page(paginator.num_pages) ip_access_status_table = [] # List of dicts for HTML rendering for ip_access_status in ip_access_status_list: try: ip_access_status_table.append({ 'id' : ip_access_status.pk, 'ip_address' : ip_access_status.ipaddress }) except ObjectDoesNotExist: print ip_access_status.pk # Is search requested -> to display the search boxes if no results found in the search search = False if any([search_ip_address]): search = True can_edit = any(is_admin(request.user)) is_demo_user = is_demo_user_account(request.user) is_monitor = is_monitor_mode(subscriber,request.user) authorized_page_list = get_authorized_pages(subscriber) return render(request, 'ip_accesslist.html', { 'ip_access_status_table' : ip_access_status_table, 'search_from' : form, 'access_status_add_form' : IpAccessStatusForm(), 'access_status_delete_form' : IpAccessStatusWithNoInputForm(), 'ip_access_status_list' : ip_access_status_list, 'is_demo_user' : is_demo_user, 'can_edit' : can_edit, 'search' : search, 'is_monitor' : is_monitor, 'auth_pages' : authorized_page_list } )
def verify_integration_page(request, subscriber): result, message = verifying_integration(subscriber) can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber,request.user) is_demo_user = is_demo_user_account(request.user) authorized_page_list = get_authorized_pages(subscriber) return render(request, 'verify_integration.html', {'result' : result, 'message' : message, 'can_edit' : can_edit, 'is_monitor' : is_monitor, 'is_demo_user' : is_demo_user, 'auth_pages' : authorized_page_list, })
def subscriber_details_page(request, subscriber): external_sids = get_external_sid(subscriber) can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber,request.user) is_demo_user = is_demo_user_account(request.user) authorized_page_list = get_authorized_pages(subscriber) return render(request, 'subscriber_details.html', {'external_sid' : external_sids[0], 'sb_external_sid' : external_sids[1], 'can_edit' : can_edit, 'is_monitor' : is_monitor, 'is_demo_user' : is_demo_user, 'auth_pages' : authorized_page_list, })
def view_bot_response(request, subscriber): pages_per_minute_form = PagesPerMinuteRulesForm() pages_per_minute_form.fields['action'].initial = subscriber.r_Pagepermin.id pages_per_session_form = PagesPerSessionRulesForm() pages_per_session_form.fields[ 'pages_per_session'].initial = subscriber.pagepersess pages_per_session_form.fields[ 'action'].initial = subscriber.r_pagepersess.id session_length_form = SessionLengthRulesForm() session_length_form.fields[ 'session_length'].initial = subscriber.sesslength session_length_form.fields['action'].initial = subscriber.r_sesslength.id browser_integrity_form = BrowserIntegrityCheckForm() browser_integrity_form.fields[ 'action'].initial = subscriber.r_browserIntgrity.id http_request_integrity_form = HTTPRequestIntegrityCheckForm() http_request_integrity_form.fields[ 'action'].initial = subscriber.r_httpRequestIntegrity.id aggregator_check_form = AggregatorCheckForm() aggregator_check_form.fields['action'].initial = subscriber.r_Aggregator.id behaviour_integrity_form = BehaviourIntegrityCheckForm() behaviour_integrity_form.fields[ 'action'].initial = subscriber.r_behaviourIntegrity.id can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber, request.user) is_demo_user = is_demo_user_account(request.user) authorized_page_list = get_authorized_pages(subscriber) return render( request, 'bot_response.html', { 'pages_per_minute_form': pages_per_minute_form, 'pages_per_session_form': pages_per_session_form, 'session_length_form': session_length_form, 'browser_integrity_form': browser_integrity_form, 'http_request_integrity_form': http_request_integrity_form, 'aggregator_check_form': aggregator_check_form, 'behaviour_integrity_form': behaviour_integrity_form, 'subscriber': subscriber, 'can_edit': can_edit, 'is_demo_user': is_demo_user, 'is_monitor': is_monitor, 'auth_pages': authorized_page_list })
def verify_integration_page(request, subscriber): result, message = verifying_integration(subscriber) can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber, request.user) is_demo_user = is_demo_user_account(request.user) authorized_page_list = get_authorized_pages(subscriber) return render( request, 'verify_integration.html', { 'result': result, 'message': message, 'can_edit': can_edit, 'is_monitor': is_monitor, 'is_demo_user': is_demo_user, 'auth_pages': authorized_page_list, })
def excel_view_traffic_analysis(request, subscriber): res, show_time, start_date, end_date, actual_start_date, actual_end_date = get_base_results_for_traffic_analysis(request, subscriber) res['traffic_analysis_result'] = get_n_displayble_traffic_details(res['traffic_analysis'], timezone = subscriber.timezone, show_time=show_time, start_date=start_date, end_date=end_date) filename = "{}.{}".format("traffic_analysis", "xls") is_monitor = is_monitor_mode(subscriber,request.user) excel = write_to_excel_traffic_analysis(res,show_time, is_monitor) response = HttpResponse(mimetype='application/ms-excel') response['Content-Disposition'] = u'attachment; filename={}'.format(filename) excel.save(response) return response
def download_connectors_page(request, subscriber): #Download process to be noted can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber,request.user) is_demo_user = is_demo_user_account(request.user) authorized_page_list = get_authorized_pages(subscriber) form = DownloadConnectorsForm(request.POST) if form.is_valid(): pass else: return render(request, 'download_connectors.html', {'form' : form, 'can_edit' : can_edit, 'is_monitor' : is_monitor, 'is_demo_user' : is_demo_user, 'auth_pages' : authorized_page_list, })
def subscriber_details_page(request, subscriber): external_sids = get_external_sid(subscriber) can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber, request.user) is_demo_user = is_demo_user_account(request.user) authorized_page_list = get_authorized_pages(subscriber) return render( request, 'subscriber_details.html', { 'external_sid': external_sids[0], 'sb_external_sid': external_sids[1], 'can_edit': can_edit, 'is_monitor': is_monitor, 'is_demo_user': is_demo_user, 'auth_pages': authorized_page_list, })
def new_view_traffic_analysis(request, subscriber): res, show_time, start_date, end_date, actual_start_date, actual_end_date = get_base_results_for_traffic_analysis( request, subscriber) res['traffic_analysis_result'] = get_n_displayble_traffic_details( res['traffic_analysis'], timezone=subscriber.timezone, show_time=show_time, start_date=start_date, end_date=end_date) dates_with_data = set() for values in NewRulesSummary.objects.filter(sid=subscriber, dt__range=[start_date, end_date])\ .values_list('dt', flat=True): dates_with_data.add(values) if show_time: dates_with_data = [ values.strftime('%b %d, %H:%M') for values in dates_with_data ] dates_in_given_range = [ dt.strftime('%b %d, %H:%M') for dt in list( rrule.rrule(rrule.HOURLY, dtstart=start_date, until=end_date)) ] else: dates_with_data = [ values.strftime('%b %d') for values in dates_with_data ] dates_in_given_range = [ dt.strftime('%b %d') for dt in list( rrule.rrule(rrule.DAILY, dtstart=start_date, until=end_date)) ] missing_data_date_range = get_missing_data_in_given_date_range( dates_in_given_range, dates_with_data) is_data_missing = True if len(missing_data_date_range) else False can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber, request.user) is_demo_user = is_demo_user_account(request.user) authorized_page_list = get_authorized_pages(subscriber) return render( request, 'dashboard.html', { 'res': res, 'can_edit': can_edit, 'is_monitor': is_monitor, 'is_demo_user': is_demo_user, 'auth_pages': authorized_page_list, 'show_time': show_time, 'is_data_missing': is_data_missing, })
def excel_view_traffic_analysis(request, subscriber): res, show_time, start_date, end_date, actual_start_date, actual_end_date = get_base_results_for_traffic_analysis( request, subscriber) res['traffic_analysis_result'] = get_n_displayble_traffic_details( res['traffic_analysis'], timezone=subscriber.timezone, show_time=show_time, start_date=start_date, end_date=end_date) filename = "{}.{}".format("traffic_analysis", "xls") is_monitor = is_monitor_mode(subscriber, request.user) excel = write_to_excel_traffic_analysis(res, show_time, is_monitor) response = HttpResponse(mimetype='application/ms-excel') response['Content-Disposition'] = u'attachment; filename={}'.format( filename) excel.save(response) return response
def list_user_analysis_details(request, subscriber): page_no = request.GET.get('page', 1) start_date_utc = request.GET.get('date_from') end_date_utc = request.GET.get('date_to') start_date, end_date = _get_date_from_timestamp(request, start_date_utc, end_date_utc) form = UserAnalysisSearchForm(request.GET) search_user_id = None if form.is_valid(): search_user_id = form.cleaned_data['user_id'].strip() start_date, end_date = convert_date_specific_to_timezone( subscriber.timezone, start_date, end_date) # Call service layer to fetch the details data, query = get_user_analysis_details(subscriber, search_user_id, start_date, end_date) user_analysis_details_table, user_analysis_details, z = pagination_for_user_analysis_page( data, query, page_no) search = False if any([search_user_id]): search = True can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber, request.user) is_demo_user = is_demo_user_account(request.user) authorized_page_list = get_authorized_pages(subscriber) return render( request, 'user_analysis.html', { 'user_analysis_details_table': user_analysis_details_table, 'search_form': form, 'user_analysis_details': user_analysis_details, 'can_edit': can_edit, 'is_demo_user': is_demo_user, 'is_monitor': is_monitor, 'search': search, 'auth_pages': authorized_page_list })
def download_connectors_page(request, subscriber): #Download process to be noted can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber, request.user) is_demo_user = is_demo_user_account(request.user) authorized_page_list = get_authorized_pages(subscriber) form = DownloadConnectorsForm(request.POST) if form.is_valid(): pass else: return render( request, 'download_connectors.html', { 'form': form, 'can_edit': can_edit, 'is_monitor': is_monitor, 'is_demo_user': is_demo_user, 'auth_pages': authorized_page_list, })
def view_bot_response(request, subscriber): pages_per_minute_form = PagesPerMinuteRulesForm() pages_per_minute_form.fields['action'].initial = subscriber.r_Pagepermin.id pages_per_session_form = PagesPerSessionRulesForm() pages_per_session_form.fields['pages_per_session'].initial = subscriber.pagepersess pages_per_session_form.fields['action'].initial = subscriber.r_pagepersess.id session_length_form = SessionLengthRulesForm() session_length_form.fields['session_length'].initial = subscriber.sesslength session_length_form.fields['action'].initial = subscriber.r_sesslength.id browser_integrity_form = BrowserIntegrityCheckForm() browser_integrity_form.fields['action'].initial = subscriber.r_browserIntgrity.id http_request_integrity_form = HTTPRequestIntegrityCheckForm() http_request_integrity_form.fields['action'].initial = subscriber.r_httpRequestIntegrity.id aggregator_check_form = AggregatorCheckForm() aggregator_check_form.fields['action'].initial = subscriber.r_Aggregator.id behaviour_integrity_form = BehaviourIntegrityCheckForm() behaviour_integrity_form.fields['action'].initial = subscriber.r_behaviourIntegrity.id can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber,request.user) is_demo_user = is_demo_user_account(request.user) authorized_page_list = get_authorized_pages(subscriber) return render(request, 'bot_response.html', {'pages_per_minute_form' : pages_per_minute_form, 'pages_per_session_form' : pages_per_session_form, 'session_length_form' : session_length_form, 'browser_integrity_form' : browser_integrity_form, 'http_request_integrity_form': http_request_integrity_form, 'aggregator_check_form' : aggregator_check_form, 'behaviour_integrity_form' : behaviour_integrity_form, 'subscriber' : subscriber, 'can_edit' : can_edit, 'is_demo_user' : is_demo_user, 'is_monitor' : is_monitor, 'auth_pages' : authorized_page_list})
def list_user_analysis_details(request, subscriber): page_no = request.GET.get('page', 1) start_date_utc = request.GET.get('date_from') end_date_utc = request.GET.get('date_to') start_date, end_date = _get_date_from_timestamp(request, start_date_utc, end_date_utc) form = UserAnalysisSearchForm(request.GET) search_user_id = None if form.is_valid(): search_user_id = form.cleaned_data['user_id'].strip() start_date, end_date = convert_date_specific_to_timezone(subscriber.timezone, start_date, end_date) # Call service layer to fetch the details data, query = get_user_analysis_details(subscriber, search_user_id, start_date, end_date) user_analysis_details_table, user_analysis_details, z = pagination_for_user_analysis_page(data, query, page_no) search = False if any([search_user_id]): search = True can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber,request.user) is_demo_user = is_demo_user_account(request.user) authorized_page_list = get_authorized_pages(subscriber) return render(request, 'user_analysis.html', {'user_analysis_details_table' : user_analysis_details_table, 'search_form' : form, 'user_analysis_details' : user_analysis_details, 'can_edit' : can_edit, 'is_demo_user' : is_demo_user, 'is_monitor' : is_monitor, 'search' : search, 'auth_pages' : authorized_page_list })
def view_traffic_analysis(request, subscriber): res, show_time, start_date, end_date = get_base_results_for_traffic_analysis( request, subscriber) res['traffic_analysis_result'] = get_n_displayble_traffic_details( res['traffic_analysis'], n=10, show_time=show_time, timezone=subscriber.timezone, start_date=start_date, end_date=end_date) dates_with_data = set() for values in RulesSummary.objects.filter( sid=subscriber, dt__range=[start_date, end_date]).values_list('dt', flat=True): dates_with_data.add(values) dates_with_data = [ datetime.datetime.strptime(values, '%Y-%m-%d').strftime('%b %d') for values in dates_with_data ] dates_in_given_range = [ dt.strftime('%b %d') for dt in list( rrule.rrule(rrule.DAILY, dtstart=start_date, until=end_date)) ] missing_data_date_range = ta_service.get_missing_data_in_given_date_range( dates_in_given_range, dates_with_data) is_data_missing = True if len(missing_data_date_range) else False can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber, request.user) is_demo_user = is_demo_user_account(request.user) return render( request, 'dashboard.html', { 'res': res, 'can_edit': can_edit, 'is_monitor': is_monitor, 'is_demo_user': is_demo_user, 'show_time': show_time, 'is_data_missing': is_data_missing })
def new_view_traffic_analysis(request, subscriber): res, show_time, start_date, end_date, actual_start_date, actual_end_date = get_base_results_for_traffic_analysis(request, subscriber) res['traffic_analysis_result'] = get_n_displayble_traffic_details( res['traffic_analysis'], timezone = subscriber.timezone, show_time=show_time, start_date=start_date, end_date=end_date) dates_with_data = set() for values in NewRulesSummary.objects.filter(sid=subscriber, dt__range=[start_date, end_date])\ .values_list('dt', flat=True): dates_with_data.add(values) if show_time: dates_with_data = [values.strftime('%b %d, %H:%M') for values in dates_with_data] dates_in_given_range = [dt.strftime('%b %d, %H:%M') for dt in list(rrule.rrule(rrule.HOURLY, dtstart=start_date, until=end_date))] else: dates_with_data = [values.strftime('%b %d') for values in dates_with_data] dates_in_given_range = [dt.strftime('%b %d') for dt in list(rrule.rrule(rrule.DAILY, dtstart=start_date, until=end_date))] missing_data_date_range = get_missing_data_in_given_date_range(dates_in_given_range, dates_with_data) is_data_missing = True if len(missing_data_date_range) else False can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber,request.user) is_demo_user = is_demo_user_account(request.user) authorized_page_list = get_authorized_pages(subscriber) return render(request, 'dashboard.html', {'res' : res, 'can_edit' : can_edit, 'is_monitor' : is_monitor, 'is_demo_user' : is_demo_user, 'auth_pages' : authorized_page_list, 'show_time' : show_time, 'is_data_missing' : is_data_missing, })
def list_ip_analysis_details(request, subscriber): # @UndefinedVariable page_no = request.GET.get('page', 1) start_date_utc = request.GET.get('date_from') end_date_utc = request.GET.get('date_to') start_date, end_date = _get_date_from_timestamp(request, start_date_utc, end_date_utc) form = IpAnalysisSearchForm(request.GET) search_ip_address = None search_country_name = None search_isp = None search_city_name = None if form.is_valid(): search_ip_address = form.cleaned_data['ip_address'].strip() search_country_name = form.cleaned_data['country_name'].strip() search_isp = form.cleaned_data['isp'].strip() search_city_name = form.cleaned_data['city_name'].strip() search_status = form.cleaned_data['status'].strip() start_date, end_date = convert_date_specific_to_timezone(subscriber.timezone, start_date, end_date) diff = end_date - start_date show_time = True if diff.days < 3 else False # Call service layer to fetch the details data = ip_analysis_details_service.get_ip_analysis_details(subscriber, search_ip_address, search_country_name, search_isp, search_city_name, search_status, start_date, end_date) paginator = Paginator(data, 15) ip_analysis_details = None try: ip_analysis_details = paginator.page(page_no) except PageNotAnInteger: ip_analysis_details = paginator.page(page_no) except EmptyPage: ip_analysis_details = paginator.page(paginator.num_pages) ip_analysis_details_table = [] # List of dicts for HTML rendering for ip_analysis_detail in ip_analysis_details: ipaddress = IpDetails.objects.get(pk = ip_analysis_detail['ipaddress']) ip_action_form, ip_line_graph_date, ip_line_graph_hits, ip_action, expiry_date, hourly_message = individual_ip_address_details(subscriber, ipaddress.id, start_date, end_date, show_time) ip_address_status = ip_address_clean_or_malicious(ipaddress, subscriber) single_hour_data = True if len(ip_line_graph_date) == 1 else False #Checks for entries for a single hour in single day ip_analysis_details_dict = { 'id' : 0, 'ip_address' : ipaddress.ip_address, 'country_name' : ipaddress.country_name, 'isp' : ipaddress.isp, 'ip_action_form' : ip_action_form, 'ip_action' : ip_action, 'expiry_date' : expiry_date, 'city_name' : ipaddress.city_name, 'bot_hits' : ip_analysis_detail['totalrequests'], 'ip_line_graph_date' : ip_line_graph_date, 'ip_line_graph_hits' : ip_line_graph_hits, 'single_hour_data' : single_hour_data, 'ip_address_status' : ip_address_status, 'bad_bot_traffic_details' : get_bad_bot_traffic_details(ip_analysis_detail) } ip_analysis_details_table.append(ip_analysis_details_dict) search = False if any([search_ip_address, search_country_name, search_isp, search_city_name, search_status]): search = True can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber,request.user) is_demo_user = is_demo_user_account(request.user) authorized_page_list = get_authorized_pages(subscriber) return render(request, 'ip_analysis.html', {'ip_analysis_details_table' : ip_analysis_details_table, 'search_from' : form, 'ip_analysis_details' : ip_analysis_details, 'can_edit' : can_edit, 'is_demo_user' : is_demo_user, 'is_monitor' : is_monitor, 'search' : search, 'auth_pages' : authorized_page_list })
def list_aggregator_analysis_details(request, subscriber): """ This Function is responsible to provide Aggregator list details for the landing page of Aggregator IP Analysis """ page_no = request.GET.get('page', 1) start_date_utc = request.GET.get('date_from') end_date_utc = request.GET.get('date_to') start_date, end_date = _get_date_from_timestamp(request, start_date_utc, end_date_utc) form = AggregatorAnalysisSearchForm(request.GET) search_ip_address = None search_aggregator_name = None if form.is_valid(): search_ip_address = form.cleaned_data['ip_address'].strip() search_aggregator_name = form.cleaned_data['aggregator_name'].strip() start_date, end_date = convert_date_specific_to_timezone(subscriber.timezone, start_date, end_date) # Call service layer to fetch the details data = get_aggregator_analysis_details(subscriber, search_ip_address, search_aggregator_name, start_date, end_date) paginator = Paginator(data, 15) aggregator_analysis_details = None try: aggregator_analysis_details = paginator.page(page_no) except PageNotAnInteger: aggregator_analysis_details = paginator.page(page_no) except EmptyPage: aggregator_analysis_details = paginator.page(paginator.num_pages) aggregator_analysis_details_table = [] # List of dicts for HTML rendering for aggregator_analysis_detail in aggregator_analysis_details: ip_address = AggregatorDetails.objects.get(pk = aggregator_analysis_detail['ip_address']) aggregator_analysis_details_dict = {'id' : 0, 'ip_address' : ip_address.ip_address, 'aggregator_name' : ip_address.aggregator_name, 'bot_hits' : aggregator_analysis_detail['total_requests']} aggregator_analysis_details_table.append(aggregator_analysis_details_dict) search = False if any([search_ip_address, search_aggregator_name]): search = True can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber,request.user) is_demo_user = is_demo_user_account(request.user) authorized_page_list = get_authorized_pages(subscriber) return render(request, 'aggregator_analysis.html', {'search_from' : form, 'aggregator_analysis_details' : aggregator_analysis_details, 'aggregator_analysis_details_table': aggregator_analysis_details_table, 'can_edit' : can_edit, 'is_demo_user' : is_demo_user, 'is_monitor' : is_monitor, 'search' : search, 'auth_pages' : authorized_page_list })
def list_aggregator_analysis_details(request, subscriber): """ This Function is responsible to provide Aggregator list details for the landing page of Aggregator IP Analysis """ page_no = request.GET.get('page', 1) start_date_utc = request.GET.get('date_from') end_date_utc = request.GET.get('date_to') start_date, end_date = _get_date_from_timestamp(request, start_date_utc, end_date_utc) form = AggregatorAnalysisSearchForm(request.GET) search_ip_address = None search_aggregator_name = None if form.is_valid(): search_ip_address = form.cleaned_data['ip_address'].strip() search_aggregator_name = form.cleaned_data['aggregator_name'].strip() start_date, end_date = convert_date_specific_to_timezone( subscriber.timezone, start_date, end_date) # Call service layer to fetch the details data = get_aggregator_analysis_details(subscriber, search_ip_address, search_aggregator_name, start_date, end_date) paginator = Paginator(data, 15) aggregator_analysis_details = None try: aggregator_analysis_details = paginator.page(page_no) except PageNotAnInteger: aggregator_analysis_details = paginator.page(page_no) except EmptyPage: aggregator_analysis_details = paginator.page(paginator.num_pages) aggregator_analysis_details_table = [] # List of dicts for HTML rendering for aggregator_analysis_detail in aggregator_analysis_details: ip_address = AggregatorDetails.objects.get( pk=aggregator_analysis_detail['ip_address']) aggregator_analysis_details_dict = { 'id': 0, 'ip_address': ip_address.ip_address, 'aggregator_name': ip_address.aggregator_name, 'bot_hits': aggregator_analysis_detail['total_requests'] } aggregator_analysis_details_table.append( aggregator_analysis_details_dict) search = False if any([search_ip_address, search_aggregator_name]): search = True can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber, request.user) is_demo_user = is_demo_user_account(request.user) authorized_page_list = get_authorized_pages(subscriber) return render( request, 'aggregator_analysis.html', { 'search_from': form, 'aggregator_analysis_details': aggregator_analysis_details, 'aggregator_analysis_details_table': aggregator_analysis_details_table, 'can_edit': can_edit, 'is_demo_user': is_demo_user, 'is_monitor': is_monitor, 'search': search, 'auth_pages': authorized_page_list })
def list_ip_analysis_details(request, subscriber): # @UndefinedVariable page_no = request.GET.get('page', 1) start_date_utc = request.GET.get('date_from') end_date_utc = request.GET.get('date_to') start_date, end_date = _get_date_from_timestamp(request, start_date_utc, end_date_utc) form = IpAnalysisSearchForm(request.GET) search_ip_address = None search_country_name = None search_isp = None search_city_name = None if form.is_valid(): search_ip_address = form.cleaned_data['ip_address'].strip() search_country_name = form.cleaned_data['country_name'].strip() search_isp = form.cleaned_data['isp'].strip() search_city_name = form.cleaned_data['city_name'].strip() search_status = form.cleaned_data['status'].strip() start_date, end_date = convert_date_specific_to_timezone( subscriber.timezone, start_date, end_date) diff = end_date - start_date show_time = True if diff.days < 3 else False # Call service layer to fetch the details data = ip_analysis_details_service.get_ip_analysis_details( subscriber, search_ip_address, search_country_name, search_isp, search_city_name, search_status, start_date, end_date) paginator = Paginator(data, 15) ip_analysis_details = None try: ip_analysis_details = paginator.page(page_no) except PageNotAnInteger: ip_analysis_details = paginator.page(page_no) except EmptyPage: ip_analysis_details = paginator.page(paginator.num_pages) ip_analysis_details_table = [] # List of dicts for HTML rendering for ip_analysis_detail in ip_analysis_details: ipaddress = IpDetails.objects.get(pk=ip_analysis_detail['ipaddress']) ip_action_form, ip_line_graph_date, ip_line_graph_hits, ip_action, expiry_date, hourly_message = individual_ip_address_details( subscriber, ipaddress.id, start_date, end_date, show_time) ip_address_status = ip_address_clean_or_malicious( ipaddress, subscriber) single_hour_data = True if len( ip_line_graph_date ) == 1 else False #Checks for entries for a single hour in single day ip_analysis_details_dict = { 'id': 0, 'ip_address': ipaddress.ip_address, 'country_name': ipaddress.country_name, 'isp': ipaddress.isp, 'ip_action_form': ip_action_form, 'ip_action': ip_action, 'expiry_date': expiry_date, 'city_name': ipaddress.city_name, 'bot_hits': ip_analysis_detail['totalrequests'], 'ip_line_graph_date': ip_line_graph_date, 'ip_line_graph_hits': ip_line_graph_hits, 'single_hour_data': single_hour_data, 'ip_address_status': ip_address_status, 'bad_bot_traffic_details': get_bad_bot_traffic_details(ip_analysis_detail) } ip_analysis_details_table.append(ip_analysis_details_dict) search = False if any([ search_ip_address, search_country_name, search_isp, search_city_name, search_status ]): search = True can_edit = any(is_admin(request.user)) is_monitor = is_monitor_mode(subscriber, request.user) is_demo_user = is_demo_user_account(request.user) authorized_page_list = get_authorized_pages(subscriber) return render( request, 'ip_analysis.html', { 'ip_analysis_details_table': ip_analysis_details_table, 'search_from': form, 'ip_analysis_details': ip_analysis_details, 'can_edit': can_edit, 'is_demo_user': is_demo_user, 'is_monitor': is_monitor, 'search': search, 'auth_pages': authorized_page_list })