From 0a61f44c8a68fd106639146a9bbac75ff3df4954 Mon Sep 17 00:00:00 2001 From: c8y3 <25362953+c8y3@users.noreply.github.com> Date: Tue, 19 Mar 2024 15:42:57 +0100 Subject: [PATCH] [IMP] Starting to separate business layer from REST layer. The business layer will be common to REST and GraphQL and include permission checks --- .../blueprints/manage/manage_cases_routes.py | 12 ++++------ source/app/business/__init__.py | 0 source/app/business/cases.py | 23 +++++++++++++++++++ 3 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 source/app/business/__init__.py create mode 100644 source/app/business/cases.py diff --git a/source/app/blueprints/manage/manage_cases_routes.py b/source/app/blueprints/manage/manage_cases_routes.py index f0510f7cd..4fbdd4ede 100644 --- a/source/app/blueprints/manage/manage_cases_routes.py +++ b/source/app/blueprints/manage/manage_cases_routes.py @@ -49,17 +49,14 @@ from app.datamgmt.manage.manage_case_templates_db import get_case_templates_list, case_template_pre_modifier, \ case_template_post_modifier from app.datamgmt.manage.manage_cases_db import close_case, map_alert_resolution_to_case_status, get_filtered_cases -from app.datamgmt.manage.manage_cases_db import delete_case from app.datamgmt.manage.manage_cases_db import get_case_details_rt from app.datamgmt.manage.manage_cases_db import get_case_protagonists from app.datamgmt.manage.manage_cases_db import list_cases_dict from app.datamgmt.manage.manage_cases_db import reopen_case from app.datamgmt.manage.manage_common import get_severities_list -from app.datamgmt.manage.manage_users_db import get_user_organisations from app.forms import AddCaseForm from app.iris_engine.access_control.utils import ac_fast_check_current_user_has_case_access, \ ac_current_user_has_permission -from app.iris_engine.access_control.utils import ac_fast_check_user_has_case_access from app.iris_engine.access_control.utils import ac_set_new_case_access from app.iris_engine.module_handler.module_handler import call_modules_hook from app.iris_engine.module_handler.module_handler import configure_module_on_init @@ -67,18 +64,17 @@ from app.iris_engine.tasker.tasks import task_case_update from app.iris_engine.utils.common import build_upload_path from app.iris_engine.utils.tracker import track_activity -from app.models.alerts import AlertStatus from app.models.authorization import CaseAccessLevel from app.models.authorization import Permissions -from app.models.models import Client, ReviewStatusList +from app.models.models import ReviewStatusList from app.schema.marshables import CaseSchema, CaseDetailsSchema -from app.util import ac_api_case_requires, add_obj_history_entry +from app.util import add_obj_history_entry from app.util import ac_api_requires from app.util import ac_api_return_access_denied -from app.util import ac_case_requires from app.util import ac_requires from app.util import response_error from app.util import response_success +from app.business.cases import delete manage_cases_blueprint = Blueprint('manage_case', __name__, @@ -250,7 +246,7 @@ def api_delete_case(cur_id, caseid): else: try: call_modules_hook('on_preload_case_delete', data=cur_id, caseid=caseid) - if delete_case(case_id=cur_id): + if delete(cur_id): call_modules_hook('on_postload_case_delete', data=cur_id, caseid=caseid) diff --git a/source/app/business/__init__.py b/source/app/business/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/source/app/business/cases.py b/source/app/business/cases.py new file mode 100644 index 000000000..df810d9e3 --- /dev/null +++ b/source/app/business/cases.py @@ -0,0 +1,23 @@ +# IRIS Source Code +# Copyright (C) 2024 - DFIR-IRIS +# contact@dfir-iris.org +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +from app.datamgmt.manage.manage_cases_db import delete_case + + +def delete(identifier): + return delete_case(identifier)