Nav apraksta

case_notes_routes.py 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # IRIS Source Code
  2. # Copyright (C) 2021 - Airbus CyberSecurity (SAS) - DFIR-IRIS Team
  3. # ir@cyberactionlab.net - contact@dfir-iris.org
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU Lesser General Public
  7. # License as published by the Free Software Foundation; either
  8. # version 3 of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # Lesser General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Lesser General Public License
  16. # along with this program; if not, write to the Free Software Foundation,
  17. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. from flask import Blueprint
  19. from flask import redirect
  20. from flask import render_template
  21. from flask import url_for
  22. from flask_wtf import FlaskForm
  23. from app.datamgmt.case.case_db import case_get_desc_crc
  24. from app.datamgmt.case.case_db import get_case
  25. from app.datamgmt.case.case_notes_db import get_note
  26. from app.models.authorization import CaseAccessLevel
  27. from app.blueprints.access_controls import ac_case_requires
  28. from app.blueprints.responses import response_error
  29. case_notes_blueprint = Blueprint('case_notes',
  30. __name__,
  31. template_folder='templates')
  32. @case_notes_blueprint.route('/case/notes', methods=['GET'])
  33. @ac_case_requires(CaseAccessLevel.read_only, CaseAccessLevel.full_access)
  34. def case_notes(caseid, url_redir):
  35. if url_redir:
  36. return redirect(url_for('case_notes.case_notes', cid=caseid, redirect=True))
  37. form = FlaskForm()
  38. case = get_case(caseid)
  39. if case:
  40. crc32, desc = case_get_desc_crc(caseid)
  41. else:
  42. crc32 = None
  43. desc = None
  44. return render_template('case_notes_v2.html', case=case, form=form, th_desc=desc, crc=crc32)
  45. @case_notes_blueprint.route('/case/notes/<int:cur_id>/comments/modal', methods=['GET'])
  46. @ac_case_requires(CaseAccessLevel.read_only, CaseAccessLevel.full_access)
  47. def case_comment_note_modal(cur_id, caseid, url_redir):
  48. if url_redir:
  49. return redirect(url_for('case_note.case_note', cid=caseid, redirect=True))
  50. note = get_note(cur_id, caseid=caseid)
  51. if not note:
  52. return response_error('Invalid note ID')
  53. return render_template("modal_conversation.html", element_id=cur_id, element_type='notes',
  54. title=note.note_title)