Mercurial > farol > farol
comparison farol/vulnerability.py @ 60:c6e7175ff28c
Unify acknowledgments update/creation from forms
author | Benoît Allard <benoit.allard@greenbone.net> |
---|---|
date | Wed, 08 Oct 2014 11:58:33 +0200 |
parents | 64403f1b424e |
children | 55b72057b066 |
comparison
equal
deleted
inserted
replaced
59:64403f1b424e | 60:c6e7175ff28c |
---|---|
29 from farolluz.cvrf import (CVRFVulnerability, CVRFVulnerabilityID, CVRFNote, | 29 from farolluz.cvrf import (CVRFVulnerability, CVRFVulnerabilityID, CVRFNote, |
30 CVRFReference, CVRFAcknowledgment, CVRFCWE, CVRFInvolvement, CVRFThreat, | 30 CVRFReference, CVRFAcknowledgment, CVRFCWE, CVRFInvolvement, CVRFThreat, |
31 CVRFProductStatus, CVRFCVSSSet, CVRFRemediation) | 31 CVRFProductStatus, CVRFCVSSSet, CVRFRemediation) |
32 from farolluz.renderer import utcnow | 32 from farolluz.renderer import utcnow |
33 | 33 |
34 from .controller import update_note_from_request, create_note_from_request | 34 from .controller import (update_note_from_request, create_note_from_request, |
35 update_acknowledgment_from_request, create_acknowledgment_from_request) | |
35 from .session import document_required, get_current | 36 from .session import document_required, get_current |
36 | 37 |
37 | 38 |
38 vulnerability = Blueprint('vulnerability', __name__) | 39 vulnerability = Blueprint('vulnerability', __name__) |
39 | 40 |
458 except IndexError: | 459 except IndexError: |
459 abort(404) | 460 abort(404) |
460 if request.method != 'POST': | 461 if request.method != 'POST': |
461 return render_template('vulnerability/edit_acknowledgment.j2', ordinal=ordinal, name=ack._name, organization=ack._organization, description=ack._description, url=ack._url, action='Update') | 462 return render_template('vulnerability/edit_acknowledgment.j2', ordinal=ordinal, name=ack._name, organization=ack._organization, description=ack._description, url=ack._url, action='Update') |
462 | 463 |
463 ack._name = request.form['name'] or None | 464 update_acknowledgment_from_request(ack) |
464 ack._organization = request.form['organization'] or None | |
465 ack._description = request.form['description'] or None | |
466 ack._url = request.form['url'] or None | |
467 return redirect(url_for('.view', ordinal=ordinal)) | 465 return redirect(url_for('.view', ordinal=ordinal)) |
468 | 466 |
469 @vulnerability.route('/<int:ordinal>/acknowledgment/add', methods=['GET', 'POST']) | 467 @vulnerability.route('/<int:ordinal>/acknowledgment/add', methods=['GET', 'POST']) |
470 @document_required | 468 @document_required |
471 def add_acknowledgment(ordinal): | 469 def add_acknowledgment(ordinal): |
472 if request.method != 'POST': | 470 if request.method != 'POST': |
473 return render_template('vulnerability/edit_acknowledgment.j2', action='Add', ordinal=ordinal) | 471 return render_template('vulnerability/edit_acknowledgment.j2', action='Add', ordinal=ordinal) |
474 | 472 |
475 ack = CVRFAcknowledgment() | 473 ack = create_acknowledgment_from_request() |
476 ack._name = request.form['name'] or None | |
477 ack._organization = request.form['organization'] or None | |
478 ack._description = request.form['description'] or None | |
479 ack._url = request.form['url'] or None | |
480 get_vuln(ordinal).addAcknowledgment(ack) | 474 get_vuln(ordinal).addAcknowledgment(ack) |
481 return redirect(url_for('.view', ordinal=ordinal)) | 475 return redirect(url_for('.view', ordinal=ordinal)) |