Skip to content

Commit

Permalink
[IMP] Moved response_success out of util.py into blueprints namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
c8y3 committed Oct 8, 2024
1 parent d27a5cd commit 4134a54
Show file tree
Hide file tree
Showing 46 changed files with 53 additions and 53 deletions.
2 changes: 1 addition & 1 deletion source/app/blueprints/access_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

from app import app
from app import db
from app.blueprints.responses import response_error
from app.datamgmt.case.case_db import get_case
from app.datamgmt.manage.manage_access_control_db import user_has_client_access
from app.datamgmt.manage.manage_users_db import get_user
Expand All @@ -50,7 +51,6 @@
from app.models.authorization import Permissions
from app.models.authorization import CaseAccessLevel

from app.blueprints.responses import response_error
from app.util import not_authenticated_redirection_url


Expand Down
9 changes: 9 additions & 0 deletions source/app/blueprints/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,12 @@ def response_error(msg, data=None, status=400):
'data': data if data is not None else []
}
return response(status, data=content)


def response_success(msg='', data=None):
content = {
"status": "success",
"message": msg,
"data": data if data is not None else []
}
return response(200, data=content)
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/activities_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from app.datamgmt.activities.activities_db import get_users_activities
from app.models.authorization import Permissions
from app.blueprints.access_controls import ac_api_requires
from app.util import response_success
from app.blueprints.responses import response_success

