Skip to content

Commit 367f0b4

Browse files
authored
Merge pull request #906 from dfir-iris/api_v2_alerts_comments
Api v2 alerts comments
2 parents a3ea05b + da2c7f6 commit 367f0b4

51 files changed

Lines changed: 1220 additions & 366 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

source/app/blueprints/rest/alerts_routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@ def alerts_batch_escalate_route() -> Response:
904904

905905

906906
@alerts_rest_blueprint.route('/alerts/<int:alert_id>/comments/list', methods=['GET'])
907+
@endpoint_deprecated('GET', '/api/v2/alerts/{alert_identifier}/comments')
907908
@ac_api_requires(Permissions.alerts_read)
908909
def alert_comments_get(alert_id):
909910
"""

source/app/blueprints/rest/api_v2_routes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
from app.blueprints.rest.v2.alerts import alerts_blueprint
2222
from app.blueprints.rest.v2.assets import assets_blueprint
23+
from app.blueprints.rest.v2.events import events_blueprint
24+
from app.blueprints.rest.v2.evidences import evidences_blueprint
25+
from app.blueprints.rest.v2.notes import notes_blueprint
2326
from app.blueprints.rest.v2.auth import auth_blueprint
2427
from app.blueprints.rest.v2.cases import cases_blueprint
2528
from app.blueprints.rest.v2.dashboard import dashboard_blueprint
@@ -39,6 +42,9 @@
3942
rest_v2_blueprint.register_blueprint(tasks_blueprint)
4043
rest_v2_blueprint.register_blueprint(iocs_blueprint)
4144
rest_v2_blueprint.register_blueprint(assets_blueprint)
45+
rest_v2_blueprint.register_blueprint(events_blueprint)
46+
rest_v2_blueprint.register_blueprint(evidences_blueprint)
47+
rest_v2_blueprint.register_blueprint(notes_blueprint)
4248
rest_v2_blueprint.register_blueprint(alerts_blueprint)
4349
rest_v2_blueprint.register_blueprint(dashboard_blueprint)
4450
rest_v2_blueprint.register_blueprint(manage_v2_blueprint)

source/app/blueprints/rest/case/case_assets_routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ def deprecated_asset_delete(cur_id, caseid):
337337

338338

339339
@case_assets_rest_blueprint.route('/case/assets/<int:cur_id>/comments/list', methods=['GET'])
340+
@endpoint_deprecated('GET', '/api/v2/assets/{asset_identifier}/comments')
340341
@ac_requires_case_identifier(CaseAccessLevel.read_only, CaseAccessLevel.full_access)
341342
@ac_api_requires()
342343
def case_comment_asset_list(cur_id, caseid):

source/app/blueprints/rest/case/case_evidences_routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def case_delete_rfile(cur_id, caseid):
140140

141141

142142
@case_evidences_rest_blueprint.route('/case/evidences/<int:cur_id>/comments/list', methods=['GET'])
143+
@endpoint_deprecated('GET', '/api/v2/evidences/{evidence_identifier}/comments')
143144
@ac_requires_case_identifier(CaseAccessLevel.read_only, CaseAccessLevel.full_access)
144145
@ac_api_requires()
145146
def case_comment_evidence_list(cur_id, caseid):

source/app/blueprints/rest/case/case_ioc_routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ def case_update_ioc(cur_id, caseid):
247247

248248

249249
@case_ioc_rest_blueprint.route('/case/ioc/<int:cur_id>/comments/list', methods=['GET'])
250+
@endpoint_deprecated('GET', '/api/v2/iocs/{ioc_identifier}/comments')
250251
@ac_requires_case_identifier(CaseAccessLevel.read_only, CaseAccessLevel.full_access)
251252
@ac_api_requires()
252253
def case_comment_ioc_list(cur_id, caseid):

source/app/blueprints/rest/case/case_notes_routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ def case_edit_notes_groups(cur_id, caseid):
392392

393393

394394
@case_notes_rest_blueprint.route('/case/notes/<int:cur_id>/comments/list', methods=['GET'])
395+
@endpoint_deprecated('GET', '/api/v2/notes/{note_identifier}/comments')
395396
@ac_requires_case_identifier(CaseAccessLevel.read_only, CaseAccessLevel.full_access)
396397
@ac_api_requires()
397398
def case_comment_note_list(cur_id, caseid):

source/app/blueprints/rest/case/case_tasks_routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def deprecated_case_delete_task(cur_id: int, caseid: int):
164164

165165

166166
@case_tasks_rest_blueprint.route('/case/tasks/<int:cur_id>/comments/list', methods=['GET'])
167+
@endpoint_deprecated('GET', '/api/v2/tasks/{task_identifier}/comments')
167168
@ac_requires_case_identifier(CaseAccessLevel.read_only, CaseAccessLevel.full_access)
168169
@ac_api_requires()
169170
def case_comment_task_list(cur_id: int, caseid: int):

source/app/blueprints/rest/case/case_timeline_routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181

8282

8383
@case_timeline_rest_blueprint.route('/case/timeline/events/<int:cur_id>/comments/list', methods=['GET'])
84+
@endpoint_deprecated('GET', '/api/v2/events/{event_identifier}/comments')
8485
@ac_requires_case_identifier(CaseAccessLevel.read_only, CaseAccessLevel.full_access)
8586
@ac_api_requires()
8687
def case_comments_get(cur_id, caseid):

source/app/blueprints/rest/case_comments.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from app.schema.marshables import CommentSchema
2424
from app.blueprints.responses import response_error
2525
from app.blueprints.responses import response_success
26-
from app.business.case_comments import case_comments_update
26+
from app.business.comments import comments_update_for_case
2727
from app.business.errors import BusinessProcessingError
2828

2929

@@ -32,7 +32,7 @@ def case_comment_update(comment_id, object_type, caseid):
3232
comment_schema = CommentSchema()
3333
rq_t = request.get_json()
3434
comment_text = rq_t.get('comment_text')
35-
comment = case_comments_update(comment_text, comment_id, object_type, caseid)
35+
comment = comments_update_for_case(comment_text, comment_id, object_type, caseid)
3636
return response_success("Comment edited", data=comment_schema.dump(comment))
3737
except BusinessProcessingError as e:
3838
return response_error(e.get_message(), data=e.get_data())

source/app/blueprints/rest/endpoints.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ def response_api_success(data):
3131

3232

3333
def _get_next_page(paginated_elements: Pagination):
34-
if paginated_elements.has_next:
35-
next_page = paginated_elements.has_next
36-
else:
37-
next_page = None
38-
return next_page
34+
if not paginated_elements.has_next:
35+
return None
36+
37+
return paginated_elements.has_next
3938

4039

4140
def response_api_paginated(schema, paginated_elements: Pagination):
@@ -91,6 +90,6 @@ def endpoint_removed(message, version):
9190
def inner_wrap(f):
9291
@wraps(f)
9392
def wrap(*args, **kwargs):
94-
return response_error(f"Endpoint deprecated in {version}. {message}.", status=410)
93+
return response_error(f'Endpoint deprecated in {version}. {message}.', status=410)
9594
return wrap
9695
return inner_wrap

0 commit comments

Comments
 (0)