Esempio n. 1
0
 def log_alert(e):
     alert = Alerts(user_id=Dojo_User.objects.get(is_superuser=True),
                    title='Notification issue',
                    description="%s" % e,
                    icon="exclamation-triangle",
                    source="Notifications")
     alert.save()
Esempio n. 2
0
def log_jira_message(text, finding):
    alerts = Alerts(description=text + " Finding: " + str(finding.id),
                    url=reverse('view_finding', args=(finding.id, )),
                    icon="bullseye",
                    display_date=localtz.localize(datetime.today()),
                    source="Jira")
    alerts.save()
Esempio n. 3
0
def log_jira_alert(error, finding):
    alerts = Alerts(description="Jira update issue: Finding: " +
                    str(finding.id) + ", " + error,
                    url=reverse('view_finding', args=(finding.id, )),
                    icon="bullseye",
                    display_date=localtz.localize(datetime.today()),
                    source="Jira")
    alerts.save()
Esempio n. 4
0
 def send_alert_notification(user=None):
     icon = kwargs.get('icon', 'info-circle')
     alert = Alerts(user_id=user, 
                    title=kwargs.get('title'),
                    description=create_notification_message(event, 'alert'),
                    url=kwargs.get('url', reverse('alerts')),
                    icon=icon, 
                    source=Notifications._meta.get_field(event).verbose_name.title())
     alert.save()
Esempio n. 5
0
 def send_alert_notification(user=None):
     icon = kwargs.get('icon', 'info-circle')
     alert = Alerts(user_id=user, 
                    title=kwargs.get('title'),
                    description=create_notification_message(event, 'alert'),
                    url=kwargs.get('url', reverse('alerts')),
                    icon=icon, 
                    source=Notifications._meta.get_field(event).verbose_name.title())
     alert.save()
Esempio n. 6
0
def log_alert(e, *args, **kwargs):
    # no try catch here, if this fails we need to show an error
    users = Dojo_User.objects.filter(is_superuser=True)
    for user in users:
        alert = Alerts(user_id=user,
                       url=kwargs.get('url', reverse('alerts')),
                       title='Notification issue',
                       description="%s" % e,
                       icon="exclamation-triangle",
                       source="Notifications")
        # relative urls will fail validation
        alert.clean_fields(exclude=['url'])
        alert.save()
Esempio n. 7
0
def log_alert(e, notification_type=None, *args, **kwargs):
    # no try catch here, if this fails we need to show an error

    users = Dojo_User.objects.filter((Q(is_superuser=True) | Q(is_staff=True)))
    for user in users:
        alert = Alerts(user_id=user,
                       url=kwargs.get('url', reverse('alerts'))[:100],
                       title=kwargs.get('title', 'Notification issue'),
                       description=kwargs.get('description', '%s' % e)[:2000],
                       icon="exclamation-triangle",
                       source=notification_type[:100] if notification_type else
                       kwargs.get('source', 'unknown')[:100])
        # relative urls will fail validation
        alert.clean_fields(exclude=['url'])
        alert.save()
Esempio n. 8
0
def send_alert_notification(event, user=None, *args, **kwargs):
    print('sending alert notification')
    try:
        icon = kwargs.get('icon', 'info-circle')
        alert = Alerts(user_id=user,
                       title=kwargs.get('title')[:100],
                       description=create_notification_message(
                           event, user, 'alert', *args, **kwargs),
                       url=kwargs.get('url', reverse('alerts')),
                       icon=icon[:25],
                       source=Notifications._meta.get_field(
                           event).verbose_name.title()[:100])
        # relative urls will fail validation
        alert.clean_fields(exclude=['url'])
        alert.save()
    except Exception as e:
        logger.exception(e)
        log_alert(e, *args, **kwargs)
        pass
Esempio n. 9
0
def send_alert_notification(event, user=None, *args, **kwargs):
    logger.debug('sending alert notification to %s', user)
    try:
        # no need to differentiate between user/no user
        icon = kwargs.get('icon', 'info-circle')
        alert = Alerts(
            user_id=user,
            title=kwargs.get('title')[:250],
            description=create_notification_message(event, user, 'alert', *args, **kwargs)[:2000],
            url=kwargs.get('url', reverse('alerts')),
            icon=icon[:25],
            source=Notifications._meta.get_field(event).verbose_name.title()[:100]
        )
        # relative urls will fail validation
        alert.clean_fields(exclude=['url'])
        alert.save()
    except Exception as e:
        logger.exception(e)
        log_alert(e, "Alert Notification", title=kwargs['title'], description=str(e), url=kwargs['url'])
        pass
Esempio n. 10
0
 def log_alert(e):
     alert = Alerts(user_id=Dojo_User.objects.get(is_superuser=True), title='Notification issue', description="%s" % e, icon="exclamation-triangle", source="Notifications")
     alert.save()