Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifications Overhaul #1158, Enhancement #1154, and more.... #1437

Merged
merged 12 commits into from
Aug 2, 2019
18 changes: 18 additions & 0 deletions dojo/db_migrations/0010_jira_conf_configuration_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.1 on 2019-07-31 18:07

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('dojo', '0009_endpoint_remediation'),
]

operations = [
migrations.AddField(
model_name='jira_conf',
name='configuration_name',
field=models.CharField(default='', help_text='Enter a name to give to this configuration', max_length=2000),
),
]
7 changes: 6 additions & 1 deletion dojo/endpoint/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from dojo.forms import EditEndpointForm, \
DeleteEndpointForm, AddEndpointForm, DojoMetaDataForm
from dojo.models import Product, Endpoint, Finding, System_Settings, DojoMeta
from dojo.utils import get_page_items, add_breadcrumb, get_period_counts, get_system_setting, Product_Tab, calculate_grade
from dojo.utils import get_page_items, add_breadcrumb, get_period_counts, get_system_setting, Product_Tab, calculate_grade, create_notification

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -226,6 +226,11 @@ def delete_endpoint(request, eid):
messages.SUCCESS,
'Endpoint and relationships removed.',
extra_tags='alert-success')
create_notification(event='other',
title='Deletion of %s' % endpoint,
description='The endpoint "%s" was deleted by %s' % (endpoint, request.user),
url=request.build_absolute_uri(reverse('endpoints')),
icon="exclamation-triangle")
return HttpResponseRedirect(reverse('view_product', args=(product.id,)))

collector = NestedObjects(using=DEFAULT_DB_ALIAS)
Expand Down
14 changes: 14 additions & 0 deletions dojo/engagement/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ def delete_engagement(request, eid):
messages.SUCCESS,
'Engagement and relationships removed.',
extra_tags='alert-success')
create_notification(event='other',
title='Deletion of %s' % engagement.name,
description='The engagement "%s" was deleted by %s' % (engagement.name, request.user),
url=request.build_absolute_uri(reverse('view_engagements', args=(product.id, ))),
recipients=[engagement.lead],
icon="exclamation-triangle")

if engagement.engagement_type == 'CI/CD':
return HttpResponseRedirect(reverse("view_engagements_cicd", args=(product.id, )))
Expand Down Expand Up @@ -640,6 +646,10 @@ def close_eng(request, eid):
messages.SUCCESS,
'Engagement closed successfully.',
extra_tags='alert-success')
create_notification(event='other',
title='Closure of %s' % eng.name,
description='The engagement "%s" was closed' % (eng.name),
url=request.build_absolute_uri(reverse('view_engagements', args=(eng.product.id, ))),)
if eng.engagement_type == 'CI/CD':
return HttpResponseRedirect(reverse("view_engagements_cicd", args=(eng.product.id, )))
else:
Expand All @@ -655,6 +665,10 @@ def reopen_eng(request, eid):
messages.SUCCESS,
'Engagement reopened successfully.',
extra_tags='alert-success')
create_notification(event='other',
title='Reopening of %s' % eng.name,
description='The engagement "%s" was reopened' % (eng.name),
url=request.build_absolute_uri(reverse('view_engagements', args=(eng.product.id, ))),)
if eng.engagement_type == 'CI/CD':
return HttpResponseRedirect(reverse("view_engagements_cicd", args=(eng.product.id, )))
else:
Expand Down
23 changes: 22 additions & 1 deletion dojo/finding/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,12 @@ def close_finding(request, fid):
messages.SUCCESS,
'Finding closed.',
extra_tags='alert-success')
create_notification(event='other',
title='Closing of %s' % finding.title,
description='The finding "%s" was closed by %s' % (finding.title, request.user),
url=request.build_absolute_uri(reverse('view_test', args=(finding.test.id, ))),
)

return HttpResponseRedirect(
reverse('view_test', args=(finding.test.id, )))

