Mercurial > farol
changeset 91:6a61c02f2156
Add deletion of CWEs
author | Benoît Allard <benoit.allard@greenbone.net> |
---|---|
date | Thu, 09 Oct 2014 16:03:04 +0200 |
parents | 2201d0ea0bf3 |
children | 33d6fd9a5e12 |
files | farol/templates/vulnerability/view.j2 farol/vulnerability.py |
diffstat | 2 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/farol/templates/vulnerability/view.j2 Thu Oct 09 15:56:43 2014 +0200 +++ b/farol/templates/vulnerability/view.j2 Thu Oct 09 16:03:04 2014 +0200 @@ -24,7 +24,7 @@ -#} {% extends "base.j2" %} -{% from "macros.j2" import panel, label_value %} +{% from "macros.j2" import panel, label_value, delete_button %} {% block title %}{{ vulnerability._title or '' }}{% endblock %} {% set active = 'vulnerability' %} @@ -70,7 +70,7 @@ {% call panel(heading="CWE", badge=vulnerability._cwes | length, title=3) %} <ul> {% for cwe in vulnerability._cwes %} - <li>{{ cwe._id }} - {{ cwe._value}} (<a href="{{ url_for('.edit_cwe', ordinal=vulnerability._ordinal, index=loop.index0) }}">edit</a>)</li> + <li><div>{{ cwe._id }} - {{ cwe._value}} (<a href="{{ url_for('.edit_cwe', ordinal=vulnerability._ordinal, index=loop.index0) }}">edit</a>){{ delete_button(url_for('.del_cwe', ordinal=vulnerability._ordinal, index=loop.index0)) }}</div></li> {% endfor %} <a href="{{ url_for('.add_cwe', ordinal=vulnerability._ordinal) }}" class="pull-right">add</a> {% endcall %}
--- a/farol/vulnerability.py Thu Oct 09 15:56:43 2014 +0200 +++ b/farol/vulnerability.py Thu Oct 09 16:03:04 2014 +0200 @@ -212,7 +212,6 @@ cwe._value = request.form['description'] return redirect(url_for('.view', ordinal=ordinal)) - @vulnerability.route('/<int:ordinal>/cwe/add', methods=['GET', 'POST']) @document_required def add_cwe(ordinal): @@ -223,6 +222,17 @@ get_vuln(ordinal).addCWE(cwe) return redirect(url_for('.view', ordinal=ordinal)) +@vulnerability.route('/<int:ordinal>/cwe/<int:index>/del', methods=['POST']) +@document_required +def del_cwe(ordinal, index): + cwes = get_vuln(ordinal)._cwes + if not ( 0 <= index < len(cwes)): + flash('CWE not found', 'danger') + abort(404) + del cwes[index] + return redirect(url_for('.view', ordinal=ordinal)) + + @vulnerability.route('/<int:ordinal>/productstatus/<int:index>') @document_required def view_status(ordinal, index):