Nenhuma Descrição

datastore_routes.py 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # IRIS Source Code
  2. # Copyright (C) 2022 - DFIR IRIS Team
  3. # 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 render_template
  20. from flask import url_for
  21. from werkzeug.utils import redirect
  22. from app.datamgmt.datastore.datastore_db import datastore_get_file
  23. from app.datamgmt.datastore.datastore_db import datastore_get_path_node
  24. from app.forms import ModalDSFileForm
  25. from app.models.authorization import CaseAccessLevel
  26. from app.blueprints.access_controls import ac_case_requires
  27. from app.blueprints.responses import response_error
  28. datastore_blueprint = Blueprint(
  29. 'datastore',
  30. __name__,
  31. template_folder='templates'
  32. )
  33. @datastore_blueprint.route('/datastore/file/add/<int:cur_id>/modal', methods=['GET'])
  34. @ac_case_requires(CaseAccessLevel.full_access)
  35. def datastore_add_file_modal(cur_id: int, caseid: int, url_redir: bool):
  36. if url_redir:
  37. return redirect(url_for('index.index', cid=caseid, redirect=True))
  38. dsp = datastore_get_path_node(cur_id, caseid)
  39. if not dsp:
  40. return response_error('Invalid path node for this case')
  41. form = ModalDSFileForm()
  42. return render_template("modal_ds_file.html", form=form, file=None, dsp=dsp)
  43. @datastore_blueprint.route('/datastore/file/add/<int:cur_id>/multi-modal', methods=['GET'])
  44. @ac_case_requires(CaseAccessLevel.full_access)
  45. def datastore_add_multi_files_modal(cur_id: int, caseid: int, url_redir: bool):
  46. if url_redir:
  47. return redirect(url_for('index.index', cid=caseid, redirect=True))
  48. dsp = datastore_get_path_node(cur_id, caseid)
  49. if not dsp:
  50. return response_error('Invalid path node for this case')
  51. form = ModalDSFileForm()
  52. return render_template("modal_ds_multi_files.html", form=form, file=None, dsp=dsp)
  53. @datastore_blueprint.route('/datastore/filter-help/modal', methods=['GET'])
  54. @ac_case_requires(CaseAccessLevel.read_only, CaseAccessLevel.full_access)
  55. def datastore_filter_help_modal(caseid, url_redir):
  56. if url_redir:
  57. return redirect(url_for('index.index', cid=caseid, redirect=True))
  58. return render_template("modal_help_filter_ds.html")
  59. @datastore_blueprint.route('/datastore/file/update/<int:cur_id>/modal', methods=['GET'])
  60. @ac_case_requires(CaseAccessLevel.read_only, CaseAccessLevel.full_access)
  61. def datastore_update_file_modal(cur_id: int, caseid: int, url_redir: bool):
  62. if url_redir:
  63. return redirect(url_for('index.index', cid=caseid, redirect=True))
  64. file = datastore_get_file(cur_id, caseid)
  65. if not file:
  66. return response_error('Invalid file ID for this case')
  67. dsp = datastore_get_path_node(file.file_parent_id, caseid)
  68. form = ModalDSFileForm()
  69. form.file_is_ioc.data = file.file_is_ioc
  70. form.file_original_name.data = file.file_original_name
  71. form.file_password.data = file.file_password
  72. form.file_password.render_kw = {'disabled': 'disabled'}
  73. form.file_description.data = file.file_description
  74. form.file_is_evidence.data = file.file_is_evidence
  75. return render_template("modal_ds_file.html", form=form, file=file, dsp=dsp)
  76. @datastore_blueprint.route('/datastore/file/info/<int:cur_id>/modal', methods=['GET'])
  77. @ac_case_requires(CaseAccessLevel.read_only, CaseAccessLevel.full_access)
  78. def datastore_info_file_modal(cur_id: int, caseid: int, url_redir: bool):
  79. if url_redir:
  80. return redirect(url_for('index.index', cid=caseid, redirect=True))
  81. file = datastore_get_file(cur_id, caseid)
  82. if not file:
  83. return response_error('Invalid file ID for this case')
  84. dsp = datastore_get_path_node(file.file_parent_id, caseid)
  85. return render_template("modal_ds_file_info.html", file=file, dsp=dsp)