activities_rest_blueprint = Blueprint('activities_rest', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/alerts_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import add_obj_history_entry
from app.util import response_success
from app.blueprints.responses import response_success

alerts_rest_blueprint = Blueprint('alerts_rest', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/api_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from app import app
from app.blueprints.access_controls import ac_api_requires
from app.util import response_success
from app.blueprints.responses import response_success

rest_api_blueprint = Blueprint('rest_api', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/case/case_assets_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
from app.schema.marshables import CommentSchema
from app.blueprints.access_controls import ac_requires_case_identifier, ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success
from app.blueprints.access_controls import ac_api_return_access_denied

case_assets_rest_blueprint = Blueprint('case_assets_rest', __name__)
Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/case/case_evidences_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from app.blueprints.access_controls import ac_requires_case_identifier
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

case_evidences_rest_blueprint = Blueprint('case_evidences_rest', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/case/case_graphs_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from app.models.authorization import CaseAccessLevel
from app.blueprints.access_controls import ac_requires_case_identifier
from app.blueprints.access_controls import ac_api_requires
from app.util import response_success
from app.blueprints.responses import response_success

case_graph_rest_blueprint = Blueprint('case_graph_rest', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/case/case_ioc_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.access_controls import ac_api_return_access_denied
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

case_ioc_rest_blueprint = Blueprint('case_ioc_rest', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/case/case_notes_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.rest.endpoints import endpoint_removed
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

case_notes_rest_blueprint = Blueprint('case_notes_rest', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/case/case_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
from app.util import add_obj_history_entry
from app.blueprints.access_controls import ac_api_return_access_denied
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

case_rest_blueprint = Blueprint('case_rest', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/case/case_tasks_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.access_controls import ac_api_return_access_denied
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

case_tasks_rest_blueprint = Blueprint('case_tasks_rest', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/case/case_timeline_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
from app.blueprints.access_controls import ac_api_requires
from app.util import add_obj_history_entry
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

case_timeline_rest_blueprint = Blueprint('case_timeline_rest', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/case_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from app.schema.marshables import CommentSchema
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success
from app.business.case_comments import case_comments_update
from app.business.errors import BusinessProcessingError

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/context_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from app.models.models import Client
from app.blueprints.access_controls import ac_api_requires
from app.util import not_authenticated_redirection_url
from app.util import response_success
from app.blueprints.responses import response_success

context_rest_blueprint = Blueprint('context_rest', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/dashboard_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
from app.blueprints.access_controls import ac_api_requires
from app.util import not_authenticated_redirection_url
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success
from app.util import is_authentication_oidc

from oic.oauth2.exception import GrantError
Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/datastore_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
from app.blueprints.access_controls import ac_api_requires
from app.util import add_obj_history_entry
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

datastore_rest_blueprint = Blueprint('datastore_rest', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/dim_tasks_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from app.blueprints.access_controls import ac_requires_case_identifier
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success
from iris_interface.IrisInterfaceStatus import IIStatus

dim_tasks_rest_blueprint = Blueprint('dim_tasks_rest', __name__)
Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/filters_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from app.iris_engine.utils.tracker import track_activity
from app.schema.marshables import SavedFilterSchema
from app.blueprints.access_controls import ac_api_requires
from app.util import response_success
from app.blueprints.responses import response_success
from app.blueprints.responses import response_error

saved_filters_rest_blueprint = Blueprint('saved_filters_rest', __name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from app.iris_engine.access_control.utils import ac_trace_user_effective_cases_access_2
from app.models.authorization import Permissions
from app.blueprints.access_controls import ac_api_requires
from app.util import response_success
from app.blueprints.responses import response_success

manage_ac_rest_blueprint = Blueprint('access_control_rest', __name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from app.schema.marshables import AlertResolutionSchema
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

manage_alerts_status_rest_blueprint = Blueprint('manage_alerts_status_rest', __name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from app.schema.marshables import AnalysisStatusSchema
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

manage_analysis_status_rest_blueprint = Blueprint('manage_analysis_status_rest', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/manage/manage_assets_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from app.schema.marshables import CaseAssetsSchema
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.access_controls import ac_api_return_access_denied
from app.util import response_success
from app.blueprints.responses import response_success

manage_assets_rest_blueprint = Blueprint('manage_assets_rest', __name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from app.schema.marshables import AssetTypeSchema
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

manage_assets_type_rest_blueprint = Blueprint('manage_assets_type_rest', __name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from app.models.models import CustomAttribute
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

manage_attributes_rest_blueprint = Blueprint('manage_attributes_rest', __name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from app.schema.marshables import CaseClassificationSchema
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

manage_case_classification_rest_blueprint = Blueprint('manage_case_classifications_rest', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/manage/manage_case_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from app.schema.marshables import CaseStateSchema
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

manage_case_state_rest_blueprint = Blueprint('manage_case_state_rest', __name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from app.blueprints.access_controls import ac_requires_case_identifier
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

manage_case_templates_rest_blueprint = Blueprint('manage_case_templates_rest', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/manage/manage_cases_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.access_controls import ac_api_return_access_denied
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success
from app.business.cases import cases_delete
from app.business.cases import cases_update
from app.business.cases import cases_create
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from app.schema.marshables import CustomerSchema
from app.blueprints.access_controls import ac_api_requires_client_access
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

manage_customers_rest_blueprint = Blueprint('manage_customers_rest', __name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from app.schema.marshables import EventCategorySchema
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

manage_event_categories_rest_blueprint = Blueprint('manage_event_categories_rest', __name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from app.schema.marshables import EvidenceTypeSchema
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

manage_evidence_types_rest_blueprint = Blueprint('manage_evidence_types_rest', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/manage/manage_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.access_controls import ac_api_return_access_denied
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success
from app.iris_engine.demo_builder import protect_demo_mode_group

manage_groups_rest_blueprint = Blueprint('manage_groups_rest', __name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from app.schema.marshables import IocTypeSchema
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

manage_ioc_type_rest_blueprint = Blueprint('manage_ioc_types_rest', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/manage/manage_modules_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from app.models.authorization import Permissions
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success
from app.schema.marshables import IrisModuleSchema

manage_modules_rest_blueprint = Blueprint('manage_module_rest', __name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from app.schema.marshables import ServerSettingsSchema
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success
from dictdiffer import diff

manage_server_settings_rest_blueprint = Blueprint('manage_server_settings_rest', __name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from app.schema.marshables import SeveritySchema
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

manage_severities_rest_blueprint = Blueprint('manage_severities_rest', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/manage/manage_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from app.schema.marshables import TagsSchema
from app.blueprints.access_controls import ac_api_requires
from app.util import AlchemyEncoder
from app.util import response_success
from app.blueprints.responses import response_success

manage_tags_rest_blueprint = Blueprint('manage_tags_rest', __name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from app.models.models import TaskStatus
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

manage_task_status_rest_blueprint = Blueprint('manage_task_status_rest', __name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from app.models.models import ReportType
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

_ALLOWED_EXTENSIONS = {'md', 'html', 'doc', 'docx'}

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/manage/manage_tlps_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from app.models import Tlp
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success

manage_tlp_type_rest_blueprint = Blueprint('manage_tlp_types_rest', __name__)

Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/manage/manage_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from app.blueprints.access_controls import ac_api_requires
from app.blueprints.access_controls import ac_api_return_access_denied
from app.blueprints.responses import response_error
from app.util import response_success
from app.blueprints.responses import response_success
from app.iris_engine.demo_builder import protect_demo_mode_user

manage_users_rest_blueprint = Blueprint('manage_users_rest', __name__)
Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/overview_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from app.datamgmt.overview.overview_db import get_overview_db
from app.blueprints.access_controls import ac_api_requires
from app.util import response_success
from app.blueprints.responses import response_success

overview_rest_blueprint = Blueprint('overview_rest', __name__)

Expand Down
Loading

0 comments on commit 4134a54

Please sign in to comment.