Expand Down Expand Up @@ -443,6 +449,11 @@ def reopen_finding(request, fid):
messages.SUCCESS,
'Finding Reopened.',
extra_tags='alert-success')
create_notification(event='other',
title='Reopening of %s' % finding.title,
description='The finding "%s" was reopened by %s' % (finding.title, request.user),
url=request.build_absolute_uri(reverse('view_test', args=(finding.test.id, ))),
)
return HttpResponseRedirect(reverse('view_finding', args=(finding.id, )))


Expand Down Expand Up @@ -489,6 +500,12 @@ def delete_finding(request, fid):
messages.SUCCESS,
'Finding deleted successfully.',
extra_tags='alert-success')
create_notification(event='other',
title='Deletion of %s' % finding.title,
description='The finding "%s" was deleted by %s' % (finding.title, request.user),
url=request.build_absolute_uri(reverse('all_findings')),
recipients=[finding.test.engagement.lead],
icon="exclamation-triangle")
return HttpResponseRedirect(reverse('view_test', args=(tid, )))
else:
messages.add_message(
Expand Down Expand Up @@ -670,10 +687,14 @@ def request_finding_review(request, fid):
users = form.cleaned_data['reviewers']
finding.reviewers.set(users)
finding.save()
reviewers = ""
for suser in form.cleaned_data['reviewers']:
reviewers += str(suser) + ", "
reviewers = reviewers[:-2]

create_notification(event='review_requested',
title='Finding review requested',
description='User %s has requested that you please review the finding "%s" for accuracy:\n\n%s' % (user, finding.title, new_note),
description='User %s has requested that users %s review the finding "%s" for accuracy:\n\n%s' % (user, reviewers, finding.title, new_note),
icon='check',
url=request.build_absolute_uri(reverse("view_finding", args=(finding.id,))))

Expand Down
19 changes: 18 additions & 1 deletion dojo/jira_link/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Local application/library imports
from dojo.forms import JIRAForm, DeleteJIRAConfForm
from dojo.models import User, JIRA_Conf, JIRA_Issue, Notes
from dojo.utils import add_breadcrumb, get_system_setting
from dojo.utils import add_breadcrumb, get_system_setting, create_notification

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -96,6 +96,12 @@ def new_jira(request):
messages.SUCCESS,
'JIRA Configuration Successfully Created.',
extra_tags='alert-success')
create_notification(event='other',
title='New addition of JIRA URL %s' % jform.cleaned_data.get('url').rstrip('/'),
description='JIRA url "%s" was added by %s' %
(jform.cleaned_data.get('url').rstrip('/'), request.user),
url=request.build_absolute_uri(reverse('jira')),
)
return HttpResponseRedirect(reverse('jira', ))
except Exception:
messages.add_message(request,
Expand Down Expand Up @@ -131,6 +137,12 @@ def edit_jira(request, jid):
messages.SUCCESS,
'JIRA Configuration Successfully Created.',
extra_tags='alert-success')
create_notification(event='other',
title='Edit of JIRA URL %s' % jform.cleaned_data.get('url').rstrip('/'),
description='JIRA url "%s" was edited by %s' %
(jform.cleaned_data.get('url').rstrip('/'), request.user),
url=request.build_absolute_uri(reverse('jira')),
)
return HttpResponseRedirect(reverse('jira', ))
except Exception:
messages.add_message(request,
Expand Down Expand Up @@ -185,6 +197,11 @@ def delete_jira(request, tid):
messages.SUCCESS,
'JIRA Conf and relationships removed.',
extra_tags='alert-success')
create_notification(event='other',
title='Deletion of JIRA URL %s' % jira_instance.url,
description='JIRA url "%s" was deleted by %s' % (jira_instance.url, request.user),
url=request.build_absolute_uri(reverse('jira')),
)
return HttpResponseRedirect(reverse('jira'))

collector = NestedObjects(using=DEFAULT_DB_ALIAS)
Expand Down
1 change: 1 addition & 0 deletions dojo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,7 @@ def save(self, *args, **kwargs):


