From aea61e1a0b3d5d6ae8773595e21c6394d034bb32 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Fri, 6 Dec 2024 10:04:19 +0100
Subject: [PATCH 01/37] Added ruff check
---
.github/workflows/ci.yml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7baf831dd..8643401ce 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -27,6 +27,10 @@ jobs:
steps:
- name: Check out iris
uses: actions/checkout@v4
+ - name: Check code with ruff
+ run: |
+ pip install ruff
+ ruff check --output-format=github source
- name: Build dockers
run: |
# TODO using the environment file from tests to build here.
From 78087f1744e1a54652398ceb032197a0049c7874 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Fri, 6 Dec 2024 10:10:26 +0100
Subject: [PATCH 02/37] Using ruff action instead
---
.github/workflows/ci.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 8643401ce..26a6240ad 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -28,9 +28,9 @@ jobs:
- name: Check out iris
uses: actions/checkout@v4
- name: Check code with ruff
- run: |
- pip install ruff
- ruff check --output-format=github source
+ uses: astral-sh/ruff-action@v2
+ with:
+ src: "./source"
- name: Build dockers
run: |
# TODO using the environment file from tests to build here.
From bf38a9390d46969ae29cc0f9528124eaab493a4e Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Fri, 6 Dec 2024 10:18:29 +0100
Subject: [PATCH 03/37] Configuring github format for ruff
---
.github/workflows/ci.yml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 26a6240ad..d52f6b0d6 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -30,7 +30,8 @@ jobs:
- name: Check code with ruff
uses: astral-sh/ruff-action@v2
with:
- src: "./source"
+ args: check --output-format=github
+ src: ./source
- name: Build dockers
run: |
# TODO using the environment file from tests to build here.
From d246ce091ba270901c2a88030cc2587424902c62 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Fri, 6 Dec 2024 10:49:24 +0100
Subject: [PATCH 04/37] Ignore ruff rules which fail so far
---
pyproject.toml | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 pyproject.toml
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 000000000..8b1371ece
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,2 @@
+[tool.ruff.lint]
+ignore = ["E402", "E711", "E712", "E721", "E722", "F401", "F403", "F541", "F821", "F841"]
From 8e284e7001a333d11d5c1f345e71238fe4db4ed0 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Fri, 6 Dec 2024 13:55:30 +0100
Subject: [PATCH 05/37] Activate ruff rule F541 and fix
---
pyproject.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyproject.toml b/pyproject.toml
index 8b1371ece..b8068802f 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,2 +1,2 @@
[tool.ruff.lint]
-ignore = ["E402", "E711", "E712", "E721", "E722", "F401", "F403", "F541", "F821", "F841"]
+ignore = ["E402", "E711", "E712", "E721", "E722", "F401", "F403", "F821", "F841"]
From e4d4cc6f6485a5e314003ee53a615e54468bdbcc Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Tue, 10 Dec 2024 13:30:14 +0100
Subject: [PATCH 06/37] Removed seemingly dead method
---
.../app/iris_engine/access_control/utils.py | 186 ------------------
1 file changed, 186 deletions(-)
diff --git a/source/app/iris_engine/access_control/utils.py b/source/app/iris_engine/access_control/utils.py
index 792f53649..b5718b614 100644
--- a/source/app/iris_engine/access_control/utils.py
+++ b/source/app/iris_engine/access_control/utils.py
@@ -880,192 +880,6 @@ def ac_trace_user_effective_cases_access_2(user_id):
return effective_cases_access
-def ac_trace_case_access(case_id):
-
- case = Cases.query.with_entities(
- Cases.case_id,
- Cases.name
- ).filter(
- Cases.case_id == case_id
- ).first()
-
- if not case:
- return {}
-
- ocas = OrganisationCaseAccess.query.with_entities(
- Organisation.org_name,
- Organisation.org_id,
- Organisation.org_uuid,
- OrganisationCaseAccess.access_level,
- User.id.label('user_id'),
- User.name.label('user_name'),
- User.email.label('user_email'),
- User.uuid.label('user_uuid')
- ).filter(
- and_(OrganisationCaseAccess.case_id == case.case_id,
- OrganisationCaseAccess.org_id == UserOrganisation.org_id)
- ).join(
- OrganisationCaseAccess.org,
- UserOrganisation.user
- ).all()
-
- gcas = GroupCaseAccess.query.with_entities(
- Group.group_name,
- Group.group_id,
- Group.group_uuid,
- GroupCaseAccess.access_level,
- User.id.label('user_id'),
- User.name.label('user_name'),
- User.email.label('user_email'),
- User.uuid.label('user_uuid')
- ).filter(
- and_(GroupCaseAccess.case_id == case.case_id,
- UserGroup.group_id == GroupCaseAccess.group_id)
- ).join(
- GroupCaseAccess.group,
- UserGroup.user
- ).all()
-
- ucas = UserCaseAccess.query.with_entities(
- User.id.label('user_id'),
- User.name.label('user_name'),
- User.uuid.label('user_uuid'),
- User.email.label('user_email'),
- UserCaseAccess.access_level
- ).filter(
- and_(UserCaseAccess.case_id == case.case_id)
- ).join(
- UserCaseAccess.user
- ).all()
-
- case_access = {}
-
- for uca in ucas:
- user = {
- 'access_trace': [],
- 'user_effective_access': 0,
- 'user_effective_access_list': [],
- 'user_info': {
- 'user_name': uca.user_name,
- 'user_uuid': uca.user_uuid,
- 'user_email': uca.user_email
- }
- }
- for ac_l in CaseAccessLevel:
-
- if uca:
- if ac_flag_match_mask(uca.access_level, ac_l.value):
- user['user_effective_access'] |= uca.access_level
- user['access_trace'].append({
- 'state': 'Effective',
- 'name': ac_l.name,
- 'value': ac_l.value,
- 'inherited_from': {
- 'object_type': 'user_access_level',
- 'object_name': 'self',
- 'object_id': 'self',
- 'object_uuid': 'self'
- }
- })
- user['user_effective_access_list'].append(ac_l.name)
- has_uca_overwritten = True
- if ac_l.value == CaseAccessLevel.deny_all.value:
- has_uca_deny_all = True
-
- if uca.user_id not in case_access:
- case_access.update({
- uca.user_id: user
- })
-
- for gca in gcas:
- if gca.user_id not in case_access:
- user = {
- 'access_trace': [],
- 'user_effective_access': 0,
- 'user_effective_access_list': [],
- 'user_info': {
- 'user_name': gca.user_name,
- 'user_uuid': gca.user_uuid,
- 'user_email': gca.user_email
- }
- }
- else:
- user = case_access[gca.user_id]
-
- for ac_l in CaseAccessLevel:
-
- if gca:
- if ac_flag_match_mask(gca.access_level, ac_l.value):
- if gca.user_id not in case_access:
- user['user_effective_access'] |= gca.access_level
- user['user_effective_access_list'].append(ac_l.name)
- state = 'Effective'
- else:
- state = 'Overwritten by user access'
-
- user['access_trace'].append({
- 'state': state,
- 'name': ac_l.name,
- 'value': ac_l.value,
- 'inherited_from': {
- 'object_type': 'group_access_level',
- 'object_name': gca.group_name,
- 'object_id': gca.group_id,
- 'object_uuid': gca.group_uuid
- }
- })
-
- if gca.user_id not in case_access:
- case_access.update({
- gca.user_id: user
- })
-
- for oca in ocas:
- if oca.user_id not in case_access:
- user = {
- 'access_trace': [],
- 'user_effective_access': 0,
- 'user_effective_access_list': [],
- 'user_info': {
- 'user_name': oca.user_name,
- 'user_uuid': oca.user_uuid,
- 'user_email': oca.user_email
- }
- }
- else:
- user = case_access[oca.user_id]
-
- for ac_l in CaseAccessLevel:
-
- if oca:
- if ac_flag_match_mask(oca.access_level, ac_l.value):
- if oca.user_id not in case_access:
- user['user_effective_access'] |= oca.access_level
- user['user_effective_access_list'].append(ac_l.name)
- state = 'Effective'
- else:
- state = 'Overwritten by user or group access'
-
- user['access_trace'].append({
- 'state': state,
- 'name': ac_l.name,
- 'value': ac_l.value,
- 'inherited_from': {
- 'object_type': 'organisation_access_level',
- 'object_name': oca.org_name,
- 'object_id': oca.org_id,
- 'object_uuid': oca.org_uuid
- }
- })
-
- if oca.user_id not in case_access:
- case_access.update({
- oca.user_id: user
- })
-
- return case_access
-
-
def ac_get_mask_case_access_level_full():
"""
Return a mask for full access level
From fe8cd539cdbf276b4ed17718b2503817ebda886e Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Tue, 10 Dec 2024 14:26:40 +0100
Subject: [PATCH 07/37] Removed unused variables
---
source/app/iris_engine/reporter/reporter.py | 4 ----
1 file changed, 4 deletions(-)
diff --git a/source/app/iris_engine/reporter/reporter.py b/source/app/iris_engine/reporter/reporter.py
index 0211acefc..e589e86a6 100644
--- a/source/app/iris_engine/reporter/reporter.py
+++ b/source/app/iris_engine/reporter/reporter.py
@@ -165,8 +165,6 @@ def get_case_timeline(caseid):
CasesEvent.event_date
).all()
- cache_id = {}
- ras = {}
tim = []
for row in timeline:
ras = row
@@ -410,8 +408,6 @@ def get_case_timeline(caseid):
CasesEvent.event_date
).all()
- cache_id = {}
- ras = {}
tim = []
for row in timeline:
ras = row
From b8f6887f0d0cb441fdc7abf8de74b42a9cc50829 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Tue, 10 Dec 2024 14:27:13 +0100
Subject: [PATCH 08/37] Removed seemingly unused class
---
source/app/iris_engine/reporter/reporter.py | 28 ---------------------
1 file changed, 28 deletions(-)
diff --git a/source/app/iris_engine/reporter/reporter.py b/source/app/iris_engine/reporter/reporter.py
index e589e86a6..ee475344d 100644
--- a/source/app/iris_engine/reporter/reporter.py
+++ b/source/app/iris_engine/reporter/reporter.py
@@ -567,31 +567,3 @@ def generate_md_report(self, doc_type):
return None, e.__str__()
return output_file_path, 'Report generated'
-
-
-class QueuingHandler(log.Handler):
- """A thread safe logging.Handler that writes messages into a queue object.
-
- Designed to work with LoggingWidget so log messages from multiple
- threads can be shown together in a single ttk.Frame.
-
- The standard logging.QueueHandler/logging.QueueListener can not be used
- for this because the QueueListener runs in a private thread, not the
- main thread.
-
- Warning: If multiple threads are writing into this Handler, all threads
- must be joined before calling logging.shutdown() or any other log
- destinations will be corrupted.
- """
-
- def __init__(self, *args, task_self, message_queue, **kwargs):
- """Initialize by copying the queue and sending everything else to superclass."""
- log.Handler.__init__(self, *args, **kwargs)
- self.message_queue = message_queue
- self.task_self = task_self
-
- def emit(self, record):
- """Add the formatted log message (sans newlines) to the queue."""
- self.message_queue.append(self.format(record).rstrip('\n'))
- self.task_self.update_state(state='PROGRESS',
- meta=list(self.message_queue))
From bf9eee5fc3cded656a9df0528d49d571dc37ff86 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Tue, 10 Dec 2024 14:34:17 +0100
Subject: [PATCH 09/37] Removed seemingly unnecessary statement
---
source/tests/performance/test_burst_db_interaction.py | 2 --
1 file changed, 2 deletions(-)
diff --git a/source/tests/performance/test_burst_db_interaction.py b/source/tests/performance/test_burst_db_interaction.py
index d523f3dfd..ea8cb4e9b 100644
--- a/source/tests/performance/test_burst_db_interaction.py
+++ b/source/tests/performance/test_burst_db_interaction.py
@@ -157,8 +157,6 @@ def random_date(start, end):
@staticmethod
def update_dates():
- d1 = datetime.strptime('1/1/2008 1:30 PM', '%m/%d/%Y %I:%M %p')
- d2 = datetime.strptime('12/12/2021 4:50 AM', '%m/%d/%Y %I:%M %p')
events = CasesEvent.query.all()
for event in events:
event.event_date = datetime.utcnow()
From 0501a04392d3ea0bc361e3f04bd465fa2bd5045b Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Wed, 11 Dec 2024 13:14:35 +0100
Subject: [PATCH 10/37] Spacing
---
.../blueprints/pages/dim_tasks/templates/modal_task_info.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source/app/blueprints/pages/dim_tasks/templates/modal_task_info.html b/source/app/blueprints/pages/dim_tasks/templates/modal_task_info.html
index 6aec5cb24..d3fb9b686 100644
--- a/source/app/blueprints/pages/dim_tasks/templates/modal_task_info.html
+++ b/source/app/blueprints/pages/dim_tasks/templates/modal_task_info.html
@@ -8,7 +8,7 @@
{{ data[element] }}
- {% endif %}
+ {% endif %}
{% endif %}
{% endfor %}
From 20ff7bfcfeb73d40e506b38c1ff32a54331886b8 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Wed, 11 Dec 2024 13:27:16 +0100
Subject: [PATCH 11/37] Converted double quotes into simple quotes
---
source/app/blueprints/pages/dim_tasks/dim_tasks.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/source/app/blueprints/pages/dim_tasks/dim_tasks.py b/source/app/blueprints/pages/dim_tasks/dim_tasks.py
index f073f647d..5824a6c4c 100644
--- a/source/app/blueprints/pages/dim_tasks/dim_tasks.py
+++ b/source/app/blueprints/pages/dim_tasks/dim_tasks.py
@@ -54,7 +54,7 @@ def dim_index(caseid: int, url_redir):
@ac_case_requires(CaseAccessLevel.read_only, CaseAccessLevel.full_access)
def task_status(task_id, caseid, url_redir):
if url_redir:
- return response_error("Invalid request")
+ return response_error('Invalid request')
task = app.celery.AsyncResult(task_id)
@@ -68,13 +68,13 @@ def task_status(task_id, caseid, url_redir):
'Additional information': 'The results of this tasks were stored in a pickled Class which does not exists '
'anymore in current IRIS version.'
}
- return render_template("modal_task_info.html", data=task_info, task_id=task.id)
+ return render_template('modal_task_info.html', data=task_info, task_id=task.id)
task_info = {
'Task ID': task_id,
'Task finished on': task.date_done,
'Task state': task.state.lower(),
- 'Engine': task.name if task.name else "No engine. Unrecoverable shadow failure"}
+ 'Engine': task.name if task.name else 'No engine. Unrecoverable shadow failure'}
task_meta = task._get_task_meta()
@@ -91,12 +91,12 @@ def task_status(task_id, caseid, url_redir):
else:
success = None
- task_info['User'] = "Shadow Iris"
+ task_info['User'] = 'Shadow Iris'
task_info['Logs'] = ['Task did not returned a valid IIStatus object']
if task_meta.get('traceback'):
task_info['Traceback'] = task.traceback
- task_info['Success'] = "Success" if success else "Failure"
+ task_info['Success'] = 'Success' if success else 'Failure'
- return render_template("modal_task_info.html", data=task_info, task_id=task.id)
+ return render_template('modal_task_info.html', data=task_info, task_id=task.id)
From 0eb34498a020e4cfa4904c5dc41872b4787c1666 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Wed, 11 Dec 2024 13:58:00 +0100
Subject: [PATCH 12/37] Remove unnecessary variable in rendering
---
source/app/blueprints/pages/dim_tasks/dim_tasks.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source/app/blueprints/pages/dim_tasks/dim_tasks.py b/source/app/blueprints/pages/dim_tasks/dim_tasks.py
index 5824a6c4c..14992901b 100644
--- a/source/app/blueprints/pages/dim_tasks/dim_tasks.py
+++ b/source/app/blueprints/pages/dim_tasks/dim_tasks.py
@@ -68,7 +68,7 @@ def task_status(task_id, caseid, url_redir):
'Additional information': 'The results of this tasks were stored in a pickled Class which does not exists '
'anymore in current IRIS version.'
}
- return render_template('modal_task_info.html', data=task_info, task_id=task.id)
+ return render_template('modal_task_info.html', data=task_info)
task_info = {
'Task ID': task_id,
@@ -99,4 +99,4 @@ def task_status(task_id, caseid, url_redir):
task_info['Success'] = 'Success' if success else 'Failure'
- return render_template('modal_task_info.html', data=task_info, task_id=task.id)
+ return render_template('modal_task_info.html', data=task_info)
From f6d95a6fcaa2e4550185603dffc2b48e88cb2618 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Wed, 11 Dec 2024 13:59:38 +0100
Subject: [PATCH 13/37] Extract method
---
.../blueprints/pages/dim_tasks/dim_tasks.py | 24 +++++++++++--------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/source/app/blueprints/pages/dim_tasks/dim_tasks.py b/source/app/blueprints/pages/dim_tasks/dim_tasks.py
index 14992901b..55ae5aa77 100644
--- a/source/app/blueprints/pages/dim_tasks/dim_tasks.py
+++ b/source/app/blueprints/pages/dim_tasks/dim_tasks.py
@@ -50,28 +50,22 @@ def dim_index(caseid: int, url_redir):
return render_template('dim_tasks.html', form=form)
-@dim_tasks_blueprint.route('/dim/tasks/status/', methods=['GET'])
-@ac_case_requires(CaseAccessLevel.read_only, CaseAccessLevel.full_access)
-def task_status(task_id, caseid, url_redir):
- if url_redir:
- return response_error('Invalid request')
-
- task = app.celery.AsyncResult(task_id)
+def _get_task(task_identifier):
+ task = app.celery.AsyncResult(task_identifier)
try:
tinfo = task.info
except AttributeError:
# Legacy task
- task_info = {
+ return {
'Danger': 'This task was executed in a previous version of IRIS and the status cannot be read anymore.',
'Note': 'All the data readable by the current IRIS version is displayed in the table.',
'Additional information': 'The results of this tasks were stored in a pickled Class which does not exists '
'anymore in current IRIS version.'
}
- return render_template('modal_task_info.html', data=task_info)
task_info = {
- 'Task ID': task_id,
+ 'Task ID': task_identifier,
'Task finished on': task.date_done,
'Task state': task.state.lower(),
'Engine': task.name if task.name else 'No engine. Unrecoverable shadow failure'}
@@ -99,4 +93,14 @@ def task_status(task_id, caseid, url_redir):
task_info['Success'] = 'Success' if success else 'Failure'
+ return task_info
+
+
+@dim_tasks_blueprint.route('/dim/tasks/status/', methods=['GET'])
+@ac_case_requires(CaseAccessLevel.read_only, CaseAccessLevel.full_access)
+def task_status(task_id, caseid, url_redir):
+ if url_redir:
+ return response_error('Invalid request')
+
+ task_info = _get_task(task_id)
return render_template('modal_task_info.html', data=task_info)
From 7752683902b0bf93742ebacfc10887e66f9bb621 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Wed, 11 Dec 2024 14:02:10 +0100
Subject: [PATCH 14/37] Moved method to get dim task down into the business
layer
---
.../blueprints/pages/dim_tasks/dim_tasks.py | 53 ++-------------
source/app/business/dim_tasks.py | 66 +++++++++++++++++++
2 files changed, 70 insertions(+), 49 deletions(-)
create mode 100644 source/app/business/dim_tasks.py
diff --git a/source/app/blueprints/pages/dim_tasks/dim_tasks.py b/source/app/blueprints/pages/dim_tasks/dim_tasks.py
index 55ae5aa77..423d89567 100644
--- a/source/app/blueprints/pages/dim_tasks/dim_tasks.py
+++ b/source/app/blueprints/pages/dim_tasks/dim_tasks.py
@@ -26,9 +26,10 @@
import app
from app.models.authorization import CaseAccessLevel
from app.models.authorization import Permissions
-from app.blueprints.access_controls import ac_case_requires, ac_requires
+from app.blueprints.access_controls import ac_case_requires
+from app.blueprints.access_controls import ac_requires
from app.blueprints.responses import response_error
-from iris_interface.IrisInterfaceStatus import IIStatus
+from app.business.dim_tasks import dim_tasks_get
dim_tasks_blueprint = Blueprint(
'dim_tasks',
@@ -50,57 +51,11 @@ def dim_index(caseid: int, url_redir):
return render_template('dim_tasks.html', form=form)
-def _get_task(task_identifier):
- task = app.celery.AsyncResult(task_identifier)
-
- try:
- tinfo = task.info
- except AttributeError:
- # Legacy task
- return {
- 'Danger': 'This task was executed in a previous version of IRIS and the status cannot be read anymore.',
- 'Note': 'All the data readable by the current IRIS version is displayed in the table.',
- 'Additional information': 'The results of this tasks were stored in a pickled Class which does not exists '
- 'anymore in current IRIS version.'
- }
-
- task_info = {
- 'Task ID': task_identifier,
- 'Task finished on': task.date_done,
- 'Task state': task.state.lower(),
- 'Engine': task.name if task.name else 'No engine. Unrecoverable shadow failure'}
-
- task_meta = task._get_task_meta()
-
- if task_meta.get('name') \
- and ('task_hook_wrapper' in task_meta.get('name') or 'pipeline_dispatcher' in task_meta.get('name')):
- task_info['Module name'] = task_meta.get('kwargs').get('module_name')
- task_info['Hook name'] = task_meta.get('kwargs').get('hook_name')
- task_info['User'] = task_meta.get('kwargs').get('init_user')
- task_info['Case ID'] = task_meta.get('kwargs').get('caseid')
-
- if isinstance(task.info, IIStatus):
- success = task.info.is_success()
- task_info['Logs'] = task.info.get_logs()
-
- else:
- success = None
- task_info['User'] = 'Shadow Iris'
- task_info['Logs'] = ['Task did not returned a valid IIStatus object']
-
- if task_meta.get('traceback'):
- task_info['Traceback'] = task.traceback
-
- task_info['Success'] = 'Success' if success else 'Failure'
-
- return task_info
-
-
@dim_tasks_blueprint.route('/dim/tasks/status/', methods=['GET'])
@ac_case_requires(CaseAccessLevel.read_only, CaseAccessLevel.full_access)
def task_status(task_id, caseid, url_redir):
if url_redir:
return response_error('Invalid request')
- task_info = _get_task(task_id)
+ task_info = dim_tasks_get(task_id)
return render_template('modal_task_info.html', data=task_info)
diff --git a/source/app/business/dim_tasks.py b/source/app/business/dim_tasks.py
new file mode 100644
index 000000000..9d5edb521
--- /dev/null
+++ b/source/app/business/dim_tasks.py
@@ -0,0 +1,66 @@
+# 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 import celery
+from iris_interface.IrisInterfaceStatus import IIStatus
+
+
+def dim_tasks_get(task_identifier):
+ task = celery.AsyncResult(task_identifier)
+
+ try:
+ tinfo = task.info
+ except AttributeError:
+ # Legacy task
+ return {
+ 'Danger': 'This task was executed in a previous version of IRIS and the status cannot be read anymore.',
+ 'Note': 'All the data readable by the current IRIS version is displayed in the table.',
+ 'Additional information': 'The results of this tasks were stored in a pickled Class which does not exists '
+ 'anymore in current IRIS version.'
+ }
+
+ task_info = {
+ 'Task ID': task_identifier,
+ 'Task finished on': task.date_done,
+ 'Task state': task.state.lower(),
+ 'Engine': task.name if task.name else 'No engine. Unrecoverable shadow failure'}
+
+ task_meta = task._get_task_meta()
+
+ if task_meta.get('name') \
+ and ('task_hook_wrapper' in task_meta.get('name') or 'pipeline_dispatcher' in task_meta.get('name')):
+ task_info['Module name'] = task_meta.get('kwargs').get('module_name')
+ task_info['Hook name'] = task_meta.get('kwargs').get('hook_name')
+ task_info['User'] = task_meta.get('kwargs').get('init_user')
+ task_info['Case ID'] = task_meta.get('kwargs').get('caseid')
+
+ if isinstance(task.info, IIStatus):
+ success = task.info.is_success()
+ task_info['Logs'] = task.info.get_logs()
+
+ else:
+ success = None
+ task_info['User'] = 'Shadow Iris'
+ task_info['Logs'] = ['Task did not returned a valid IIStatus object']
+
+ if task_meta.get('traceback'):
+ task_info['Traceback'] = task.traceback
+
+ task_info['Success'] = 'Success' if success else 'Failure'
+
+ return task_info
From 31b818c5ce3bc2a562cfca5c2e1978fa30955f58 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Fri, 13 Dec 2024 08:46:42 +0100
Subject: [PATCH 15/37] replaced let by const
---
e2e/tests/administrator/case/ioc.spec.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/e2e/tests/administrator/case/ioc.spec.js b/e2e/tests/administrator/case/ioc.spec.js
index 152ff6525..def22454d 100644
--- a/e2e/tests/administrator/case/ioc.spec.js
+++ b/e2e/tests/administrator/case/ioc.spec.js
@@ -46,7 +46,7 @@ test('should paginate the IOCs', async ({ page, rest }) => {
const caseName = `Case - ${crypto.randomUUID()}`;
// TODO maybe should remove cases between each tests (like in the backend tests)
- let response = await rest.post('/api/v2/cases', {
+ const response = await rest.post('/api/v2/cases', {
data: {
case_name: caseName,
case_description: 'Case description',
From 7fc77d9e68c0f0779cfccdf96cbce86e0f5be039 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Fri, 13 Dec 2024 10:09:31 +0100
Subject: [PATCH 16/37] Added first end to end test on DIM tasks
---
e2e/tests/administrator/case/ioc.spec.js | 14 ++--------
e2e/tests/administrator/dim/tasks.spec.js | 33 +++++++++++++++++++++++
e2e/tests/api.js | 20 ++++++++++++++
3 files changed, 55 insertions(+), 12 deletions(-)
create mode 100644 e2e/tests/administrator/dim/tasks.spec.js
create mode 100644 e2e/tests/api.js
diff --git a/e2e/tests/administrator/case/ioc.spec.js b/e2e/tests/administrator/case/ioc.spec.js
index def22454d..65a226965 100644
--- a/e2e/tests/administrator/case/ioc.spec.js
+++ b/e2e/tests/administrator/case/ioc.spec.js
@@ -1,5 +1,6 @@
import { test } from '../../restFixture.js';
import { expect } from '@playwright/test';
+import Api from '../../api.js';
import crypto from 'node:crypto';
test.beforeEach(async({ page }) => {
@@ -43,18 +44,7 @@ test('should not be able to create an IOC with the same type and value', async (
});
test('should paginate the IOCs', async ({ page, rest }) => {
- const caseName = `Case - ${crypto.randomUUID()}`;
-
- // TODO maybe should remove cases between each tests (like in the backend tests)
- const response = await rest.post('/api/v2/cases', {
- data: {
- case_name: caseName,
- case_description: 'Case description',
- case_customer: 1,
- case_soc_id: ''
- }
- });
- const caseIdentifier = (await response.json()).case_id;
+ const caseIdentifier = await Api.createCase(rest);
for (let i = 0; i < 11; i++) {
await rest.post(`/api/v2/cases/${caseIdentifier}/iocs`, {
data: {
diff --git a/e2e/tests/administrator/dim/tasks.spec.js b/e2e/tests/administrator/dim/tasks.spec.js
new file mode 100644
index 000000000..60e970f04
--- /dev/null
+++ b/e2e/tests/administrator/dim/tasks.spec.js
@@ -0,0 +1,33 @@
+import { test } from '../../restFixture.js';
+import { expect } from '@playwright/test';
+import Api from '../../api.js';
+import crypto from 'node:crypto';
+
+let api;
+
+test.beforeEach(async ({ page, rest }) => {
+ await page.goto('/dim/tasks');
+});
+
+test('should be able to consult task info', async ({ page, rest }) => {
+ let response = await rest.get('/manage/modules/list');
+ const modules = (await response.json()).data;
+ const irisCheckModule = modules.find(module => module.module_human_name === 'IrisCheck');
+ response = await rest.post(`/manage/modules/enable/${irisCheckModule.id}`);
+ const caseIdentifier = await Api.createCase(rest);
+ await rest.delete(`/api/v2/cases/${caseIdentifier}`);
+
+ await page.goto('/dim/tasks');
+ // filter 'Case' column with the case identifier
+ // TODO should make the more interface testable to be able to use some page.getByRole
+ await page.locator('th:nth-child(4) > .form-group > .form-control').fill(caseIdentifier.toString());
+ // filter 'Processing module' column with on_postload_case_delete
+ // TODO should make the more interface testable to be able to use some page.getByRole
+ await page.locator('th:nth-child(5) > .form-group > .form-control').fill('on_postload_case_delete');
+ // TODO should make the more interface testable to be able to use some page.getByRole
+ await page.locator('td').getByRole('link').click();
+ await expect(page.locator('#info_dim_task_modal_body')).toContainText(`Case ID: ${caseIdentifier}`);
+ await expect(page.locator('#info_dim_task_modal_body')).toContainText('Hook name: on_postload_case_delete');
+ await expect(page.locator('#info_dim_task_modal_body')).toContainText('Module name: iris_check_module');
+ await expect(page.locator('#info_dim_task_modal_body')).toContainText('User: administrator');
+});
diff --git a/e2e/tests/api.js b/e2e/tests/api.js
new file mode 100644
index 000000000..b536d038d
--- /dev/null
+++ b/e2e/tests/api.js
@@ -0,0 +1,20 @@
+import crypto from 'node:crypto';
+
+const createCase = async (rest) => {
+ const caseName = `Case - ${crypto.randomUUID()}`;
+
+ // TODO maybe should remove cases between each tests (like in the backend tests)
+ const response = await rest.post('/api/v2/cases', {
+ data: {
+ case_name: caseName,
+ case_description: 'Case description',
+ case_customer: 1,
+ case_soc_id: ''
+ }
+ });
+ return (await response.json()).case_id;
+};
+
+export default {
+ createCase
+}
\ No newline at end of file
From 47204ef522237670c26176dcf38a3e10a944e10a Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Fri, 13 Dec 2024 10:10:01 +0100
Subject: [PATCH 17/37] Avoid call to private method
---
source/app/business/dim_tasks.py | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/source/app/business/dim_tasks.py b/source/app/business/dim_tasks.py
index 9d5edb521..b4a49fde7 100644
--- a/source/app/business/dim_tasks.py
+++ b/source/app/business/dim_tasks.py
@@ -40,14 +40,11 @@ def dim_tasks_get(task_identifier):
'Task state': task.state.lower(),
'Engine': task.name if task.name else 'No engine. Unrecoverable shadow failure'}
- task_meta = task._get_task_meta()
-
- if task_meta.get('name') \
- and ('task_hook_wrapper' in task_meta.get('name') or 'pipeline_dispatcher' in task_meta.get('name')):
- task_info['Module name'] = task_meta.get('kwargs').get('module_name')
- task_info['Hook name'] = task_meta.get('kwargs').get('hook_name')
- task_info['User'] = task_meta.get('kwargs').get('init_user')
- task_info['Case ID'] = task_meta.get('kwargs').get('caseid')
+ if task.name and ('task_hook_wrapper' in task.name or 'pipeline_dispatcher' in task.name):
+ task_info['Module name'] = task.kwargs.get('module_name')
+ task_info['Hook name'] = task.kwargs.get('hook_name')
+ task_info['User'] = task.kwargs.get('init_user')
+ task_info['Case ID'] = task.kwargs.get('caseid')
if isinstance(task.info, IIStatus):
success = task.info.is_success()
@@ -58,7 +55,7 @@ def dim_tasks_get(task_identifier):
task_info['User'] = 'Shadow Iris'
task_info['Logs'] = ['Task did not returned a valid IIStatus object']
- if task_meta.get('traceback'):
+ if task.traceback:
task_info['Traceback'] = task.traceback
task_info['Success'] = 'Success' if success else 'Failure'
From ce03f4155350c71f0c596c6b28d2d58639e73994 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Fri, 13 Dec 2024 10:57:06 +0100
Subject: [PATCH 18/37] Fixed end to end tests for chromium
---
e2e/tests/administrator/alerts.spec.js | 1 +
e2e/tests/administrator/dim/tasks.spec.js | 8 ++++++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/e2e/tests/administrator/alerts.spec.js b/e2e/tests/administrator/alerts.spec.js
index a66eb966c..bd41e68b8 100644
--- a/e2e/tests/administrator/alerts.spec.js
+++ b/e2e/tests/administrator/alerts.spec.js
@@ -17,5 +17,6 @@ test('should present the alert', async ({ page, rest }) => {
alert_customer_id: 1
}
});
+ await page.getByRole('button', { name: 'Refresh', exact: true }).click();
await expect(page.getByRole('heading', { name: alertTitle })).toBeVisible();
});
\ No newline at end of file
diff --git a/e2e/tests/administrator/dim/tasks.spec.js b/e2e/tests/administrator/dim/tasks.spec.js
index 60e970f04..8f494607c 100644
--- a/e2e/tests/administrator/dim/tasks.spec.js
+++ b/e2e/tests/administrator/dim/tasks.spec.js
@@ -26,8 +26,12 @@ test('should be able to consult task info', async ({ page, rest }) => {
await page.locator('th:nth-child(5) > .form-group > .form-control').fill('on_postload_case_delete');
// TODO should make the more interface testable to be able to use some page.getByRole
await page.locator('td').getByRole('link').click();
- await expect(page.locator('#info_dim_task_modal_body')).toContainText(`Case ID: ${caseIdentifier}`);
- await expect(page.locator('#info_dim_task_modal_body')).toContainText('Hook name: on_postload_case_delete');
+ // TODO this click should not be necessary. However, when run on the chromium browser, it seem the first click is ignored
+ // => there is probably a bug in the code to chase
+ await page.locator('td').getByRole('link').click();
+
await expect(page.locator('#info_dim_task_modal_body')).toContainText('Module name: iris_check_module');
+ await expect(page.locator('#info_dim_task_modal_body')).toContainText('Hook name: on_postload_case_delete');
await expect(page.locator('#info_dim_task_modal_body')).toContainText('User: administrator');
+ await expect(page.locator('#info_dim_task_modal_body')).toContainText(`Case ID: ${caseIdentifier}`);
});
From 9cf8b7f4fce2bd29cc854649112366f353f985dc Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Fri, 13 Dec 2024 11:28:02 +0100
Subject: [PATCH 19/37] Added an optional action based on the browser on which
it is run
---
e2e/tests/administrator/dim/tasks.spec.js | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/e2e/tests/administrator/dim/tasks.spec.js b/e2e/tests/administrator/dim/tasks.spec.js
index 8f494607c..b0d4346a1 100644
--- a/e2e/tests/administrator/dim/tasks.spec.js
+++ b/e2e/tests/administrator/dim/tasks.spec.js
@@ -9,7 +9,7 @@ test.beforeEach(async ({ page, rest }) => {
await page.goto('/dim/tasks');
});
-test('should be able to consult task info', async ({ page, rest }) => {
+test('should be able to consult task info', async ({ page, rest, browserName }) => {
let response = await rest.get('/manage/modules/list');
const modules = (await response.json()).data;
const irisCheckModule = modules.find(module => module.module_human_name === 'IrisCheck');
@@ -26,9 +26,11 @@ test('should be able to consult task info', async ({ page, rest }) => {
await page.locator('th:nth-child(5) > .form-group > .form-control').fill('on_postload_case_delete');
// TODO should make the more interface testable to be able to use some page.getByRole
await page.locator('td').getByRole('link').click();
- // TODO this click should not be necessary. However, when run on the chromium browser, it seem the first click is ignored
- // => there is probably a bug in the code to chase
- await page.locator('td').getByRole('link').click();
+ if (browserName === 'chromium') {
+ // TODO this click should not be necessary. However, when run on the chromium browser, it seem the first click is ignored
+ // => there is probably a bug in the code to chase
+ await page.locator('td').getByRole('link').click();
+ }
await expect(page.locator('#info_dim_task_modal_body')).toContainText('Module name: iris_check_module');
await expect(page.locator('#info_dim_task_modal_body')).toContainText('Hook name: on_postload_case_delete');
From 891e9a893c3ba775bcc1eef6a99647bdfd04ae65 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Fri, 13 Dec 2024 13:29:33 +0100
Subject: [PATCH 20/37] Added TODO
---
e2e/tests/administrator/case/ioc.spec.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/e2e/tests/administrator/case/ioc.spec.js b/e2e/tests/administrator/case/ioc.spec.js
index 65a226965..f29d1aeba 100644
--- a/e2e/tests/administrator/case/ioc.spec.js
+++ b/e2e/tests/administrator/case/ioc.spec.js
@@ -7,6 +7,8 @@ test.beforeEach(async({ page }) => {
await page.goto('/case/ioc?cid=1');
});
+// TODO should maybe remove all iocs between each tests: there is a risk we reach the pagination limit
+
test('should be able to update IOC', async ({ page }) => {
const iocValue = `IOC value - ${crypto.randomUUID()}`;
From b5cf4609f7b92760b295d5096953e702b6712624 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Fri, 13 Dec 2024 17:31:33 +0100
Subject: [PATCH 21/37] Cleaning up code of dim_tasks_get
---
source/app/business/dim_tasks.py | 71 ++++++++++++++++++++------------
1 file changed, 45 insertions(+), 26 deletions(-)
diff --git a/source/app/business/dim_tasks.py b/source/app/business/dim_tasks.py
index b4a49fde7..7273fe82f 100644
--- a/source/app/business/dim_tasks.py
+++ b/source/app/business/dim_tasks.py
@@ -20,13 +20,27 @@
from iris_interface.IrisInterfaceStatus import IIStatus
-def dim_tasks_get(task_identifier):
- task = celery.AsyncResult(task_identifier)
+def _get_engine_name(task):
+ if not task.name:
+ return 'No engine. Unrecoverable shadow failure'
+ return task.name
+def _get_success(task_result: IIStatus):
+ if task_result.is_success():
+ return 'Success'
+ else:
+ return 'Failure'
+
+def dim_tasks_is_legacy(task):
try:
- tinfo = task.info
+ _ = task.info
+ return False
except AttributeError:
- # Legacy task
+ return True
+
+def dim_tasks_get(task_identifier):
+ task = celery.AsyncResult(task_identifier)
+ if dim_tasks_is_legacy(task):
return {
'Danger': 'This task was executed in a previous version of IRIS and the status cannot be read anymore.',
'Note': 'All the data readable by the current IRIS version is displayed in the table.',
@@ -34,30 +48,35 @@ def dim_tasks_get(task_identifier):
'anymore in current IRIS version.'
}
- task_info = {
- 'Task ID': task_identifier,
- 'Task finished on': task.date_done,
- 'Task state': task.state.lower(),
- 'Engine': task.name if task.name else 'No engine. Unrecoverable shadow failure'}
-
+ engine_name = _get_engine_name(task)
+ user = None
+ module_name = None
+ hook_name = None
+ case_identifier = None
if task.name and ('task_hook_wrapper' in task.name or 'pipeline_dispatcher' in task.name):
- task_info['Module name'] = task.kwargs.get('module_name')
- task_info['Hook name'] = task.kwargs.get('hook_name')
- task_info['User'] = task.kwargs.get('init_user')
- task_info['Case ID'] = task.kwargs.get('caseid')
+ module_name = task.kwargs.get('module_name')
+ hook_name = task.kwargs.get('hook_name')
+ user = task.kwargs.get('init_user')
+ case_identifier = task.kwargs.get('caseid')
if isinstance(task.info, IIStatus):
- success = task.info.is_success()
- task_info['Logs'] = task.info.get_logs()
-
+ success = _get_success(task.info)
+ logs = task.info.get_logs()
else:
- success = None
- task_info['User'] = 'Shadow Iris'
- task_info['Logs'] = ['Task did not returned a valid IIStatus object']
-
- if task.traceback:
- task_info['Traceback'] = task.traceback
+ success = 'Failure'
+ user = 'Shadow Iris'
+ logs = ['Task did not returned a valid IIStatus object']
- task_info['Success'] = 'Success' if success else 'Failure'
-
- return task_info
+ return {
+ 'Task ID': task_identifier,
+ 'Task finished on': task.date_done,
+ 'Task state': task.state.lower(),
+ 'Engine': engine_name,
+ 'Module name': module_name,
+ 'Hook name': hook_name,
+ 'Case ID': case_identifier,
+ 'Success': success,
+ 'User': user,
+ 'Logs': logs,
+ 'Traceback': task.traceback
+ }
From 985070727d3e8eba3aeebc47e14affcd53ffddf0 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Fri, 13 Dec 2024 17:47:50 +0100
Subject: [PATCH 22/37] Reusing method dim_tasks_is_legacy
---
source/app/blueprints/rest/dim_tasks_routes.py | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/source/app/blueprints/rest/dim_tasks_routes.py b/source/app/blueprints/rest/dim_tasks_routes.py
index 599fc2040..8e7820730 100644
--- a/source/app/blueprints/rest/dim_tasks_routes.py
+++ b/source/app/blueprints/rest/dim_tasks_routes.py
@@ -41,6 +41,7 @@
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.blueprints.responses import response_success
+from app.business.dim_tasks import dim_tasks_is_legacy
from iris_interface.IrisInterfaceStatus import IIStatus
dim_tasks_rest_blueprint = Blueprint('dim_tasks_rest', __name__)
@@ -186,10 +187,7 @@ def list_dim_tasks(count):
tkp = {'state': row.status, 'case': "Unknown", 'module': row.name, 'task_id': row.task_id, 'date_done': row.date_done, 'user': "Unknown"}
- try:
- _ = row.result
- except AttributeError:
- # Legacy task
+ if dim_tasks_is_legacy(row):
data.append(tkp)
continue
From e7fa4696665b6aab98b6a9df7fdc7ca69321ea24 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Fri, 13 Dec 2024 17:48:38 +0100
Subject: [PATCH 23/37] Activate F841
---
pyproject.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyproject.toml b/pyproject.toml
index b8068802f..e65af88b9 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,2 +1,2 @@
[tool.ruff.lint]
-ignore = ["E402", "E711", "E712", "E721", "E722", "F401", "F403", "F821", "F841"]
+ignore = ["E402", "E711", "E712", "E721", "E722", "F401", "F403", "F821"]
From b90180710b15aac5a07bb26345eab35e41d66e3b Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Fri, 13 Dec 2024 18:00:32 +0100
Subject: [PATCH 24/37] Removed unused imports
---
source/app/blueprints/rest/v2/case/api_v2_assets_routes.py | 1 -
source/app/iris_engine/access_control/utils.py | 3 ---
2 files changed, 4 deletions(-)
diff --git a/source/app/blueprints/rest/v2/case/api_v2_assets_routes.py b/source/app/blueprints/rest/v2/case/api_v2_assets_routes.py
index 07fb1d314..4fe7a7904 100644
--- a/source/app/blueprints/rest/v2/case/api_v2_assets_routes.py
+++ b/source/app/blueprints/rest/v2/case/api_v2_assets_routes.py
@@ -18,7 +18,6 @@
from flask import Blueprint
from flask import request
-from kombu.abstract import Object
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.rest.endpoints import response_api_created
diff --git a/source/app/iris_engine/access_control/utils.py b/source/app/iris_engine/access_control/utils.py
index b5718b614..d1599db72 100644
--- a/source/app/iris_engine/access_control/utils.py
+++ b/source/app/iris_engine/access_control/utils.py
@@ -11,14 +11,11 @@
from app.models.authorization import UserClient
from app.models.authorization import Group
from app.models.authorization import GroupCaseAccess
-from app.models.authorization import Organisation
-from app.models.authorization import OrganisationCaseAccess
from app.models.authorization import Permissions
from app.models.authorization import User
from app.models.authorization import UserCaseAccess
from app.models.authorization import UserCaseEffectiveAccess
from app.models.authorization import UserGroup
-from app.models.authorization import UserOrganisation
log = app.app.logger
From e9b610ded83ab6c79318906586d40bbd32d71589 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Fri, 13 Dec 2024 18:28:03 +0100
Subject: [PATCH 25/37] Two separate lines for imports
---
source/app/__init__.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/source/app/__init__.py b/source/app/__init__.py
index c00a2c7e0..ddc1a5aa0 100644
--- a/source/app/__init__.py
+++ b/source/app/__init__.py
@@ -26,7 +26,8 @@
from flask_caching import Cache
from flask_login import LoginManager
from flask_marshmallow import Marshmallow
-from flask_socketio import SocketIO, Namespace
+from flask_socketio import SocketIO
+from flask_socketio import Namespace
from flask_sqlalchemy import SQLAlchemy
from functools import partial
From 68397fe79f02a91b69ff698f9f0c9707b10df78f Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Fri, 13 Dec 2024 18:34:18 +0100
Subject: [PATCH 26/37] Fixed dim_tasks_is_legacy
---
source/app/business/dim_tasks.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source/app/business/dim_tasks.py b/source/app/business/dim_tasks.py
index 7273fe82f..4ca2b8645 100644
--- a/source/app/business/dim_tasks.py
+++ b/source/app/business/dim_tasks.py
@@ -33,7 +33,7 @@ def _get_success(task_result: IIStatus):
def dim_tasks_is_legacy(task):
try:
- _ = task.info
+ _ = task.date_done
return False
except AttributeError:
return True
From f0e16ff1654759def48d11e7bbb00015f09e3b80 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Mon, 16 Dec 2024 16:58:42 +0100
Subject: [PATCH 27/37] Removed unused import to re-export in __init__ file
---
source/app/flask_dropzone/__init__.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/source/app/flask_dropzone/__init__.py b/source/app/flask_dropzone/__init__.py
index 2cdc83f7d..2d864710b 100644
--- a/source/app/flask_dropzone/__init__.py
+++ b/source/app/flask_dropzone/__init__.py
@@ -15,7 +15,6 @@
from flask import url_for
from app.flask_dropzone.utils import get_url
-from app.flask_dropzone.utils import random_filename
#: defined normal file type
allowed_file_extensions = {
From a5bcd7410a861bb41592525d84f6867cd0160031 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Tue, 17 Dec 2024 15:20:11 +0100
Subject: [PATCH 28/37] Removed import from __init__
---
...cb34f7c_add_compromise_status_to_assets.py | 2 +-
source/app/datamgmt/states.py | 2 +-
source/app/models/__init__.py | 1 -
source/app/post_init.py | 20 ++++++++++++++-----
4 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/source/app/alembic/versions/4ecdfcb34f7c_add_compromise_status_to_assets.py b/source/app/alembic/versions/4ecdfcb34f7c_add_compromise_status_to_assets.py
index 383537e4f..7d711ae9d 100644
--- a/source/app/alembic/versions/4ecdfcb34f7c_add_compromise_status_to_assets.py
+++ b/source/app/alembic/versions/4ecdfcb34f7c_add_compromise_status_to_assets.py
@@ -10,7 +10,7 @@
# revision identifiers, used by Alembic.
from app.alembic.alembic_utils import _table_has_column
-from app.models import CompromiseStatus
+from app.models.models import CompromiseStatus
revision = '4ecdfcb34f7c'
down_revision = 'a929ef458490'
diff --git a/source/app/datamgmt/states.py b/source/app/datamgmt/states.py
index d7eefce8a..e182b3a54 100644
--- a/source/app/datamgmt/states.py
+++ b/source/app/datamgmt/states.py
@@ -21,7 +21,7 @@
from sqlalchemy import and_
from app import db
-from app.models import ObjectState
+from app.models.models import ObjectState
def _update_object_state(object_name, caseid, userid=None) -> ObjectState:
diff --git a/source/app/models/__init__.py b/source/app/models/__init__.py
index 2d7adf33b..90011803c 100644
--- a/source/app/models/__init__.py
+++ b/source/app/models/__init__.py
@@ -1,4 +1,3 @@
-from app.models.models import ObjectState
from app.models.cases import Cases
from app.models.cases import CasesEvent
from app.models.cases import Client
diff --git a/source/app/post_init.py b/source/app/post_init.py
index c571eb721..ee45a720b 100644
--- a/source/app/post_init.py
+++ b/source/app/post_init.py
@@ -28,7 +28,10 @@
import time
from alembic import command
from alembic.config import Config
-from sqlalchemy import create_engine, exc, or_, text
+from sqlalchemy import create_engine
+from sqlalchemy import exc
+from sqlalchemy import or_
+from sqlalchemy import text
from sqlalchemy_utils import create_database
from sqlalchemy_utils import database_exists
@@ -48,15 +51,22 @@
from app.iris_engine.module_handler.module_handler import check_module_health
from app.iris_engine.module_handler.module_handler import instantiate_module_from_name
from app.iris_engine.module_handler.module_handler import register_module
-from app.models import create_safe_limited
-from app.models.alerts import Severity, AlertStatus, AlertResolutionStatus
+from app.models.models import create_safe_limited
+from app.models.alerts import Severity
+from app.models.alerts import AlertStatus
+from app.models.alerts import AlertResolutionStatus
from app.models.authorization import CaseAccessLevel
from app.models.authorization import Group
from app.models.authorization import Organisation
from app.models.authorization import User
-from app.models.cases import Cases, CaseState
+from app.models.cases import Cases
+from app.models.cases import CaseState
from app.models.cases import Client
-from app.models.models import AnalysisStatus, CaseClassification, ReviewStatus, ReviewStatusList, EvidenceTypes
+from app.models.models import AnalysisStatus
+from app.models.models import CaseClassification
+from app.models.models import ReviewStatus
+from app.models.models import ReviewStatusList
+from app.models.models import EvidenceTypes
from app.models.models import AssetsType
from app.models.models import EventCategory
from app.models.models import IocType
From 7158d8d8bbd91cad4a14aa6386fc040ed4873d8a Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Tue, 17 Dec 2024 15:28:43 +0100
Subject: [PATCH 29/37] Removed import of Cases from __init__
---
source/app/blueprints/access_controls.py | 2 +-
.../app/blueprints/rest/dim_tasks_routes.py | 2 +-
.../app/datamgmt/activities/activities_db.py | 2 +-
source/app/datamgmt/alerts/alerts_db.py | 2 +-
source/app/datamgmt/case/case_assets_db.py | 5 ++--
source/app/datamgmt/case/case_iocs_db.py | 2 +-
source/app/datamgmt/case/case_tasks_db.py | 5 ++--
source/app/datamgmt/client/client_db.py | 8 +++---
source/app/datamgmt/context/context_db.py | 7 +++--
source/app/datamgmt/dashboard/dashboard_db.py | 6 +++--
.../manage/manage_access_control_db.py | 2 +-
.../app/datamgmt/manage/manage_assets_db.py | 26 +++++++++++++++++--
.../datamgmt/manage/manage_attribute_db.py | 5 ++--
.../manage/manage_case_templates_db.py | 15 ++++++++---
source/app/datamgmt/manage/manage_cases_db.py | 2 +-
.../app/datamgmt/manage/manage_groups_db.py | 2 +-
source/app/datamgmt/manage/manage_users_db.py | 3 ++-
source/app/datamgmt/overview/overview_db.py | 2 +-
source/app/datamgmt/reporter/report_db.py | 2 +-
.../app/iris_engine/access_control/utils.py | 2 +-
source/app/iris_engine/demo_builder.py | 2 +-
source/app/models/__init__.py | 1 -
source/app/schema/marshables.py | 2 +-
23 files changed, 74 insertions(+), 33 deletions(-)
diff --git a/source/app/blueprints/access_controls.py b/source/app/blueprints/access_controls.py
index 3b76038f0..39de3e9ba 100644
--- a/source/app/blueprints/access_controls.py
+++ b/source/app/blueprints/access_controls.py
@@ -48,7 +48,7 @@
from app.iris_engine.access_control.utils import ac_fast_check_user_has_case_access
from app.iris_engine.access_control.utils import ac_get_effective_permissions_of_user
from app.iris_engine.utils.tracker import track_activity
-from app.models import Cases
+from app.models.cases import Cases
from app.models.authorization import Permissions
from app.models.authorization import CaseAccessLevel
diff --git a/source/app/blueprints/rest/dim_tasks_routes.py b/source/app/blueprints/rest/dim_tasks_routes.py
index 8e7820730..f2607ff82 100644
--- a/source/app/blueprints/rest/dim_tasks_routes.py
+++ b/source/app/blueprints/rest/dim_tasks_routes.py
@@ -30,7 +30,7 @@
from app.models import CaseAssets
from app.models import CaseReceivedFile
from app.models import CaseTasks
-from app.models import Cases
+from app.models.cases import Cases
from app.models import CasesEvent
from app.models import GlobalTasks
from app.models import Ioc
diff --git a/source/app/datamgmt/activities/activities_db.py b/source/app/datamgmt/activities/activities_db.py
index c1fb0c9b5..f27134a00 100644
--- a/source/app/datamgmt/activities/activities_db.py
+++ b/source/app/datamgmt/activities/activities_db.py
@@ -19,7 +19,7 @@
from sqlalchemy import and_
from sqlalchemy import desc
-from app.models import Cases
+from app.models.cases import Cases
from app.models.authorization import User
from app.models.models import UserActivity
diff --git a/source/app/datamgmt/alerts/alerts_db.py b/source/app/datamgmt/alerts/alerts_db.py
index 766be6472..bd6572066 100644
--- a/source/app/datamgmt/alerts/alerts_db.py
+++ b/source/app/datamgmt/alerts/alerts_db.py
@@ -48,7 +48,7 @@
from app.datamgmt.manage.manage_case_templates_db import get_case_template_by_id
from app.datamgmt.manage.manage_case_templates_db import case_template_post_modifier
from app.datamgmt.states import update_timeline_state
-from app.models import Cases
+from app.models.cases import Cases
from app.models import EventCategory
from app.models import Tags
from app.models import AssetsType
diff --git a/source/app/datamgmt/case/case_assets_db.py b/source/app/datamgmt/case/case_assets_db.py
index 093a20dab..eba5020c6 100644
--- a/source/app/datamgmt/case/case_assets_db.py
+++ b/source/app/datamgmt/case/case_assets_db.py
@@ -24,12 +24,13 @@
from app import db, app
from app.datamgmt.states import update_assets_state
-from app.models import AnalysisStatus, CaseStatus
+from app.models import AnalysisStatus
+from app.models import CaseStatus
from app.models import AssetComments
from app.models import AssetsType
from app.models import CaseAssets
from app.models import CaseEventsAssets
-from app.models import Cases
+from app.models.cases import Cases
from app.models import Comments
from app.models import CompromiseStatus
from app.models import Ioc
diff --git a/source/app/datamgmt/case/case_iocs_db.py b/source/app/datamgmt/case/case_iocs_db.py
index 47dc5819f..52ab79a6d 100644
--- a/source/app/datamgmt/case/case_iocs_db.py
+++ b/source/app/datamgmt/case/case_iocs_db.py
@@ -25,7 +25,7 @@
from app import app
from app.datamgmt.states import update_ioc_state
from app.iris_engine.access_control.utils import ac_get_fast_user_cases_access
-from app.models import Cases
+from app.models.cases import Cases
from app.models import Client
from app.models import Comments
from app.models import Ioc
diff --git a/source/app/datamgmt/case/case_tasks_db.py b/source/app/datamgmt/case/case_tasks_db.py
index fa0cf38fc..1697737ae 100644
--- a/source/app/datamgmt/case/case_tasks_db.py
+++ b/source/app/datamgmt/case/case_tasks_db.py
@@ -18,7 +18,8 @@
from datetime import datetime
from flask_login import current_user
-from sqlalchemy import desc, and_
+from sqlalchemy import desc
+from sqlalchemy import and_
from app import db
from app.datamgmt.manage.manage_attribute_db import get_default_custom_attributes
@@ -26,7 +27,7 @@
from app.datamgmt.states import update_tasks_state
from app.models import CaseTasks
from app.models import TaskAssignee
-from app.models import Cases
+from app.models.cases import Cases
from app.models import Comments
from app.models import TaskComments
from app.models import TaskStatus
diff --git a/source/app/datamgmt/client/client_db.py b/source/app/datamgmt/client/client_db.py
index 7679c5e74..e0cf1effe 100644
--- a/source/app/datamgmt/client/client_db.py
+++ b/source/app/datamgmt/client/client_db.py
@@ -16,16 +16,18 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import marshmallow
-from sqlalchemy import func, and_
+from sqlalchemy import func
+from sqlalchemy import and_
from typing import List
from app import db
from app.datamgmt.exceptions.ElementExceptions import ElementInUseException
from app.datamgmt.exceptions.ElementExceptions import ElementNotFoundException
-from app.models import Cases
+from app.models.cases import Cases
from app.models import Client
from app.models import Contact
-from app.models.authorization import User, UserClient
+from app.models.authorization import User
+from app.models.authorization import UserClient
from app.schema.marshables import ContactSchema
from app.schema.marshables import CustomerSchema
diff --git a/source/app/datamgmt/context/context_db.py b/source/app/datamgmt/context/context_db.py
index 52f262b15..793a791da 100644
--- a/source/app/datamgmt/context/context_db.py
+++ b/source/app/datamgmt/context/context_db.py
@@ -15,10 +15,13 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-from sqlalchemy import and_, case, or_, asc
+from sqlalchemy import and_
+from sqlalchemy import case
+from sqlalchemy import or_
+from sqlalchemy import asc
from sqlalchemy import desc
-from app.models import Cases
+from app.models.cases import Cases
from app.models import Client
from app.models.authorization import CaseAccessLevel
from app.models.authorization import UserCaseEffectiveAccess
diff --git a/source/app/datamgmt/dashboard/dashboard_db.py b/source/app/datamgmt/dashboard/dashboard_db.py
index 5023f3260..e522db532 100644
--- a/source/app/datamgmt/dashboard/dashboard_db.py
+++ b/source/app/datamgmt/dashboard/dashboard_db.py
@@ -20,8 +20,10 @@
from sqlalchemy import desc
from app import db
-from app.models import CaseTasks, TaskAssignee, ReviewStatus
-from app.models import Cases
+from app.models import CaseTasks
+from app.models import TaskAssignee
+from app.models import ReviewStatus
+from app.models.cases import Cases
from app.models import GlobalTasks
from app.models import TaskStatus
from app.models.authorization import User
diff --git a/source/app/datamgmt/manage/manage_access_control_db.py b/source/app/datamgmt/manage/manage_access_control_db.py
index c5b7d9132..a97db33a8 100644
--- a/source/app/datamgmt/manage/manage_access_control_db.py
+++ b/source/app/datamgmt/manage/manage_access_control_db.py
@@ -16,7 +16,7 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from app import ac_current_user_has_permission
-from app.models import Cases
+from app.models.cases import Cases
from app.models.authorization import Group
from app.models.authorization import UserClient
from app.models.authorization import Permissions
diff --git a/source/app/datamgmt/manage/manage_assets_db.py b/source/app/datamgmt/manage/manage_assets_db.py
index c9e8b1a82..014e5cdbe 100644
--- a/source/app/datamgmt/manage/manage_assets_db.py
+++ b/source/app/datamgmt/manage/manage_assets_db.py
@@ -1,10 +1,32 @@
+# 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 flask_login import current_user
-from sqlalchemy import and_, desc, asc
+from sqlalchemy import and_
+from sqlalchemy import desc
+from sqlalchemy import asc
from functools import reduce
import app
from app.datamgmt.manage.manage_cases_db import user_list_cases_view
-from app.models import CaseAssets, Client, Cases
+from app.models import CaseAssets
+from app.models import Client
+from app.models.cases import Cases
def get_filtered_assets(case_id=None,
diff --git a/source/app/datamgmt/manage/manage_attribute_db.py b/source/app/datamgmt/manage/manage_attribute_db.py
index 2237f6c1e..e821dde93 100644
--- a/source/app/datamgmt/manage/manage_attribute_db.py
+++ b/source/app/datamgmt/manage/manage_attribute_db.py
@@ -19,11 +19,12 @@
import logging as logger
from sqlalchemy.orm.attributes import flag_modified
-from app import db, app
+from app import db
+from app import app
from app.models import CaseAssets
from app.models import CaseReceivedFile
from app.models import CaseTasks
-from app.models import Cases
+from app.models.cases import Cases
from app.models import CasesEvent
from app.models import Client
from app.models import CustomAttribute
diff --git a/source/app/datamgmt/manage/manage_case_templates_db.py b/source/app/datamgmt/manage/manage_case_templates_db.py
index e98864d06..e6661e1c6 100644
--- a/source/app/datamgmt/manage/manage_case_templates_db.py
+++ b/source/app/datamgmt/manage/manage_case_templates_db.py
@@ -14,17 +14,26 @@
# 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.
+
import marshmallow
from datetime import datetime
-from typing import List, Optional, Union
+from typing import List
+from typing import Optional
+from typing import Union
from app import db
from app.datamgmt.case.case_tasks_db import add_task
from app.datamgmt.manage.manage_case_classifications_db import get_case_classification_by_name
from app.iris_engine.module_handler.module_handler import call_modules_hook
-from app.models import CaseTemplate, Cases, Tags, NoteDirectory
+from app.models import CaseTemplate
+from app.models.cases import Cases
+from app.models import Tags
+from app.models import NoteDirectory
from app.models.authorization import User
-from app.schema.marshables import CaseSchema, CaseTaskSchema, CaseNoteDirectorySchema, CaseNoteSchema
+from app.schema.marshables import CaseSchema
+from app.schema.marshables import CaseTaskSchema
+from app.schema.marshables import CaseNoteDirectorySchema
+from app.schema.marshables import CaseNoteSchema
def get_case_templates_list() -> List[dict]:
diff --git a/source/app/datamgmt/manage/manage_cases_db.py b/source/app/datamgmt/manage/manage_cases_db.py
index 491ac7a17..f1618b5e0 100644
--- a/source/app/datamgmt/manage/manage_cases_db.py
+++ b/source/app/datamgmt/manage/manage_cases_db.py
@@ -45,7 +45,7 @@
from app.models import CaseEventsIoc
from app.models import CaseReceivedFile
from app.models import CaseTasks
-from app.models import Cases
+from app.models.cases import Cases
from app.models import CasesEvent
from app.models import Client
from app.models import DataStoreFile
diff --git a/source/app/datamgmt/manage/manage_groups_db.py b/source/app/datamgmt/manage/manage_groups_db.py
index 3a197035b..3d3eedb21 100644
--- a/source/app/datamgmt/manage/manage_groups_db.py
+++ b/source/app/datamgmt/manage/manage_groups_db.py
@@ -24,7 +24,7 @@
from app.iris_engine.access_control.utils import ac_access_level_to_list
from app.iris_engine.access_control.utils import ac_auto_update_user_effective_access
from app.iris_engine.access_control.utils import ac_permission_to_list
-from app.models import Cases
+from app.models.cases import Cases
from app.models.authorization import Group
from app.models.authorization import GroupCaseAccess
from app.models.authorization import User
diff --git a/source/app/datamgmt/manage/manage_users_db.py b/source/app/datamgmt/manage/manage_users_db.py
index 6d7ce249e..70e985bcf 100644
--- a/source/app/datamgmt/manage/manage_users_db.py
+++ b/source/app/datamgmt/manage/manage_users_db.py
@@ -31,7 +31,8 @@
from app.iris_engine.access_control.utils import ac_get_detailed_effective_permissions_from_groups
from app.iris_engine.access_control.utils import ac_remove_case_access_from_user
from app.iris_engine.access_control.utils import ac_set_case_access_for_user
-from app.models import Cases, Client
+from app.models.cases import Cases
+from app.models import Client
from app.models.authorization import CaseAccessLevel, UserClient
from app.models.authorization import Group
from app.models.authorization import Organisation
diff --git a/source/app/datamgmt/overview/overview_db.py b/source/app/datamgmt/overview/overview_db.py
index 3ecff5148..62a097b08 100644
--- a/source/app/datamgmt/overview/overview_db.py
+++ b/source/app/datamgmt/overview/overview_db.py
@@ -20,7 +20,7 @@
from app.datamgmt.case.case_tasks_db import get_tasks_cases_mapping
from app.datamgmt.manage.manage_cases_db import user_list_cases_view
-from app.models import Cases
+from app.models.cases import Cases
from app.schema.marshables import CaseDetailsSchema
diff --git a/source/app/datamgmt/reporter/report_db.py b/source/app/datamgmt/reporter/report_db.py
index 13a269c36..9184ebf45 100644
--- a/source/app/datamgmt/reporter/report_db.py
+++ b/source/app/datamgmt/reporter/report_db.py
@@ -31,7 +31,7 @@
from app.models import CaseEventsIoc
from app.models import CaseReceivedFile
from app.models import CaseTasks
-from app.models import Cases
+from app.models.cases import Cases
from app.models import CasesEvent
from app.models import Comments
from app.models import EventCategory
diff --git a/source/app/iris_engine/access_control/utils.py b/source/app/iris_engine/access_control/utils.py
index d1599db72..e164c7020 100644
--- a/source/app/iris_engine/access_control/utils.py
+++ b/source/app/iris_engine/access_control/utils.py
@@ -5,7 +5,7 @@
import app
from app import db
from app.datamgmt.manage.manage_access_control_db import check_ua_case_client
-from app.models import Cases
+from app.models.cases import Cases
from app.models import Client
from app.models.authorization import CaseAccessLevel
from app.models.authorization import UserClient
diff --git a/source/app/iris_engine/demo_builder.py b/source/app/iris_engine/demo_builder.py
index 3151badbc..ca85d8db9 100644
--- a/source/app/iris_engine/demo_builder.py
+++ b/source/app/iris_engine/demo_builder.py
@@ -28,7 +28,7 @@
from app.datamgmt.manage.manage_users_db import add_user_to_organisation
from app.datamgmt.manage.manage_users_db import user_exists
from app.iris_engine.access_control.utils import ac_add_users_multi_effective_access
-from app.models import Cases
+from app.models.cases import Cases
from app.models import Client
from app.models import get_or_create
from app.models.authorization import CaseAccessLevel
diff --git a/source/app/models/__init__.py b/source/app/models/__init__.py
index 90011803c..40aefeb0b 100644
--- a/source/app/models/__init__.py
+++ b/source/app/models/__init__.py
@@ -1,4 +1,3 @@
-from app.models.cases import Cases
from app.models.cases import CasesEvent
from app.models.cases import Client
from app.models.models import *
diff --git a/source/app/schema/marshables.py b/source/app/schema/marshables.py
index 88e1999e3..0379a615d 100644
--- a/source/app/schema/marshables.py
+++ b/source/app/schema/marshables.py
@@ -68,7 +68,7 @@
from app.models import CaseAssets
from app.models import CaseReceivedFile
from app.models import CaseTasks
-from app.models import Cases
+from app.models.cases import Cases
from app.models import CasesEvent
from app.models import Client
from app.models import Comments
From 2d4aa3d7e761cc9a946b383df1bf2fa4a96198ed Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Tue, 17 Dec 2024 15:30:23 +0100
Subject: [PATCH 30/37] Removed import of CasesEvent from __init__
---
source/app/blueprints/rest/dim_tasks_routes.py | 2 +-
source/app/datamgmt/case/case_events_db.py | 2 +-
source/app/datamgmt/manage/manage_attribute_db.py | 2 +-
source/app/datamgmt/manage/manage_cases_db.py | 2 +-
source/app/datamgmt/reporter/report_db.py | 2 +-
source/app/iris_engine/reporter/reporter.py | 2 +-
source/app/models/__init__.py | 1 -
source/app/schema/marshables.py | 2 +-
8 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/source/app/blueprints/rest/dim_tasks_routes.py b/source/app/blueprints/rest/dim_tasks_routes.py
index f2607ff82..9cea7a403 100644
--- a/source/app/blueprints/rest/dim_tasks_routes.py
+++ b/source/app/blueprints/rest/dim_tasks_routes.py
@@ -31,7 +31,7 @@
from app.models import CaseReceivedFile
from app.models import CaseTasks
from app.models.cases import Cases
-from app.models import CasesEvent
+from app.models.cases import CasesEvent
from app.models import GlobalTasks
from app.models import Ioc
from app.models import Notes
diff --git a/source/app/datamgmt/case/case_events_db.py b/source/app/datamgmt/case/case_events_db.py
index 6be300d90..af8a49388 100644
--- a/source/app/datamgmt/case/case_events_db.py
+++ b/source/app/datamgmt/case/case_events_db.py
@@ -25,7 +25,7 @@
from app.models import CaseEventCategory
from app.models import CaseEventsAssets
from app.models import CaseEventsIoc
-from app.models import CasesEvent
+from app.models.cases import CasesEvent
from app.models import Comments
from app.models import EventCategory
from app.models import EventComments
diff --git a/source/app/datamgmt/manage/manage_attribute_db.py b/source/app/datamgmt/manage/manage_attribute_db.py
index e821dde93..2c632fad7 100644
--- a/source/app/datamgmt/manage/manage_attribute_db.py
+++ b/source/app/datamgmt/manage/manage_attribute_db.py
@@ -25,7 +25,7 @@
from app.models import CaseReceivedFile
from app.models import CaseTasks
from app.models.cases import Cases
-from app.models import CasesEvent
+from app.models.cases import CasesEvent
from app.models import Client
from app.models import CustomAttribute
from app.models import Ioc
diff --git a/source/app/datamgmt/manage/manage_cases_db.py b/source/app/datamgmt/manage/manage_cases_db.py
index f1618b5e0..d83123e73 100644
--- a/source/app/datamgmt/manage/manage_cases_db.py
+++ b/source/app/datamgmt/manage/manage_cases_db.py
@@ -46,7 +46,7 @@
from app.models import CaseReceivedFile
from app.models import CaseTasks
from app.models.cases import Cases
-from app.models import CasesEvent
+from app.models.cases import CasesEvent
from app.models import Client
from app.models import DataStoreFile
from app.models import DataStorePath
diff --git a/source/app/datamgmt/reporter/report_db.py b/source/app/datamgmt/reporter/report_db.py
index 9184ebf45..0e5c107c9 100644
--- a/source/app/datamgmt/reporter/report_db.py
+++ b/source/app/datamgmt/reporter/report_db.py
@@ -32,7 +32,7 @@
from app.models import CaseReceivedFile
from app.models import CaseTasks
from app.models.cases import Cases
-from app.models import CasesEvent
+from app.models.cases import CasesEvent
from app.models import Comments
from app.models import EventCategory
from app.models import Ioc
diff --git a/source/app/iris_engine/reporter/reporter.py b/source/app/iris_engine/reporter/reporter.py
index ee475344d..630d844d5 100644
--- a/source/app/iris_engine/reporter/reporter.py
+++ b/source/app/iris_engine/reporter/reporter.py
@@ -39,7 +39,7 @@
from app.models import CaseEventsAssets
from app.models import CaseReceivedFile
from app.models import CaseTemplateReport
-from app.models import CasesEvent
+from app.models.cases import CasesEvent
from app.models import Ioc
from app.models import IocAssetLink
diff --git a/source/app/models/__init__.py b/source/app/models/__init__.py
index 40aefeb0b..7048eb750 100644
--- a/source/app/models/__init__.py
+++ b/source/app/models/__init__.py
@@ -1,4 +1,3 @@
-from app.models.cases import CasesEvent
from app.models.cases import Client
from app.models.models import *
diff --git a/source/app/schema/marshables.py b/source/app/schema/marshables.py
index 0379a615d..a096b8054 100644
--- a/source/app/schema/marshables.py
+++ b/source/app/schema/marshables.py
@@ -69,7 +69,7 @@
from app.models import CaseReceivedFile
from app.models import CaseTasks
from app.models.cases import Cases
-from app.models import CasesEvent
+from app.models.cases import CasesEvent
from app.models import Client
from app.models import Comments
from app.models import Contact
From c5b77be6a1638a42f8a4c4cc6722734e5e327789 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Tue, 17 Dec 2024 15:34:12 +0100
Subject: [PATCH 31/37] Removed import of Client from __init__
---
source/app/datamgmt/case/case_iocs_db.py | 2 +-
source/app/datamgmt/client/client_db.py | 2 +-
source/app/datamgmt/context/context_db.py | 2 +-
source/app/datamgmt/manage/manage_assets_db.py | 2 +-
source/app/datamgmt/manage/manage_attribute_db.py | 2 +-
source/app/datamgmt/manage/manage_cases_db.py | 2 +-
source/app/datamgmt/manage/manage_users_db.py | 2 +-
source/app/iris_engine/access_control/utils.py | 2 +-
source/app/iris_engine/demo_builder.py | 2 +-
source/app/models/__init__.py | 1 -
source/app/post_init.py | 2 +-
source/app/schema/marshables.py | 2 +-
source/tests/performance/test_burst_db_interaction.py | 2 +-
source/tests/test_helper.py | 2 +-
14 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/source/app/datamgmt/case/case_iocs_db.py b/source/app/datamgmt/case/case_iocs_db.py
index 52ab79a6d..f96acd870 100644
--- a/source/app/datamgmt/case/case_iocs_db.py
+++ b/source/app/datamgmt/case/case_iocs_db.py
@@ -26,7 +26,7 @@
from app.datamgmt.states import update_ioc_state
from app.iris_engine.access_control.utils import ac_get_fast_user_cases_access
from app.models.cases import Cases
-from app.models import Client
+from app.models.models import Client
from app.models import Comments
from app.models import Ioc
from app.models import IocComments
diff --git a/source/app/datamgmt/client/client_db.py b/source/app/datamgmt/client/client_db.py
index e0cf1effe..5e99932c3 100644
--- a/source/app/datamgmt/client/client_db.py
+++ b/source/app/datamgmt/client/client_db.py
@@ -24,7 +24,7 @@
from app.datamgmt.exceptions.ElementExceptions import ElementInUseException
from app.datamgmt.exceptions.ElementExceptions import ElementNotFoundException
from app.models.cases import Cases
-from app.models import Client
+from app.models.models import Client
from app.models import Contact
from app.models.authorization import User
from app.models.authorization import UserClient
diff --git a/source/app/datamgmt/context/context_db.py b/source/app/datamgmt/context/context_db.py
index 793a791da..27afcd233 100644
--- a/source/app/datamgmt/context/context_db.py
+++ b/source/app/datamgmt/context/context_db.py
@@ -22,7 +22,7 @@
from sqlalchemy import desc
from app.models.cases import Cases
-from app.models import Client
+from app.models.models import Client
from app.models.authorization import CaseAccessLevel
from app.models.authorization import UserCaseEffectiveAccess
from app.datamgmt.authorization import has_deny_all_access_level
diff --git a/source/app/datamgmt/manage/manage_assets_db.py b/source/app/datamgmt/manage/manage_assets_db.py
index 014e5cdbe..637eef04c 100644
--- a/source/app/datamgmt/manage/manage_assets_db.py
+++ b/source/app/datamgmt/manage/manage_assets_db.py
@@ -25,7 +25,7 @@
import app
from app.datamgmt.manage.manage_cases_db import user_list_cases_view
from app.models import CaseAssets
-from app.models import Client
+from app.models.models import Client
from app.models.cases import Cases
diff --git a/source/app/datamgmt/manage/manage_attribute_db.py b/source/app/datamgmt/manage/manage_attribute_db.py
index 2c632fad7..03082fa74 100644
--- a/source/app/datamgmt/manage/manage_attribute_db.py
+++ b/source/app/datamgmt/manage/manage_attribute_db.py
@@ -26,7 +26,7 @@
from app.models import CaseTasks
from app.models.cases import Cases
from app.models.cases import CasesEvent
-from app.models import Client
+from app.models.models import Client
from app.models import CustomAttribute
from app.models import Ioc
from app.models import Notes
diff --git a/source/app/datamgmt/manage/manage_cases_db.py b/source/app/datamgmt/manage/manage_cases_db.py
index d83123e73..9239f47b8 100644
--- a/source/app/datamgmt/manage/manage_cases_db.py
+++ b/source/app/datamgmt/manage/manage_cases_db.py
@@ -47,7 +47,7 @@
from app.models import CaseTasks
from app.models.cases import Cases
from app.models.cases import CasesEvent
-from app.models import Client
+from app.models.models import Client
from app.models import DataStoreFile
from app.models import DataStorePath
from app.models import IocAssetLink
diff --git a/source/app/datamgmt/manage/manage_users_db.py b/source/app/datamgmt/manage/manage_users_db.py
index 70e985bcf..c3bce5336 100644
--- a/source/app/datamgmt/manage/manage_users_db.py
+++ b/source/app/datamgmt/manage/manage_users_db.py
@@ -32,7 +32,7 @@
from app.iris_engine.access_control.utils import ac_remove_case_access_from_user
from app.iris_engine.access_control.utils import ac_set_case_access_for_user
from app.models.cases import Cases
-from app.models import Client
+from app.models.models import Client
from app.models.authorization import CaseAccessLevel, UserClient
from app.models.authorization import Group
from app.models.authorization import Organisation
diff --git a/source/app/iris_engine/access_control/utils.py b/source/app/iris_engine/access_control/utils.py
index e164c7020..a715663e4 100644
--- a/source/app/iris_engine/access_control/utils.py
+++ b/source/app/iris_engine/access_control/utils.py
@@ -6,7 +6,7 @@
from app import db
from app.datamgmt.manage.manage_access_control_db import check_ua_case_client
from app.models.cases import Cases
-from app.models import Client
+from app.models.models import Client
from app.models.authorization import CaseAccessLevel
from app.models.authorization import UserClient
from app.models.authorization import Group
diff --git a/source/app/iris_engine/demo_builder.py b/source/app/iris_engine/demo_builder.py
index ca85d8db9..bfcea49e8 100644
--- a/source/app/iris_engine/demo_builder.py
+++ b/source/app/iris_engine/demo_builder.py
@@ -29,7 +29,7 @@
from app.datamgmt.manage.manage_users_db import user_exists
from app.iris_engine.access_control.utils import ac_add_users_multi_effective_access
from app.models.cases import Cases
-from app.models import Client
+from app.models.models import Client
from app.models import get_or_create
from app.models.authorization import CaseAccessLevel
from app.models.authorization import User
diff --git a/source/app/models/__init__.py b/source/app/models/__init__.py
index 7048eb750..b34daaa59 100644
--- a/source/app/models/__init__.py
+++ b/source/app/models/__init__.py
@@ -1,3 +1,2 @@
-from app.models.cases import Client
from app.models.models import *
diff --git a/source/app/post_init.py b/source/app/post_init.py
index ee45a720b..29c0abf8e 100644
--- a/source/app/post_init.py
+++ b/source/app/post_init.py
@@ -61,7 +61,7 @@
from app.models.authorization import User
from app.models.cases import Cases
from app.models.cases import CaseState
-from app.models.cases import Client
+from app.models.models import Client
from app.models.models import AnalysisStatus
from app.models.models import CaseClassification
from app.models.models import ReviewStatus
diff --git a/source/app/schema/marshables.py b/source/app/schema/marshables.py
index a096b8054..7256abbf3 100644
--- a/source/app/schema/marshables.py
+++ b/source/app/schema/marshables.py
@@ -70,7 +70,7 @@
from app.models import CaseTasks
from app.models.cases import Cases
from app.models.cases import CasesEvent
-from app.models import Client
+from app.models.models import Client
from app.models import Comments
from app.models import Contact
from app.models import DataStoreFile
diff --git a/source/tests/performance/test_burst_db_interaction.py b/source/tests/performance/test_burst_db_interaction.py
index ea8cb4e9b..5ffb348af 100644
--- a/source/tests/performance/test_burst_db_interaction.py
+++ b/source/tests/performance/test_burst_db_interaction.py
@@ -31,7 +31,7 @@
from app.datamgmt.manage.manage_users_db import create_user
from app.models.cases import Cases
from app.models.cases import CasesEvent
-from app.models.cases import Client
+from app.models.models import Client
from app.models.models import CaseEventsAssets
from app.models.authorization import User
from app.post_init import run_post_init
diff --git a/source/tests/test_helper.py b/source/tests/test_helper.py
index 202a66209..e70841ead 100644
--- a/source/tests/test_helper.py
+++ b/source/tests/test_helper.py
@@ -27,7 +27,7 @@
from app import app
from app.datamgmt.client.client_db import create_client
-from app.models import Client
+from app.models.models import Client
class TestHelper(TestCase):
From a49bf647206f763bec2a061060e739800dc780e5 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Tue, 17 Dec 2024 16:04:13 +0100
Subject: [PATCH 32/37] Removed wildcard import from app.models __init__
---
.../app/blueprints/pages/case/case_routes.py | 2 +-
.../manage/manage_case_templates_routes.py | 2 +-
.../pages/manage/manage_ioc_types_routes.py | 2 +-
.../rest/case/case_assets_routes.py | 2 +-
.../blueprints/rest/case/case_notes_routes.py | 2 +-
.../app/blueprints/rest/case/case_routes.py | 6 +-
.../rest/case/case_timeline_routes.py | 2 +-
.../app/blueprints/rest/dim_tasks_routes.py | 20 +++----
.../manage/manage_case_templates_routes.py | 2 +-
.../rest/manage/manage_ioc_types_routes.py | 4 +-
.../rest/manage/manage_tlps_routes.py | 2 +-
source/app/blueprints/rest/reports_route.py | 2 +-
source/app/blueprints/rest/search_routes.py | 2 +-
source/app/business/assets.py | 2 +-
source/app/business/cases.py | 2 +-
source/app/business/iocs.py | 2 +-
source/app/business/notes.py | 2 +-
source/app/business/tasks.py | 2 +-
source/app/datamgmt/alerts/alerts_db.py | 16 +++---
source/app/datamgmt/case/case_assets_db.py | 22 ++++----
source/app/datamgmt/case/case_comments.py | 2 +-
source/app/datamgmt/case/case_events_db.py | 22 ++++----
source/app/datamgmt/case/case_iocs_db.py | 10 ++--
source/app/datamgmt/case/case_notes_db.py | 12 ++--
source/app/datamgmt/case/case_rfiles_db.py | 6 +-
source/app/datamgmt/case/case_tasks_db.py | 10 ++--
source/app/datamgmt/client/client_db.py | 2 +-
source/app/datamgmt/dashboard/dashboard_db.py | 10 ++--
source/app/datamgmt/datastore/datastore_db.py | 12 ++--
source/app/datamgmt/filters/filters_db.py | 2 +-
.../datamgmt/iris_engine/evidence_storage.py | 2 +-
source/app/datamgmt/iris_engine/modules_db.py | 6 +-
.../app/datamgmt/manage/manage_assets_db.py | 2 +-
.../datamgmt/manage/manage_attribute_db.py | 12 ++--
.../manage/manage_case_classifications_db.py | 2 +-
.../app/datamgmt/manage/manage_case_objs.py | 5 +-
.../manage/manage_case_templates_db.py | 6 +-
source/app/datamgmt/manage/manage_cases_db.py | 39 ++++++-------
.../manage/manage_evidence_types_db.py | 3 +-
.../datamgmt/manage/manage_srv_settings_db.py | 2 +-
source/app/datamgmt/manage/manage_tags_db.py | 6 +-
source/app/datamgmt/reporter/report_db.py | 36 ++++++------
source/app/iris_engine/demo_builder.py | 2 +-
.../module_handler/module_handler.py | 6 +-
source/app/iris_engine/reporter/reporter.py | 14 ++---
source/app/iris_engine/updater/updater.py | 2 +-
source/app/iris_engine/utils/tracker.py | 4 +-
source/app/models/__init__.py | 2 -
source/app/models/alerts.py | 3 +-
source/app/schema/marshables.py | 56 +++++++++----------
50 files changed, 201 insertions(+), 195 deletions(-)
diff --git a/source/app/blueprints/pages/case/case_routes.py b/source/app/blueprints/pages/case/case_routes.py
index 8b01f1c89..4c4b1f051 100644
--- a/source/app/blueprints/pages/case/case_routes.py
+++ b/source/app/blueprints/pages/case/case_routes.py
@@ -32,7 +32,7 @@
from app.forms import PipelinesCaseForm
from app.iris_engine.access_control.utils import ac_get_all_access_level
from app.iris_engine.module_handler.module_handler import list_available_pipelines
-from app.models import CaseStatus
+from app.models.models import CaseStatus
from app.models.authorization import CaseAccessLevel
from app.blueprints.access_controls import ac_case_requires
diff --git a/source/app/blueprints/pages/manage/manage_case_templates_routes.py b/source/app/blueprints/pages/manage/manage_case_templates_routes.py
index 94ef310e3..33f101fe5 100644
--- a/source/app/blueprints/pages/manage/manage_case_templates_routes.py
+++ b/source/app/blueprints/pages/manage/manage_case_templates_routes.py
@@ -22,7 +22,7 @@
from app.datamgmt.manage.manage_case_templates_db import get_case_template_by_id
from app.forms import CaseTemplateForm, AddAssetForm
-from app.models import CaseTemplate
+from app.models.models import CaseTemplate
from app.models.authorization import Permissions
from app.blueprints.access_controls import ac_requires
from app.blueprints.responses import response_error
diff --git a/source/app/blueprints/pages/manage/manage_ioc_types_routes.py b/source/app/blueprints/pages/manage/manage_ioc_types_routes.py
index 16594705e..479f908a4 100644
--- a/source/app/blueprints/pages/manage/manage_ioc_types_routes.py
+++ b/source/app/blueprints/pages/manage/manage_ioc_types_routes.py
@@ -22,7 +22,7 @@
from werkzeug.utils import redirect
from app.forms import AddIocTypeForm
-from app.models import IocType
+from app.models.models import IocType
from app.models.authorization import Permissions
from app.blueprints.access_controls import ac_requires
from app.blueprints.responses import response_error
diff --git a/source/app/blueprints/rest/case/case_assets_routes.py b/source/app/blueprints/rest/case/case_assets_routes.py
index 3dd5ebf72..8bb44967a 100644
--- a/source/app/blueprints/rest/case/case_assets_routes.py
+++ b/source/app/blueprints/rest/case/case_assets_routes.py
@@ -51,7 +51,7 @@
from app.iris_engine.access_control.utils import ac_fast_check_current_user_has_case_access
from app.iris_engine.module_handler.module_handler import call_modules_hook
from app.iris_engine.utils.tracker import track_activity
-from app.models import AnalysisStatus
+from app.models.models import AnalysisStatus
from app.models.authorization import CaseAccessLevel
from app.schema.marshables import CaseAssetsSchema
from app.schema.marshables import CommentSchema
diff --git a/source/app/blueprints/rest/case/case_notes_routes.py b/source/app/blueprints/rest/case/case_notes_routes.py
index 5cd6eaba8..38825affd 100644
--- a/source/app/blueprints/rest/case/case_notes_routes.py
+++ b/source/app/blueprints/rest/case/case_notes_routes.py
@@ -46,7 +46,7 @@
from app.datamgmt.states import get_notes_state
from app.iris_engine.module_handler.module_handler import call_modules_hook
from app.iris_engine.utils.tracker import track_activity
-from app.models import Notes
+from app.models.models import Notes
from app.models.authorization import CaseAccessLevel
from app.schema.marshables import CaseNoteDirectorySchema
from app.schema.marshables import CaseNoteRevisionSchema
diff --git a/source/app/blueprints/rest/case/case_routes.py b/source/app/blueprints/rest/case/case_routes.py
index 95603ff16..b7767ca05 100644
--- a/source/app/blueprints/rest/case/case_routes.py
+++ b/source/app/blueprints/rest/case/case_routes.py
@@ -43,9 +43,9 @@
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_case_access_for_users
from app.iris_engine.utils.tracker import track_activity
-from app.models import CaseStatus
-from app.models import ReviewStatusList
-from app.models import UserActivity
+from app.models.models import CaseStatus
+from app.models.models import ReviewStatusList
+from app.models.models import UserActivity
from app.models.authorization import CaseAccessLevel
from app.models.authorization import User
from app.schema.marshables import TaskLogSchema
diff --git a/source/app/blueprints/rest/case/case_timeline_routes.py b/source/app/blueprints/rest/case/case_timeline_routes.py
index 25a405a90..dc69637ec 100644
--- a/source/app/blueprints/rest/case/case_timeline_routes.py
+++ b/source/app/blueprints/rest/case/case_timeline_routes.py
@@ -54,7 +54,7 @@
from app.iris_engine.utils.collab import collab_notify
from app.iris_engine.utils.common import parse_bf_date_format
from app.iris_engine.utils.tracker import track_activity
-from app.models import CompromiseStatus
+from app.models.models import CompromiseStatus
from app.models.authorization import CaseAccessLevel
from app.models.authorization import User
from app.models.cases import CasesEvent
diff --git a/source/app/blueprints/rest/dim_tasks_routes.py b/source/app/blueprints/rest/dim_tasks_routes.py
index 9cea7a403..882090220 100644
--- a/source/app/blueprints/rest/dim_tasks_routes.py
+++ b/source/app/blueprints/rest/dim_tasks_routes.py
@@ -23,18 +23,18 @@
from sqlalchemy import desc
from app.iris_engine.module_handler.module_handler import call_modules_hook
-from app.models import CeleryTaskMeta
-from app.models import IrisHook
-from app.models import IrisModule
-from app.models import IrisModuleHook
-from app.models import CaseAssets
-from app.models import CaseReceivedFile
-from app.models import CaseTasks
+from app.models.models import CeleryTaskMeta
+from app.models.models import IrisHook
+from app.models.models import IrisModule
+from app.models.models import IrisModuleHook
+from app.models.models import CaseAssets
+from app.models.models import CaseReceivedFile
+from app.models.models import CaseTasks
from app.models.cases import Cases
from app.models.cases import CasesEvent
-from app.models import GlobalTasks
-from app.models import Ioc
-from app.models import Notes
+from app.models.models import GlobalTasks
+from app.models.models import Ioc
+from app.models.models import Notes
from app.models.alerts import Alert
from app.models.authorization import CaseAccessLevel
from app.blueprints.access_controls import ac_requires_case_identifier
diff --git a/source/app/blueprints/rest/manage/manage_case_templates_routes.py b/source/app/blueprints/rest/manage/manage_case_templates_routes.py
index aab98e66d..0f4fa5835 100644
--- a/source/app/blueprints/rest/manage/manage_case_templates_routes.py
+++ b/source/app/blueprints/rest/manage/manage_case_templates_routes.py
@@ -27,7 +27,7 @@
from app.datamgmt.manage.manage_case_templates_db import get_case_template_by_id
from app.datamgmt.manage.manage_case_templates_db import validate_case_template
from app.datamgmt.manage.manage_case_templates_db import delete_case_template_by_id
-from app.models import CaseTemplate
+from app.models.models import CaseTemplate
from app.models.authorization import Permissions
from app.iris_engine.utils.tracker import track_activity
from app.schema.marshables import CaseTemplateSchema
diff --git a/source/app/blueprints/rest/manage/manage_ioc_types_routes.py b/source/app/blueprints/rest/manage/manage_ioc_types_routes.py
index 6f5a07d9c..bbe9a62d3 100644
--- a/source/app/blueprints/rest/manage/manage_ioc_types_routes.py
+++ b/source/app/blueprints/rest/manage/manage_ioc_types_routes.py
@@ -24,8 +24,8 @@
from app.datamgmt.case.case_iocs_db import get_ioc_types_list
from app.datamgmt.manage.manage_case_objs import search_ioc_type_by_name
from app.iris_engine.utils.tracker import track_activity
-from app.models import Ioc
-from app.models import IocType
+from app.models.models import Ioc
+from app.models.models import IocType
from app.models.authorization import Permissions
from app.schema.marshables import IocTypeSchema
from app.blueprints.access_controls import ac_api_requires
diff --git a/source/app/blueprints/rest/manage/manage_tlps_routes.py b/source/app/blueprints/rest/manage/manage_tlps_routes.py
index a72ec43f2..28203b28d 100644
--- a/source/app/blueprints/rest/manage/manage_tlps_routes.py
+++ b/source/app/blueprints/rest/manage/manage_tlps_routes.py
@@ -18,7 +18,7 @@
from flask import Blueprint
-from app.models import Tlp
+from app.models.models import Tlp
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.blueprints.responses import response_success
diff --git a/source/app/blueprints/rest/reports_route.py b/source/app/blueprints/rest/reports_route.py
index 94d7b87ce..a8052b317 100644
--- a/source/app/blueprints/rest/reports_route.py
+++ b/source/app/blueprints/rest/reports_route.py
@@ -29,7 +29,7 @@
from app.iris_engine.reporter.reporter import IrisMakeMdReport
from app.iris_engine.utils.tracker import track_activity
-from app.models import CaseTemplateReport
+from app.models.models import CaseTemplateReport
from app.models.authorization import CaseAccessLevel
from app.util import FileRemover
diff --git a/source/app/blueprints/rest/search_routes.py b/source/app/blueprints/rest/search_routes.py
index 7da5e4410..395af5fe2 100644
--- a/source/app/blueprints/rest/search_routes.py
+++ b/source/app/blueprints/rest/search_routes.py
@@ -21,7 +21,7 @@
from sqlalchemy import and_
from app.iris_engine.utils.tracker import track_activity
-from app.models import Comments
+from app.models.models import Comments
from app.models.authorization import Permissions
from app.models.cases import Cases
from app.models.models import Client
diff --git a/source/app/business/assets.py b/source/app/business/assets.py
index bd5c1e59f..ea752316d 100644
--- a/source/app/business/assets.py
+++ b/source/app/business/assets.py
@@ -21,7 +21,7 @@
from app.business.errors import BusinessProcessingError
from app.business.errors import ObjectNotFoundError
-from app.models import CaseAssets
+from app.models.models import CaseAssets
from app.datamgmt.case.case_assets_db import get_asset
from app.datamgmt.case.case_assets_db import case_assets_db_exists
from app.datamgmt.case.case_assets_db import create_asset
diff --git a/source/app/business/cases.py b/source/app/business/cases.py
index 65473905a..01d743602 100644
--- a/source/app/business/cases.py
+++ b/source/app/business/cases.py
@@ -30,7 +30,7 @@
from app.util import add_obj_history_entry
from app.schema.marshables import CaseSchema
-from app.models import ReviewStatusList
+from app.models.models import ReviewStatusList
from app.business.errors import BusinessProcessingError
from app.business.iocs import iocs_exports_to_json
diff --git a/source/app/business/iocs.py b/source/app/business/iocs.py
index 3374695da..8473501c5 100644
--- a/source/app/business/iocs.py
+++ b/source/app/business/iocs.py
@@ -20,7 +20,7 @@
from marshmallow.exceptions import ValidationError
from app import db
-from app.models import Ioc
+from app.models.models import Ioc
from app.datamgmt.case.case_iocs_db import add_ioc
from app.datamgmt.case.case_iocs_db import case_iocs_db_exists
from app.datamgmt.case.case_iocs_db import check_ioc_type_id
diff --git a/source/app/business/notes.py b/source/app/business/notes.py
index 96117d433..c3647f5e6 100644
--- a/source/app/business/notes.py
+++ b/source/app/business/notes.py
@@ -25,7 +25,7 @@
from app.datamgmt.case.case_notes_db import get_note
from app.iris_engine.module_handler.module_handler import call_modules_hook
from app.iris_engine.utils.tracker import track_activity
-from app.models import NoteRevisions
+from app.models.models import NoteRevisions
from app.models.authorization import User
from app.schema.marshables import CaseNoteSchema
from app.util import add_obj_history_entry
diff --git a/source/app/business/tasks.py b/source/app/business/tasks.py
index cd6230444..9a026d537 100644
--- a/source/app/business/tasks.py
+++ b/source/app/business/tasks.py
@@ -29,7 +29,7 @@
from app.datamgmt.states import update_tasks_state
from app.iris_engine.module_handler.module_handler import call_modules_hook
from app.iris_engine.utils.tracker import track_activity
-from app.models import CaseTasks
+from app.models.models import CaseTasks
from app.schema.marshables import CaseTaskSchema
from app.business.errors import BusinessProcessingError
from app.business.errors import ObjectNotFoundError
diff --git a/source/app/datamgmt/alerts/alerts_db.py b/source/app/datamgmt/alerts/alerts_db.py
index bd6572066..4d4458b91 100644
--- a/source/app/datamgmt/alerts/alerts_db.py
+++ b/source/app/datamgmt/alerts/alerts_db.py
@@ -49,14 +49,14 @@
from app.datamgmt.manage.manage_case_templates_db import case_template_post_modifier
from app.datamgmt.states import update_timeline_state
from app.models.cases import Cases
-from app.models import EventCategory
-from app.models import Tags
-from app.models import AssetsType
-from app.models import Comments
-from app.models import CaseAssets
-from app.models import alert_assets_association
-from app.models import alert_iocs_association
-from app.models import Ioc
+from app.models.models import EventCategory
+from app.models.models import Tags
+from app.models.models import AssetsType
+from app.models.models import Comments
+from app.models.models import CaseAssets
+from app.models.models import alert_assets_association
+from app.models.models import alert_iocs_association
+from app.models.models import Ioc
from app.models.alerts import Alert
from app.models.alerts import AlertStatus
from app.models.alerts import AlertCaseAssociation
diff --git a/source/app/datamgmt/case/case_assets_db.py b/source/app/datamgmt/case/case_assets_db.py
index eba5020c6..d76b4bd05 100644
--- a/source/app/datamgmt/case/case_assets_db.py
+++ b/source/app/datamgmt/case/case_assets_db.py
@@ -24,18 +24,18 @@
from app import db, app
from app.datamgmt.states import update_assets_state
-from app.models import AnalysisStatus
-from app.models import CaseStatus
-from app.models import AssetComments
-from app.models import AssetsType
-from app.models import CaseAssets
-from app.models import CaseEventsAssets
+from app.models.models import AnalysisStatus
+from app.models.models import CaseStatus
+from app.models.models import AssetComments
+from app.models.models import AssetsType
+from app.models.models import CaseAssets
+from app.models.models import CaseEventsAssets
from app.models.cases import Cases
-from app.models import Comments
-from app.models import CompromiseStatus
-from app.models import Ioc
-from app.models import IocAssetLink
-from app.models import IocType
+from app.models.models import Comments
+from app.models.models import CompromiseStatus
+from app.models.models import Ioc
+from app.models.models import IocAssetLink
+from app.models.models import IocType
from app.models.authorization import User
diff --git a/source/app/datamgmt/case/case_comments.py b/source/app/datamgmt/case/case_comments.py
index e34410619..890f2ba8c 100644
--- a/source/app/datamgmt/case/case_comments.py
+++ b/source/app/datamgmt/case/case_comments.py
@@ -16,7 +16,7 @@
# 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.models import Comments
+from app.models.models import Comments
def get_case_comment(comment_id, caseid):
diff --git a/source/app/datamgmt/case/case_events_db.py b/source/app/datamgmt/case/case_events_db.py
index af8a49388..c124a907a 100644
--- a/source/app/datamgmt/case/case_events_db.py
+++ b/source/app/datamgmt/case/case_events_db.py
@@ -20,18 +20,18 @@
from app import db
from app.datamgmt.states import update_timeline_state
-from app.models import AssetsType
-from app.models import CaseAssets
-from app.models import CaseEventCategory
-from app.models import CaseEventsAssets
-from app.models import CaseEventsIoc
+from app.models.models import AssetsType
+from app.models.models import CaseAssets
+from app.models.models import CaseEventCategory
+from app.models.models import CaseEventsAssets
+from app.models.models import CaseEventsIoc
from app.models.cases import CasesEvent
-from app.models import Comments
-from app.models import EventCategory
-from app.models import EventComments
-from app.models import Ioc
-from app.models import IocAssetLink
-from app.models import IocType
+from app.models.models import Comments
+from app.models.models import EventCategory
+from app.models.models import EventComments
+from app.models.models import Ioc
+from app.models.models import IocAssetLink
+from app.models.models import IocType
from app.models.authorization import User
diff --git a/source/app/datamgmt/case/case_iocs_db.py b/source/app/datamgmt/case/case_iocs_db.py
index f96acd870..355525a9a 100644
--- a/source/app/datamgmt/case/case_iocs_db.py
+++ b/source/app/datamgmt/case/case_iocs_db.py
@@ -27,11 +27,11 @@
from app.iris_engine.access_control.utils import ac_get_fast_user_cases_access
from app.models.cases import Cases
from app.models.models import Client
-from app.models import Comments
-from app.models import Ioc
-from app.models import IocComments
-from app.models import IocType
-from app.models import Tlp
+from app.models.models import Comments
+from app.models.models import Ioc
+from app.models.models import IocComments
+from app.models.models import IocType
+from app.models.models import Tlp
from app.models.authorization import User
from app.models.authorization import UserCaseEffectiveAccess
from app.models.authorization import CaseAccessLevel
diff --git a/source/app/datamgmt/case/case_notes_db.py b/source/app/datamgmt/case/case_notes_db.py
index 5871c1e25..9a5ad5140 100644
--- a/source/app/datamgmt/case/case_notes_db.py
+++ b/source/app/datamgmt/case/case_notes_db.py
@@ -21,11 +21,13 @@
from app import db
from app.datamgmt.manage.manage_attribute_db import get_default_custom_attributes
from app.datamgmt.states import update_notes_state
-from app.models import Comments, NoteDirectory, NoteRevisions
-from app.models import Notes
-from app.models import NotesComments
-from app.models import NotesGroup
-from app.models import NotesGroupLink
+from app.models.models import Comments
+from app.models.models import NoteDirectory
+from app.models.models import NoteRevisions
+from app.models.models import Notes
+from app.models.models import NotesComments
+from app.models.models import NotesGroup
+from app.models.models import NotesGroupLink
from app.models.authorization import User
diff --git a/source/app/datamgmt/case/case_rfiles_db.py b/source/app/datamgmt/case/case_rfiles_db.py
index 3425972a6..950cf3704 100644
--- a/source/app/datamgmt/case/case_rfiles_db.py
+++ b/source/app/datamgmt/case/case_rfiles_db.py
@@ -24,9 +24,9 @@
from app import db
from app.datamgmt.manage.manage_attribute_db import get_default_custom_attributes
from app.datamgmt.states import update_evidences_state
-from app.models import CaseReceivedFile
-from app.models import Comments
-from app.models import EvidencesComments
+from app.models.models import CaseReceivedFile
+from app.models.models import Comments
+from app.models.models import EvidencesComments
from app.models.authorization import User
diff --git a/source/app/datamgmt/case/case_tasks_db.py b/source/app/datamgmt/case/case_tasks_db.py
index 1697737ae..9f78c9278 100644
--- a/source/app/datamgmt/case/case_tasks_db.py
+++ b/source/app/datamgmt/case/case_tasks_db.py
@@ -25,12 +25,12 @@
from app.datamgmt.manage.manage_attribute_db import get_default_custom_attributes
from app.datamgmt.manage.manage_users_db import get_users_list_restricted_from_case
from app.datamgmt.states import update_tasks_state
-from app.models import CaseTasks
-from app.models import TaskAssignee
+from app.models.models import CaseTasks
+from app.models.models import TaskAssignee
from app.models.cases import Cases
-from app.models import Comments
-from app.models import TaskComments
-from app.models import TaskStatus
+from app.models.models import Comments
+from app.models.models import TaskComments
+from app.models.models import TaskStatus
from app.models.authorization import User
diff --git a/source/app/datamgmt/client/client_db.py b/source/app/datamgmt/client/client_db.py
index 5e99932c3..b81bae752 100644
--- a/source/app/datamgmt/client/client_db.py
+++ b/source/app/datamgmt/client/client_db.py
@@ -25,7 +25,7 @@
from app.datamgmt.exceptions.ElementExceptions import ElementNotFoundException
from app.models.cases import Cases
from app.models.models import Client
-from app.models import Contact
+from app.models.models import Contact
from app.models.authorization import User
from app.models.authorization import UserClient
from app.schema.marshables import ContactSchema
diff --git a/source/app/datamgmt/dashboard/dashboard_db.py b/source/app/datamgmt/dashboard/dashboard_db.py
index e522db532..20c213e46 100644
--- a/source/app/datamgmt/dashboard/dashboard_db.py
+++ b/source/app/datamgmt/dashboard/dashboard_db.py
@@ -20,12 +20,12 @@
from sqlalchemy import desc
from app import db
-from app.models import CaseTasks
-from app.models import TaskAssignee
-from app.models import ReviewStatus
+from app.models.models import CaseTasks
+from app.models.models import TaskAssignee
+from app.models.models import ReviewStatus
from app.models.cases import Cases
-from app.models import GlobalTasks
-from app.models import TaskStatus
+from app.models.models import GlobalTasks
+from app.models.models import TaskStatus
from app.models.authorization import User
diff --git a/source/app/datamgmt/datastore/datastore_db.py b/source/app/datamgmt/datastore/datastore_db.py
index 5135e06fa..fa6b85f19 100644
--- a/source/app/datamgmt/datastore/datastore_db.py
+++ b/source/app/datamgmt/datastore/datastore_db.py
@@ -27,12 +27,12 @@
from app import app
from app import db
-from app.models import CaseReceivedFile
-from app.models import DataStoreFile
-from app.models import DataStorePath
-from app.models import Ioc
-from app.models import IocType
-from app.models import Tlp
+from app.models.models import CaseReceivedFile
+from app.models.models import DataStoreFile
+from app.models.models import DataStorePath
+from app.models.models import Ioc
+from app.models.models import IocType
+from app.models.models import Tlp
def datastore_get_root(cid):
diff --git a/source/app/datamgmt/filters/filters_db.py b/source/app/datamgmt/filters/filters_db.py
index 759e1d79c..56f828d97 100644
--- a/source/app/datamgmt/filters/filters_db.py
+++ b/source/app/datamgmt/filters/filters_db.py
@@ -1,7 +1,7 @@
from flask_login import current_user
from sqlalchemy import and_
-from app.models import SavedFilter
+from app.models.models import SavedFilter
def get_filter_by_id(filter_id):
diff --git a/source/app/datamgmt/iris_engine/evidence_storage.py b/source/app/datamgmt/iris_engine/evidence_storage.py
index a65b28a27..21ce14d14 100644
--- a/source/app/datamgmt/iris_engine/evidence_storage.py
+++ b/source/app/datamgmt/iris_engine/evidence_storage.py
@@ -17,7 +17,7 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from app.datamgmt.case.case_rfiles_db import add_rfile
-from app.models import CaseReceivedFile
+from app.models.models import CaseReceivedFile
class EvidenceStorage(object):
diff --git a/source/app/datamgmt/iris_engine/modules_db.py b/source/app/datamgmt/iris_engine/modules_db.py
index 503f5980a..1abde96ae 100644
--- a/source/app/datamgmt/iris_engine/modules_db.py
+++ b/source/app/datamgmt/iris_engine/modules_db.py
@@ -20,9 +20,9 @@
from flask_login import current_user
from app import db, app
-from app.models import IrisHook
-from app.models import IrisModule
-from app.models import IrisModuleHook
+from app.models.models import IrisHook
+from app.models.models import IrisModule
+from app.models.models import IrisModuleHook
from app.models.authorization import User
log = app.logger
diff --git a/source/app/datamgmt/manage/manage_assets_db.py b/source/app/datamgmt/manage/manage_assets_db.py
index 637eef04c..1daad63f1 100644
--- a/source/app/datamgmt/manage/manage_assets_db.py
+++ b/source/app/datamgmt/manage/manage_assets_db.py
@@ -24,7 +24,7 @@
import app
from app.datamgmt.manage.manage_cases_db import user_list_cases_view
-from app.models import CaseAssets
+from app.models.models import CaseAssets
from app.models.models import Client
from app.models.cases import Cases
diff --git a/source/app/datamgmt/manage/manage_attribute_db.py b/source/app/datamgmt/manage/manage_attribute_db.py
index 03082fa74..86924f10f 100644
--- a/source/app/datamgmt/manage/manage_attribute_db.py
+++ b/source/app/datamgmt/manage/manage_attribute_db.py
@@ -21,15 +21,15 @@
from app import db
from app import app
-from app.models import CaseAssets
-from app.models import CaseReceivedFile
-from app.models import CaseTasks
+from app.models.models import CaseAssets
+from app.models.models import CaseReceivedFile
+from app.models.models import CaseTasks
from app.models.cases import Cases
from app.models.cases import CasesEvent
from app.models.models import Client
-from app.models import CustomAttribute
-from app.models import Ioc
-from app.models import Notes
+from app.models.models import CustomAttribute
+from app.models.models import Ioc
+from app.models.models import Notes
log = logger.getLogger(__name__)
diff --git a/source/app/datamgmt/manage/manage_case_classifications_db.py b/source/app/datamgmt/manage/manage_case_classifications_db.py
index 5f0adcece..09eb1fca8 100644
--- a/source/app/datamgmt/manage/manage_case_classifications_db.py
+++ b/source/app/datamgmt/manage/manage_case_classifications_db.py
@@ -17,7 +17,7 @@
from sqlalchemy import func
from typing import List
-from app.models import CaseClassification
+from app.models.models import CaseClassification
def get_case_classifications_list() -> List[dict]:
diff --git a/source/app/datamgmt/manage/manage_case_objs.py b/source/app/datamgmt/manage/manage_case_objs.py
index 014d77658..8ed653fcc 100644
--- a/source/app/datamgmt/manage/manage_case_objs.py
+++ b/source/app/datamgmt/manage/manage_case_objs.py
@@ -17,7 +17,10 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from sqlalchemy import func
-from app.models import AnalysisStatus, IocType, AssetsType, EventCategory
+from app.models.models import AnalysisStatus
+from app.models.models import IocType
+from app.models.models import AssetsType
+from app.models.models import EventCategory
def search_analysis_status_by_name(name: str, exact_match: bool = False) -> AnalysisStatus:
diff --git a/source/app/datamgmt/manage/manage_case_templates_db.py b/source/app/datamgmt/manage/manage_case_templates_db.py
index e6661e1c6..99691dde7 100644
--- a/source/app/datamgmt/manage/manage_case_templates_db.py
+++ b/source/app/datamgmt/manage/manage_case_templates_db.py
@@ -25,10 +25,10 @@
from app.datamgmt.case.case_tasks_db import add_task
from app.datamgmt.manage.manage_case_classifications_db import get_case_classification_by_name
from app.iris_engine.module_handler.module_handler import call_modules_hook
-from app.models import CaseTemplate
+from app.models.models import CaseTemplate
from app.models.cases import Cases
-from app.models import Tags
-from app.models import NoteDirectory
+from app.models.models import Tags
+from app.models.models import NoteDirectory
from app.models.authorization import User
from app.schema.marshables import CaseSchema
from app.schema.marshables import CaseTaskSchema
diff --git a/source/app/datamgmt/manage/manage_cases_db.py b/source/app/datamgmt/manage/manage_cases_db.py
index 9239f47b8..6b80fec52 100644
--- a/source/app/datamgmt/manage/manage_cases_db.py
+++ b/source/app/datamgmt/manage/manage_cases_db.py
@@ -33,28 +33,29 @@
from app.datamgmt.manage.manage_case_state_db import get_case_state_by_name
from app.datamgmt.authorization import has_deny_all_access_level
from app.datamgmt.states import delete_case_states
-from app.models import CaseAssets, NoteRevisions
-from app.models import CaseClassification
-from app.models import alert_assets_association
-from app.models import CaseStatus
-from app.models import TaskAssignee
-from app.models import NoteDirectory
-from app.models import Tags
-from app.models import CaseEventCategory
-from app.models import CaseEventsAssets
-from app.models import CaseEventsIoc
-from app.models import CaseReceivedFile
-from app.models import CaseTasks
+from app.models.models import CaseAssets
+from app.models.models import NoteRevisions
+from app.models.models import CaseClassification
+from app.models.models import alert_assets_association
+from app.models.models import CaseStatus
+from app.models.models import TaskAssignee
+from app.models.models import NoteDirectory
+from app.models.models import Tags
+from app.models.models import CaseEventCategory
+from app.models.models import CaseEventsAssets
+from app.models.models import CaseEventsIoc
+from app.models.models import CaseReceivedFile
+from app.models.models import CaseTasks
from app.models.cases import Cases
from app.models.cases import CasesEvent
from app.models.models import Client
-from app.models import DataStoreFile
-from app.models import DataStorePath
-from app.models import IocAssetLink
-from app.models import Notes
-from app.models import NotesGroup
-from app.models import NotesGroupLink
-from app.models import UserActivity
+from app.models.models import DataStoreFile
+from app.models.models import DataStorePath
+from app.models.models import IocAssetLink
+from app.models.models import Notes
+from app.models.models import NotesGroup
+from app.models.models import NotesGroupLink
+from app.models.models import UserActivity
from app.models.alerts import AlertCaseAssociation
from app.models.authorization import CaseAccessLevel
from app.models.authorization import GroupCaseAccess
diff --git a/source/app/datamgmt/manage/manage_evidence_types_db.py b/source/app/datamgmt/manage/manage_evidence_types_db.py
index 2184d9f1f..33c2b11a1 100644
--- a/source/app/datamgmt/manage/manage_evidence_types_db.py
+++ b/source/app/datamgmt/manage/manage_evidence_types_db.py
@@ -17,7 +17,8 @@
from sqlalchemy import func
from typing import List
-from app.models import EvidenceTypes, CaseReceivedFile
+from app.models.models import EvidenceTypes
+from app.models.models import CaseReceivedFile
def get_evidence_types_list() -> List[dict]:
diff --git a/source/app/datamgmt/manage/manage_srv_settings_db.py b/source/app/datamgmt/manage/manage_srv_settings_db.py
index 9dcd8dee2..a7e77b282 100644
--- a/source/app/datamgmt/manage/manage_srv_settings_db.py
+++ b/source/app/datamgmt/manage/manage_srv_settings_db.py
@@ -1,7 +1,7 @@
from sqlalchemy import text
from app import db
-from app.models import ServerSettings
+from app.models.models import ServerSettings
from app.schema.marshables import ServerSettingsSchema
diff --git a/source/app/datamgmt/manage/manage_tags_db.py b/source/app/datamgmt/manage/manage_tags_db.py
index 170bb4271..c472be086 100644
--- a/source/app/datamgmt/manage/manage_tags_db.py
+++ b/source/app/datamgmt/manage/manage_tags_db.py
@@ -1,9 +1,11 @@
from functools import reduce
-from sqlalchemy import and_, desc, asc
+from sqlalchemy import and_
+from sqlalchemy import desc
+from sqlalchemy import asc
import app
-from app.models import Tags
+from app.models.models import Tags
def get_filtered_tags(tag_title=None,
diff --git a/source/app/datamgmt/reporter/report_db.py b/source/app/datamgmt/reporter/report_db.py
index 0e5c107c9..8272724c0 100644
--- a/source/app/datamgmt/reporter/report_db.py
+++ b/source/app/datamgmt/reporter/report_db.py
@@ -22,26 +22,26 @@
from app.datamgmt.case.case_notes_db import get_notes_from_group
from app.datamgmt.case.case_notes_db import get_case_note_comments
-from app.models import AnalysisStatus
-from app.models import CompromiseStatus
-from app.models import TaskAssignee
-from app.models import AssetsType
-from app.models import CaseAssets
-from app.models import CaseEventsAssets
-from app.models import CaseEventsIoc
-from app.models import CaseReceivedFile
-from app.models import CaseTasks
+from app.models.models import AnalysisStatus
+from app.models.models import CompromiseStatus
+from app.models.models import TaskAssignee
+from app.models.models import AssetsType
+from app.models.models import CaseAssets
+from app.models.models import CaseEventsAssets
+from app.models.models import CaseEventsIoc
+from app.models.models import CaseReceivedFile
+from app.models.models import CaseTasks
from app.models.cases import Cases
from app.models.cases import CasesEvent
-from app.models import Comments
-from app.models import EventCategory
-from app.models import Ioc
-from app.models import IocAssetLink
-from app.models import IocType
-from app.models import Notes
-from app.models import NotesGroup
-from app.models import TaskStatus
-from app.models import Tlp
+from app.models.models import Comments
+from app.models.models import EventCategory
+from app.models.models import Ioc
+from app.models.models import IocAssetLink
+from app.models.models import IocType
+from app.models.models import Notes
+from app.models.models import NotesGroup
+from app.models.models import TaskStatus
+from app.models.models import Tlp
from app.models.authorization import User
from app.schema.marshables import CaseDetailsSchema
from app.schema.marshables import CommentSchema
diff --git a/source/app/iris_engine/demo_builder.py b/source/app/iris_engine/demo_builder.py
index bfcea49e8..57b67f83c 100644
--- a/source/app/iris_engine/demo_builder.py
+++ b/source/app/iris_engine/demo_builder.py
@@ -30,7 +30,7 @@
from app.iris_engine.access_control.utils import ac_add_users_multi_effective_access
from app.models.cases import Cases
from app.models.models import Client
-from app.models import get_or_create
+from app.models.models import get_or_create
from app.models.authorization import CaseAccessLevel
from app.models.authorization import User
diff --git a/source/app/iris_engine/module_handler/module_handler.py b/source/app/iris_engine/module_handler/module_handler.py
index ad3aac0d2..9011d94ef 100644
--- a/source/app/iris_engine/module_handler/module_handler.py
+++ b/source/app/iris_engine/module_handler/module_handler.py
@@ -34,9 +34,9 @@
from app.datamgmt.iris_engine.modules_db import iris_module_add
from app.datamgmt.iris_engine.modules_db import iris_module_exists
from app.datamgmt.iris_engine.modules_db import modules_list_pipelines
-from app.models import IrisHook
-from app.models import IrisModule
-from app.models import IrisModuleHook
+from app.models.models import IrisHook
+from app.models.models import IrisModule
+from app.models.models import IrisModuleHook
from app.util import hmac_sign
from app.util import hmac_verify
from iris_interface import IrisInterfaceStatus as IStatus
diff --git a/source/app/iris_engine/reporter/reporter.py b/source/app/iris_engine/reporter/reporter.py
index 630d844d5..c90253f8e 100644
--- a/source/app/iris_engine/reporter/reporter.py
+++ b/source/app/iris_engine/reporter/reporter.py
@@ -34,14 +34,14 @@
from app.datamgmt.activities.activities_db import get_manual_activities
from app.datamgmt.case.case_db import case_get_desc_crc
-from app.models import AssetsType
-from app.models import CaseAssets
-from app.models import CaseEventsAssets
-from app.models import CaseReceivedFile
-from app.models import CaseTemplateReport
+from app.models.models import AssetsType
+from app.models.models import CaseAssets
+from app.models.models import CaseEventsAssets
+from app.models.models import CaseReceivedFile
+from app.models.models import CaseTemplateReport
from app.models.cases import CasesEvent
-from app.models import Ioc
-from app.models import IocAssetLink
+from app.models.models import Ioc
+from app.models.models import IocAssetLink
from app.iris_engine.reporter.ImageHandler import ImageHandler
from app.iris_engine.utils.common import IrisJinjaEnv
diff --git a/source/app/iris_engine/updater/updater.py b/source/app/iris_engine/updater/updater.py
index 3e9fcb664..680d83fc6 100644
--- a/source/app/iris_engine/updater/updater.py
+++ b/source/app/iris_engine/updater/updater.py
@@ -39,7 +39,7 @@
from app import socket_io
from app.datamgmt.manage.manage_srv_settings_db import get_server_settings_as_dict
from app.iris_engine.backup.backup import backup_iris_db
-from app.models import ServerSettings
+from app.models.models import ServerSettings
from iris_interface import IrisInterfaceStatus as IStatus
log = app.logger
diff --git a/source/app/iris_engine/utils/tracker.py b/source/app/iris_engine/utils/tracker.py
index 59e086caf..bdddec88a 100644
--- a/source/app/iris_engine/utils/tracker.py
+++ b/source/app/iris_engine/utils/tracker.py
@@ -16,19 +16,17 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-# IMPORTS ------------------------------------------------
from datetime import datetime
from flask import request
from flask_login import current_user
import app
from app import db
-from app.models import UserActivity
+from app.models.models import UserActivity
log = app.app.logger
-# CONTENT ------------------------------------------------
def track_activity(message, caseid=None, ctx_less=False, user_input=False, display_in_ui=True):
"""
Register a user activity in DB.
diff --git a/source/app/models/__init__.py b/source/app/models/__init__.py
index b34daaa59..e69de29bb 100644
--- a/source/app/models/__init__.py
+++ b/source/app/models/__init__.py
@@ -1,2 +0,0 @@
-from app.models.models import *
-
diff --git a/source/app/models/alerts.py b/source/app/models/alerts.py
index 6ae521bd9..3bb3d146d 100644
--- a/source/app/models/alerts.py
+++ b/source/app/models/alerts.py
@@ -13,7 +13,8 @@
from sqlalchemy.orm import relationship
from app import db
-from app.models import alert_assets_association, alert_iocs_association
+from app.models.models import alert_assets_association
+from app.models.models import alert_iocs_association
class AlertCaseAssociation(db.Model):
diff --git a/source/app/schema/marshables.py b/source/app/schema/marshables.py
index 7256abbf3..d4d974138 100644
--- a/source/app/schema/marshables.py
+++ b/source/app/schema/marshables.py
@@ -53,37 +53,37 @@
from app.datamgmt.manage.manage_tags_db import add_db_tag
from app.datamgmt.case.case_iocs_db import get_ioc_links
from app.iris_engine.access_control.utils import ac_mask_from_val_list
-from app.models import AnalysisStatus
-from app.models import CaseClassification
-from app.models import SavedFilter
-from app.models import DataStorePath
-from app.models import IrisModuleHook
-from app.models import Tags
-from app.models import ReviewStatus
-from app.models import EvidenceTypes
-from app.models import CaseStatus
-from app.models import NoteDirectory
-from app.models import NoteRevisions
-from app.models import AssetsType
-from app.models import CaseAssets
-from app.models import CaseReceivedFile
-from app.models import CaseTasks
+from app.models.models import AnalysisStatus
+from app.models.models import CaseClassification
+from app.models.models import SavedFilter
+from app.models.models import DataStorePath
+from app.models.models import IrisModuleHook
+from app.models.models import Tags
+from app.models.models import ReviewStatus
+from app.models.models import EvidenceTypes
+from app.models.models import CaseStatus
+from app.models.models import NoteDirectory
+from app.models.models import NoteRevisions
+from app.models.models import AssetsType
+from app.models.models import CaseAssets
+from app.models.models import CaseReceivedFile
+from app.models.models import CaseTasks
from app.models.cases import Cases
from app.models.cases import CasesEvent
from app.models.models import Client
-from app.models import Comments
-from app.models import Contact
-from app.models import DataStoreFile
-from app.models import EventCategory
-from app.models import GlobalTasks
-from app.models import Ioc
-from app.models import IocType
-from app.models import IrisModule
-from app.models import Notes
-from app.models import NotesGroup
-from app.models import ServerSettings
-from app.models import TaskStatus
-from app.models import Tlp
+from app.models.models import Comments
+from app.models.models import Contact
+from app.models.models import DataStoreFile
+from app.models.models import EventCategory
+from app.models.models import GlobalTasks
+from app.models.models import Ioc
+from app.models.models import IocType
+from app.models.models import IrisModule
+from app.models.models import Notes
+from app.models.models import NotesGroup
+from app.models.models import ServerSettings
+from app.models.models import TaskStatus
+from app.models.models import Tlp
from app.models.alerts import Alert
from app.models.alerts import Severity
from app.models.alerts import AlertStatus
From 0549d8121a412781d00541491ca5ed10678fd0b0 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Tue, 17 Dec 2024 16:13:48 +0100
Subject: [PATCH 33/37] Activate F403 ruff rule
---
pyproject.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyproject.toml b/pyproject.toml
index e65af88b9..786dd58cc 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,2 +1,2 @@
[tool.ruff.lint]
-ignore = ["E402", "E711", "E712", "E721", "E722", "F401", "F403", "F821"]
+ignore = ["E402", "E711", "E712", "E721", "E722", "F401", "F821"]
From b5f283e5f7fbfb50ed40620b5fa29e21cedd9353 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Wed, 18 Dec 2024 11:41:38 +0100
Subject: [PATCH 34/37] Create method to register blueprints, move up call to
post_init in __init__.py
---
source/app/__init__.py | 15 +++-
source/app/views.py | 185 ++++++++++++++++++++---------------------
2 files changed, 102 insertions(+), 98 deletions(-)
diff --git a/source/app/__init__.py b/source/app/__init__.py
index ddc1a5aa0..7553fb91c 100644
--- a/source/app/__init__.py
+++ b/source/app/__init__.py
@@ -140,4 +140,17 @@ def shutdown_session(exception=None):
db.session.remove()
-from app import views
+from app.views import register_blueprints
+
+register_blueprints(app)
+
+from app.post_init import run_post_init
+
+try:
+
+ run_post_init(development=app.config['DEVELOPMENT'])
+
+except Exception as e:
+ app.logger.exception('Post init failed. IRIS not started')
+ raise e
+
diff --git a/source/app/views.py b/source/app/views.py
index a7d944ae2..eecfc4dc3 100644
--- a/source/app/views.py
+++ b/source/app/views.py
@@ -17,7 +17,6 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-from app import app
from app import lm
from app.blueprints.pages.activities.activities_routes import activities_blueprint
from app.blueprints.pages.alerts.alerts_routes import alerts_blueprint
@@ -102,102 +101,94 @@
from app.blueprints.rest.v2.case.api_v2_ioc_routes import api_v2_ioc_blueprint
from app.blueprints.rest.v2.case.api_v2_case_tasks_routes import api_v2_tasks_blueprint
from app.models.authorization import User
-from app.post_init import run_post_init
-
-
-app.register_blueprint(graphql_blueprint)
-app.register_blueprint(dashboard_blueprint)
-app.register_blueprint(dashboard_rest_blueprint)
-app.register_blueprint(overview_blueprint)
-app.register_blueprint(overview_rest_blueprint)
-app.register_blueprint(login_blueprint)
-app.register_blueprint(profile_blueprint)
-app.register_blueprint(profile_rest_blueprint)
-app.register_blueprint(search_blueprint)
-app.register_blueprint(search_rest_blueprint)
-app.register_blueprint(manage_cases_blueprint)
-app.register_blueprint(manage_cases_rest_blueprint)
-app.register_blueprint(manage_assets_type_blueprint)
-app.register_blueprint(manage_assets_type_rest_blueprint)
-app.register_blueprint(manage_srv_settings_blueprint)
-app.register_blueprint(manage_server_settings_rest_blueprint)
-app.register_blueprint(manage_users_blueprint)
-app.register_blueprint(manage_users_rest_blueprint)
-app.register_blueprint(manage_templates_blueprint)
-app.register_blueprint(manage_templates_rest_blueprint)
-app.register_blueprint(manage_modules_blueprint)
-app.register_blueprint(manage_modules_rest_blueprint)
-app.register_blueprint(manage_customers_blueprint)
-app.register_blueprint(manage_customers_rest_blueprint)
-app.register_blueprint(manage_analysis_status_rest_blueprint)
-app.register_blueprint(manage_ioc_type_blueprint)
-app.register_blueprint(manage_ioc_type_rest_blueprint)
-app.register_blueprint(manage_event_categories_rest_blueprint)
-app.register_blueprint(manage_objects_blueprint)
-app.register_blueprint(manage_tlp_type_rest_blueprint)
-app.register_blueprint(manage_case_templates_blueprint)
-app.register_blueprint(manage_case_templates_rest_blueprint)
-app.register_blueprint(manage_task_status_rest_blueprint)
-app.register_blueprint(manage_attributes_blueprint)
-app.register_blueprint(manage_attributes_rest_blueprint)
-app.register_blueprint(manage_ac_blueprint)
-app.register_blueprint(manage_ac_rest_blueprint)
-app.register_blueprint(manage_groups_blueprint)
-app.register_blueprint(manage_groups_rest_blueprint)
-app.register_blueprint(manage_case_classification_blueprint)
-app.register_blueprint(manage_case_classification_rest_blueprint)
-app.register_blueprint(manage_alerts_status_rest_blueprint)
-app.register_blueprint(manage_severities_rest_blueprint)
-app.register_blueprint(manage_case_state_blueprint)
-app.register_blueprint(manage_case_state_rest_blueprint)
-app.register_blueprint(manage_evidence_types_blueprint)
-app.register_blueprint(manage_evidence_types_rest_blueprint)
-app.register_blueprint(manage_assets_rest_blueprint)
-app.register_blueprint(manage_tags_rest_blueprint)
-app.register_blueprint(saved_filters_rest_blueprint)
-
-app.register_blueprint(context_rest_blueprint)
-app.register_blueprint(case_timeline_blueprint)
-app.register_blueprint(case_timeline_rest_blueprint)
-app.register_blueprint(case_notes_blueprint)
-app.register_blueprint(case_notes_rest_blueprint)
-app.register_blueprint(case_assets_blueprint)
-app.register_blueprint(case_assets_rest_blueprint)
-app.register_blueprint(case_ioc_blueprint)
-app.register_blueprint(case_ioc_rest_blueprint)
-app.register_blueprint(case_rfiles_blueprint)
-app.register_blueprint(case_evidences_rest_blueprint)
-app.register_blueprint(case_graph_blueprint)
-app.register_blueprint(case_graph_rest_blueprint)
-app.register_blueprint(case_tasks_blueprint)
-app.register_blueprint(case_tasks_rest_blueprint)
-app.register_blueprint(case_blueprint)
-app.register_blueprint(case_rest_blueprint)
-app.register_blueprint(reports_rest_blueprint)
-app.register_blueprint(activities_blueprint)
-app.register_blueprint(activities_rest_blueprint)
-app.register_blueprint(dim_tasks_blueprint)
-app.register_blueprint(dim_tasks_rest_blueprint)
-app.register_blueprint(datastore_blueprint)
-app.register_blueprint(datastore_rest_blueprint)
-app.register_blueprint(alerts_blueprint)
-app.register_blueprint(alerts_rest_blueprint)
-
-app.register_blueprint(rest_api_blueprint)
-app.register_blueprint(demo_blueprint)
-
-app.register_blueprint(api_v2_case_blueprint)
-app.register_blueprint(api_v2_ioc_blueprint)
-app.register_blueprint(api_v2_assets_blueprint)
-app.register_blueprint(api_v2_tasks_blueprint)
-
-try:
-
- run_post_init(development=app.config["DEVELOPMENT"])
-
-except Exception as e:
- app.logger.exception("Post init failed. IRIS not started")
- raise e
+
+
+def register_blueprints(app):
+ app.register_blueprint(graphql_blueprint)
+ app.register_blueprint(dashboard_blueprint)
+ app.register_blueprint(dashboard_rest_blueprint)
+ app.register_blueprint(overview_blueprint)
+ app.register_blueprint(overview_rest_blueprint)
+ app.register_blueprint(login_blueprint)
+ app.register_blueprint(profile_blueprint)
+ app.register_blueprint(profile_rest_blueprint)
+ app.register_blueprint(search_blueprint)
+ app.register_blueprint(search_rest_blueprint)
+ app.register_blueprint(manage_cases_blueprint)
+ app.register_blueprint(manage_cases_rest_blueprint)
+ app.register_blueprint(manage_assets_type_blueprint)
+ app.register_blueprint(manage_assets_type_rest_blueprint)
+ app.register_blueprint(manage_srv_settings_blueprint)
+ app.register_blueprint(manage_server_settings_rest_blueprint)
+ app.register_blueprint(manage_users_blueprint)
+ app.register_blueprint(manage_users_rest_blueprint)
+ app.register_blueprint(manage_templates_blueprint)
+ app.register_blueprint(manage_templates_rest_blueprint)
+ app.register_blueprint(manage_modules_blueprint)
+ app.register_blueprint(manage_modules_rest_blueprint)
+ app.register_blueprint(manage_customers_blueprint)
+ app.register_blueprint(manage_customers_rest_blueprint)
+ app.register_blueprint(manage_analysis_status_rest_blueprint)
+ app.register_blueprint(manage_ioc_type_blueprint)
+ app.register_blueprint(manage_ioc_type_rest_blueprint)
+ app.register_blueprint(manage_event_categories_rest_blueprint)
+ app.register_blueprint(manage_objects_blueprint)
+ app.register_blueprint(manage_tlp_type_rest_blueprint)
+ app.register_blueprint(manage_case_templates_blueprint)
+ app.register_blueprint(manage_case_templates_rest_blueprint)
+ app.register_blueprint(manage_task_status_rest_blueprint)
+ app.register_blueprint(manage_attributes_blueprint)
+ app.register_blueprint(manage_attributes_rest_blueprint)
+ app.register_blueprint(manage_ac_blueprint)
+ app.register_blueprint(manage_ac_rest_blueprint)
+ app.register_blueprint(manage_groups_blueprint)
+ app.register_blueprint(manage_groups_rest_blueprint)
+ app.register_blueprint(manage_case_classification_blueprint)
+ app.register_blueprint(manage_case_classification_rest_blueprint)
+ app.register_blueprint(manage_alerts_status_rest_blueprint)
+ app.register_blueprint(manage_severities_rest_blueprint)
+ app.register_blueprint(manage_case_state_blueprint)
+ app.register_blueprint(manage_case_state_rest_blueprint)
+ app.register_blueprint(manage_evidence_types_blueprint)
+ app.register_blueprint(manage_evidence_types_rest_blueprint)
+ app.register_blueprint(manage_assets_rest_blueprint)
+ app.register_blueprint(manage_tags_rest_blueprint)
+ app.register_blueprint(saved_filters_rest_blueprint)
+
+ app.register_blueprint(context_rest_blueprint)
+ app.register_blueprint(case_timeline_blueprint)
+ app.register_blueprint(case_timeline_rest_blueprint)
+ app.register_blueprint(case_notes_blueprint)
+ app.register_blueprint(case_notes_rest_blueprint)
+ app.register_blueprint(case_assets_blueprint)
+ app.register_blueprint(case_assets_rest_blueprint)
+ app.register_blueprint(case_ioc_blueprint)
+ app.register_blueprint(case_ioc_rest_blueprint)
+ app.register_blueprint(case_rfiles_blueprint)
+ app.register_blueprint(case_evidences_rest_blueprint)
+ app.register_blueprint(case_graph_blueprint)
+ app.register_blueprint(case_graph_rest_blueprint)
+ app.register_blueprint(case_tasks_blueprint)
+ app.register_blueprint(case_tasks_rest_blueprint)
+ app.register_blueprint(case_blueprint)
+ app.register_blueprint(case_rest_blueprint)
+ app.register_blueprint(reports_rest_blueprint)
+ app.register_blueprint(activities_blueprint)
+ app.register_blueprint(activities_rest_blueprint)
+ app.register_blueprint(dim_tasks_blueprint)
+ app.register_blueprint(dim_tasks_rest_blueprint)
+ app.register_blueprint(datastore_blueprint)
+ app.register_blueprint(datastore_rest_blueprint)
+ app.register_blueprint(alerts_blueprint)
+ app.register_blueprint(alerts_rest_blueprint)
+
+ app.register_blueprint(rest_api_blueprint)
+ app.register_blueprint(demo_blueprint)
+
+ app.register_blueprint(api_v2_case_blueprint)
+ app.register_blueprint(api_v2_ioc_blueprint)
+ app.register_blueprint(api_v2_assets_blueprint)
+ app.register_blueprint(api_v2_tasks_blueprint)
# provide login manager with load_user callback
From bef606e77c2d868e0b0798bf8b18ac42c738554d Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Wed, 18 Dec 2024 13:53:39 +0100
Subject: [PATCH 35/37] Removing circular dependency with app.views
---
source/app/__init__.py | 4 ++++
source/app/views.py | 4 ----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/source/app/__init__.py b/source/app/__init__.py
index 7553fb91c..d2e461042 100644
--- a/source/app/__init__.py
+++ b/source/app/__init__.py
@@ -141,6 +141,8 @@ def shutdown_session(exception=None):
from app.views import register_blueprints
+from app.views import load_user
+from app.views import load_user_from_request
register_blueprints(app)
@@ -154,3 +156,5 @@ def shutdown_session(exception=None):
app.logger.exception('Post init failed. IRIS not started')
raise e
+lm.user_loader(load_user)
+lm.request_loader(load_user_from_request)
diff --git a/source/app/views.py b/source/app/views.py
index eecfc4dc3..0828e0331 100644
--- a/source/app/views.py
+++ b/source/app/views.py
@@ -17,7 +17,6 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-from app import lm
from app.blueprints.pages.activities.activities_routes import activities_blueprint
from app.blueprints.pages.alerts.alerts_routes import alerts_blueprint
from app.blueprints.pages.case.case_routes import case_blueprint
@@ -190,9 +189,7 @@ def register_blueprints(app):
app.register_blueprint(api_v2_assets_blueprint)
app.register_blueprint(api_v2_tasks_blueprint)
-
# provide login manager with load_user callback
-@lm.user_loader
def load_user(user_id):
return User.query.get(int(user_id))
@@ -208,7 +205,6 @@ def _get_user_by_api_key(api_key):
).first()
-@lm.request_loader
def load_user_from_request(request):
api_key_sources = [
request.headers.get('X-IRIS-AUTH'),
From 0503e007be2d8936fe9f5c832366a926a2ed8550 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Wed, 18 Dec 2024 14:14:35 +0100
Subject: [PATCH 36/37] One import per line
---
source/app/models/authorization.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/source/app/models/authorization.py b/source/app/models/authorization.py
index df19f59ab..2188b2f47 100644
--- a/source/app/models/authorization.py
+++ b/source/app/models/authorization.py
@@ -2,7 +2,8 @@
import secrets
import uuid
from flask_login import UserMixin
-from sqlalchemy import BigInteger, JSON
+from sqlalchemy import BigInteger
+from sqlalchemy import JSON
from sqlalchemy import Boolean
from sqlalchemy import Column
from sqlalchemy import ForeignKey
From e396bec5d63a22aafffcaafc319dd35f0c3d66d6 Mon Sep 17 00:00:00 2001
From: c8y3 <25362953+c8y3@users.noreply.github.com>
Date: Wed, 18 Dec 2024 14:52:35 +0100
Subject: [PATCH 37/37] Activate ruff rule F401
---
pyproject.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyproject.toml b/pyproject.toml
index 786dd58cc..101c01ea8 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,2 +1,2 @@
[tool.ruff.lint]
-ignore = ["E402", "E711", "E712", "E721", "E722", "F401", "F821"]
+ignore = ["E402", "E711", "E712", "E721", "E722", "F821"]