Security reports have an UUID
These are changes following the US574 in cerberus project, introducing an uuid for security reports. Change-Id: I1ea5e1c8211217d9283e8562ae38c175c07a821a
This commit is contained in:
parent
d24e33e2b3
commit
18aa75f9d4
@ -107,14 +107,14 @@ def security_report_list(request):
|
||||
return cerberusclient(request).security_reports.list()
|
||||
|
||||
|
||||
def security_report_get(request, sr_id):
|
||||
def security_report_get(request, sr_uuid):
|
||||
"""Get a security report."""
|
||||
return cerberusclient(request).security_reports.get(sr_id)
|
||||
return cerberusclient(request).security_reports.get(sr_uuid)
|
||||
|
||||
|
||||
def security_report_put_ticket_id(request, sr_id, ticket_id):
|
||||
def security_report_put_ticket_id(request, sr_uuid, ticket_id):
|
||||
"""Update a security report by adding its associated ticket id."""
|
||||
return cerberusclient(request).security_reports.put(sr_id, ticket_id)
|
||||
return cerberusclient(request).security_reports.put(sr_uuid, ticket_id)
|
||||
|
||||
|
||||
def security_alarm_list(request):
|
||||
|
@ -56,13 +56,13 @@ class CreateTicket(tables.BatchAction):
|
||||
return not(is_associated(report)) \
|
||||
and api.cerberus.is_sticks_available(request)
|
||||
|
||||
def action(self, request, report_id):
|
||||
report = api.cerberus.security_report_get(request, report_id)
|
||||
def action(self, request, report_uuid):
|
||||
report = api.cerberus.security_report_get(request, report_uuid)
|
||||
data = {'project': report.project_id, 'title': report.title}
|
||||
try:
|
||||
ticket = api.cerberus.ticket_create(request, data)
|
||||
api.cerberus.security_report_put_ticket_id(request,
|
||||
report_id,
|
||||
report_uuid,
|
||||
ticket.id)
|
||||
except Exception as e:
|
||||
LOG.exception(e)
|
||||
@ -92,10 +92,10 @@ class ShowTicket(tables.LinkAction):
|
||||
|
||||
|
||||
class SecurityReportsTable(tables.DataTable):
|
||||
report_id = tables.Column("id",
|
||||
link=("horizon:security:security_reports:"
|
||||
"details"),
|
||||
verbose_name="id",)
|
||||
report_uuid = tables.Column("uuid",
|
||||
link=("horizon:security:security_reports:"
|
||||
"details"),
|
||||
verbose_name="uuid",)
|
||||
title = tables.Column("title", verbose_name=_("Title"))
|
||||
description = tables.Column("description", verbose_name=_("Description"))
|
||||
plugin_id = tables.Column("plugin_id", verbose_name=_("Plugin"))
|
||||
@ -115,6 +115,9 @@ class SecurityReportsTable(tables.DataTable):
|
||||
verbose_name = _("Security Reports")
|
||||
row_actions = (CreateTicket, ShowTicket)
|
||||
|
||||
def get_object_id(self, report):
|
||||
return report.uuid
|
||||
|
||||
|
||||
class VulnerabilitiesTable(tables.DataTable):
|
||||
service = tables.Column("service",
|
||||
|
@ -25,6 +25,6 @@ urlpatterns = patterns('',
|
||||
name='index'),
|
||||
url(r'^$', views.IndexView.as_view(),
|
||||
name='security_reports'),
|
||||
url(r'^(?P<report_id>[^/]+)$',
|
||||
url(r'^(?P<report_uuid>[^/]+)$',
|
||||
views.DetailView.as_view(),
|
||||
name='details'),)
|
||||
|
@ -52,16 +52,16 @@ class DetailView(tabs.TabbedTableView):
|
||||
return context
|
||||
|
||||
def get_data(self):
|
||||
report_id = self.kwargs['report_id']
|
||||
report_uuid = self.kwargs['report_uuid']
|
||||
try:
|
||||
security_report = cerberus.security_report_get(
|
||||
self.request, report_id)
|
||||
self.request, report_uuid)
|
||||
except Exception as e:
|
||||
LOG.exception(e)
|
||||
redirect = reverse_lazy(self.redirect_url)
|
||||
exceptions.handle(self.request,
|
||||
_('Unable to retrieve details for '
|
||||
'security report "%s".') % report_id,
|
||||
'security report "%s".') % report_uuid,
|
||||
redirect=redirect)
|
||||
# Not all exception types handled above will result in a redirect.
|
||||
# Need to raise here just in case.
|
||||
|
@ -8,7 +8,7 @@
|
||||
<hr class="header_rule">
|
||||
<dl>
|
||||
<dt>{% trans "ID" %}</dt>
|
||||
<dd>{{ security_report.id }}</dd>
|
||||
<dd>{{ security_report.uuid }}</dd>
|
||||
<dt>{% trans "Title" %}</dt>
|
||||
<dd>{{ security_report.title }}</dd>
|
||||
<dt>{% trans "Description" %}</dt>
|
||||
@ -32,6 +32,8 @@
|
||||
<dt>{% trans "Plugin" %}</dt>
|
||||
<dd><a href="{% url 'horizon:security:plugins:details' security_report.plugin_id %}">
|
||||
{{ security_report.plugin_id }}</a></dd>
|
||||
<dt>{% trans "Report id of the plugin" %}</dt>
|
||||
<dd>{{ security_report.report_id }}</dd>
|
||||
<dt>{% trans "Associated ticket" %}</dt>
|
||||
{% if security_report.ticket_id != None %}
|
||||
<dd><a href="{% url 'horizon:helpdesk:tickets:details' security_report.ticket_id %}">
|
||||
|
@ -3,7 +3,7 @@
|
||||
{% block title %}{% trans "Security Report Details" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Security Report Details: ")|add:security_report.id %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Security Report Details: ")|add:security_report.uuid %}
|
||||
{% endblock page_header %}
|
||||
|
||||
{% block main %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user