class JIRA_Conf(models.Model):
configuration_name = models.CharField(max_length=2000, help_text="Enter a name to give to this configuration", default='')
url = models.URLField(max_length=2000, verbose_name="JIRA URL", help_text="For configuring Jira, view: https://defectdojo.readthedocs.io/en/latest/features.html#jira-integration")
# product = models.ForeignKey(Product)
username = models.CharField(max_length=2000)
Expand Down
5 changes: 5 additions & 0 deletions dojo/product/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,11 @@ def delete_product(request, pid):
messages.SUCCESS,
'Product and relationships removed.',
extra_tags='alert-success')
create_notification(event='other',
title='Deletion of %s' % product.name,
description='The product "%s" was deleted by %s' % (product.name, request.user),
url=request.build_absolute_uri(reverse('product')),
icon="exclamation-triangle")
return HttpResponseRedirect(reverse('product'))

collector = NestedObjects(using=DEFAULT_DB_ALIAS)
Expand Down
8 changes: 7 additions & 1 deletion dojo/product_type/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from dojo.filters import ProductTypeFilter
from dojo.forms import Product_TypeForm, Product_TypeProductForm, Delete_Product_TypeForm
from dojo.models import Product_Type
from dojo.utils import get_page_items, add_breadcrumb
from dojo.utils import get_page_items, add_breadcrumb, create_notification


logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -83,6 +84,11 @@ def edit_product_type(request, ptid):
"Product type Deleted successfully.",
extra_tags="alert-success",
)
create_notification(event='other',
title='Deletion of %s' % pt.name,
description='The product type "%s" was deleted by %s' % (pt.name, request.user),
url=request.build_absolute_uri(reverse('product_type')),
icon="exclamation-triangle")
return HttpResponseRedirect(reverse("product_type"))
add_breadcrumb(title="Edit Product Type", top_level=False, request=request)
return render(request, 'dojo/edit_product_type.html', {
Expand Down
9 changes: 6 additions & 3 deletions dojo/templates/dojo/findings_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ <h3 class="has-filters">
</div>
</div>
{% if findings %}
<div class="clearfix">
{% include "dojo/paging_snippet.html" with page=findings page_size=True %}
</div>
<div class="hidden" style="padding-bottom: 5px;" id="bulk_edit_menu">
<div class="btn-toolbar" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group mr-2" role="group" aria-label="Second group">
Expand Down Expand Up @@ -94,9 +97,6 @@ <h3 class="has-filters">
</div>
</div>
</div>
<div class="clearfix">
{% include "dojo/paging_snippet.html" with page=findings page_size=True %}
</div>
<div class="panel panel-default table-responsive">
<table id="open_findings"
class="tablesorter-bootstrap table table-condensed table-striped table-hover">
Expand Down Expand Up @@ -264,6 +264,9 @@ <h3 class="has-filters">
" data-placement="right" data-container="body" data-original-title="Endpoints" title="">
{% endif %}
{% endif %}
{% if finding.notes.all %}
<i class="fa fa-comment has-popover" data-trigger="hover" data-content="{{ finding.notes.all.0 }}" data-placement="left" data-container="body" data-original-title="Most Recent Note" title="">
{% endif %}
</i>
<sup>
{% for tag in finding.tags %}
Expand Down
4 changes: 4 additions & 0 deletions dojo/templates/dojo/jira.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ <h3 class="has-filters">
class="tablesorter-bootstrap table table-bordered table-condensed table-striped">
<thead>
<tr>
<th>Name</th>
<th>URL</th>
<th> Username</th>
<th></th>
Expand All @@ -44,6 +45,9 @@ <h3 class="has-filters">
<tbody>
{% for conf in confs %}
<tr>
<td>
{{ conf.configuration_name }}
</td>
<td>
<a href="{% url 'edit_jira' conf.id %}"><b>{{ conf.url }}</b></a>
</td>
Expand Down
Loading