diff --git a/core/arguments.py b/core/arguments.py index 0acb016bb..9def4e6d9 100644 --- a/core/arguments.py +++ b/core/arguments.py @@ -5,6 +5,7 @@ logger = logging.getLogger(__name__) + class Argument(object): def __init__(self, key=None, value=None, format='str'): """Initializes a new Argument object. diff --git a/core/controller.py b/core/controller.py index 2c103ac9e..2633688f1 100644 --- a/core/controller.py +++ b/core/controller.py @@ -27,6 +27,7 @@ logger = logging.getLogger(__name__) + def initialize_threading(): """Initializes the threadpool. """ diff --git a/core/filter.py b/core/filter.py index d8407450f..04f328cea 100644 --- a/core/filter.py +++ b/core/filter.py @@ -77,7 +77,6 @@ def validate_args(self): def __call__(self, output=None): if self.validate_args(): try: - #result = getattr(module, "main")(args=self.args, value=output) result = execute_filter(self.action, args=self.args, value=output) callbacks.FilterSuccess.send(self) return result @@ -129,4 +128,4 @@ def get_children(self, ancestry): Returns: Empty dictionary {} """ - return {} \ No newline at end of file + return {} diff --git a/core/filters/length.py b/core/filters/length.py index afd6b612a..a8a22b293 100644 --- a/core/filters/length.py +++ b/core/filters/length.py @@ -7,7 +7,8 @@ def execute(args, value): """ Gets the length of the value provided to it. Returns: - If the value is a collection, it calls len() on it. If it is an int, it simply returns the value passed in""" + If the value is a collection, it calls len() on it. + If it is an int, it simply returns the value passed in""" try: if isinstance(value, int): return value diff --git a/core/widgetsignals.py b/core/widgetsignals.py index b53aea79d..a5ec79989 100644 --- a/core/widgetsignals.py +++ b/core/widgetsignals.py @@ -30,4 +30,3 @@ def get_widget_signal(app_name, widget_name): if key not in _widget_signals: _widget_signals[key] = signal(create_widget_signal_name(app_name, widget_name)) return _widget_signals[key] - diff --git a/core/workflow.py b/core/workflow.py index 363f1c42f..05d015407 100644 --- a/core/workflow.py +++ b/core/workflow.py @@ -278,7 +278,7 @@ def __get_child_step_generator(self, tiered_step_str): child_name, child_start, child_next = params[0].lstrip('@'), params[1], params[2] child_name = construct_workflow_name_key(self.playbook_name, child_name) if (child_name in self.options.children - and type(self.options.children[child_name]).__name__ == 'Workflow'): + and type(self.options.children[child_name]).__name__ == 'Workflow'): logger.debug('Executing child workflow {0} of workflow {1}'.format(child_name, self.ancestry)) callbacks.WorkflowExecutionStart.send(self.options.children[child_name]) child_step_generator = self.options.children[child_name].__steps(start=child_start) diff --git a/server/app.py b/server/app.py index 04969cf79..ae99d9cf3 100644 --- a/server/app.py +++ b/server/app.py @@ -1,4 +1,5 @@ -import os, logging +import os +import logging from jinja2 import Environment, FileSystemLoader from core import helpers @@ -15,7 +16,7 @@ def read_and_indent(filename, indent): - indent = ' '*indent + indent = ' ' * indent with open(filename, 'r') as file_open: return ['{0}{1}'.format(indent, line) for line in file_open] @@ -47,16 +48,16 @@ def create_app(): _app.jinja_loader = FileSystemLoader(['server/templates']) _app.config.update( - # CHANGE SECRET KEY AND SECURITY PASSWORD SALT!!! - SECRET_KEY = "SHORTSTOPKEYTEST", - SQLALCHEMY_DATABASE_URI=format_db_path(core.config.config.walkoff_db_type, os.path.abspath(paths.db_path)), - SECURITY_PASSWORD_HASH = 'pbkdf2_sha512', - SECURITY_TRACKABLE = False, - SECURITY_PASSWORD_SALT = 'something_super_secret_change_in_production', - SECURITY_POST_LOGIN_VIEW = '/', - WTF_CSRF_ENABLED = False, - STATIC_FOLDER=os.path.abspath('server/static') - ) + # CHANGE SECRET KEY AND SECURITY PASSWORD SALT!!! + SECRET_KEY="SHORTSTOPKEYTEST", + SQLALCHEMY_DATABASE_URI=format_db_path(core.config.config.walkoff_db_type, os.path.abspath(paths.db_path)), + SECURITY_PASSWORD_HASH='pbkdf2_sha512', + SECURITY_TRACKABLE=False, + SECURITY_PASSWORD_SALT='something_super_secret_change_in_production', + SECURITY_POST_LOGIN_VIEW='/', + WTF_CSRF_ENABLED=False, + STATIC_FOLDER=os.path.abspath('server/static') + ) _app.config["SECURITY_LOGIN_USER_TEMPLATE"] = "login_user.html" _app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False @@ -64,6 +65,7 @@ def create_app(): connexion_app.add_api('composed_api.yaml') return _app + # Template Loader env = Environment(loader=FileSystemLoader("apps")) app = create_app() @@ -96,4 +98,4 @@ def create_user(): running_context.CaseSubscription.sync_to_subscriptions() - app.logger.handlers = logging.getLogger('server').handlers \ No newline at end of file + app.logger.handlers = logging.getLogger('server').handlers diff --git a/server/appdevice.py b/server/appdevice.py index 6913eb55e..16e4618b9 100644 --- a/server/appdevice.py +++ b/server/appdevice.py @@ -31,7 +31,7 @@ def __init__(self, app=None, devices=None): Args: app (str, optional): The name of the app. Defaults to None. - device (list[str], optional): The list of device names to be associated with the App object. There is a + devices (list[str], optional): The list of device names to be associated with the App object. There is a one to many mapping from Apps to Devices. """ self.name = app @@ -90,7 +90,7 @@ def __init__(self, name="", username="", password="", ip="0.0.0.0", port=0, extr password (str, optional): The password for the Device object. Defaults to an empty string. ip (str, optional): The IP address for for the Device object. Defaults to "0.0.0.0". port (int, optional): The port for the Device object. Defaults to 0. - exra_fields (str, optional): The string representation of a dictionary that holds various custom + extra_fields (str, optional): The string representation of a dictionary that holds various custom extra fields for the Device object. Defaults to an empty string. app_id (str, optional): The ID of the App object to which this Device is associated. Defaults to an empty string. @@ -116,7 +116,7 @@ def add_device(name, username, password, ip, port, extra_fields, app_server): password (str, optional): The password for the Device object. Defaults to an empty string. ip (str, optional): The IP address for for the Device object. Defaults to "0.0.0.0". port (int, optional): The port for the Device object. Defaults to 0. - exra_fields (str, optional): The string representation of a dictionary that holds various custom + extra_fields (str, optional): The string representation of a dictionary that holds various custom extra fields for the Device object. Defaults to an empty string. app_server (str, optional): The ID of the App object to which this Device is associated. Defaults to an empty string. diff --git a/server/blueprints/app.py b/server/blueprints/app.py index 92d52fcf0..90a62bf0a 100644 --- a/server/blueprints/app.py +++ b/server/blueprints/app.py @@ -41,6 +41,7 @@ def list_app_actions(): else: return json.dumps({'status': 'error: app name not found'}) + #TODO: DELETE @app_page.route('/display', methods=['POST']) @auth_token_required diff --git a/server/blueprints/events.py b/server/blueprints/events.py index efd70e5d2..2af706c3a 100644 --- a/server/blueprints/events.py +++ b/server/blueprints/events.py @@ -41,4 +41,4 @@ def setup_case_stream(): @auth_token_required @roles_accepted(*running_context.user_roles['/cases']) def stream_case_events(): - return Response(__case_event_stream(), mimetype='text/event-stream') \ No newline at end of file + return Response(__case_event_stream(), mimetype='text/event-stream') diff --git a/server/blueprints/widget.py b/server/blueprints/widget.py index 385b30137..054f96afd 100644 --- a/server/blueprints/widget.py +++ b/server/blueprints/widget.py @@ -43,4 +43,4 @@ def load_module(app_name, widget_name): def load_widget(app_name, widget_name, keys, values): module = load_module(app_name, widget_name) args = dict(zip(keys, values)) - return getattr(module, 'load')(args) if module else {} \ No newline at end of file + return getattr(module, 'load')(args) if module else {} diff --git a/server/blueprints/widgets.py b/server/blueprints/widgets.py index 7a6cdfc4e..b30725a00 100644 --- a/server/blueprints/widgets.py +++ b/server/blueprints/widgets.py @@ -43,4 +43,4 @@ def load_module(app_name, widget_name): def load_widget(app_name, widget_name, keys, values): module = load_module(app_name, widget_name) args = dict(zip(keys, values)) - return getattr(module, 'load')(args) if module else {} \ No newline at end of file + return getattr(module, 'load')(args) if module else {} diff --git a/server/casesubscription.py b/server/casesubscription.py index 55e8b2bab..02d5cf46a 100644 --- a/server/casesubscription.py +++ b/server/casesubscription.py @@ -71,4 +71,3 @@ def sync_to_subscriptions(): subscriptions = {case.name: core.case.subscription.CaseSubscriptions.from_json(json.loads(case.subscription)) for case in CaseSubscription.query.all()} core.case.subscription.set_subscriptions(subscriptions) - diff --git a/server/endpoints/cases.py b/server/endpoints/cases.py index b0e331e05..3c51f44ea 100644 --- a/server/endpoints/cases.py +++ b/server/endpoints/cases.py @@ -73,7 +73,7 @@ def __func(): if form.note.data: case_database.case_db.edit_case_note(form.name.data, form.note.data) current_app.logger.debug('Case name changed from {0} to {1}'.format(case, form.name.data)) - #TODO: YAML says that name AND note are required...is this second branch necessary? + # TODO: YAML says that name AND note are required...is this second branch necessary? elif form.note.data: case_database.case_db.edit_case_note(case, form.note.data) return case_database.case_db.cases_as_json() diff --git a/server/endpoints/events.py b/server/endpoints/events.py index 472d96e93..987cc65c1 100644 --- a/server/endpoints/events.py +++ b/server/endpoints/events.py @@ -30,4 +30,4 @@ def __func(): return case_database.case_db.event_as_json(event_id) else: return {"status": "invalid event"} - return __func() \ No newline at end of file + return __func() diff --git a/server/endpoints/playbooks.py b/server/endpoints/playbooks.py index 11a340e47..030f5dd52 100644 --- a/server/endpoints/playbooks.py +++ b/server/endpoints/playbooks.py @@ -399,8 +399,8 @@ def __func(): current_app.logger.info('Paused workflow {0}-{1}'.format(playbook_name, workflow_name)) return {"uuid": uuid} else: - current_app.logger.error('Cannot pause workflow {0}-{1}. Does not exist in controller'.format(playbook_name, - workflow_name)) + current_app.logger.error('Cannot pause workflow ' + '{0}-{1}. Does not exist in controller'.format(playbook_name, workflow_name)) status = 'error: invalid playbook and/or workflow name' return {"status": status} diff --git a/server/endpoints/roles.py b/server/endpoints/roles.py index 1a9e786b1..94d36d565 100644 --- a/server/endpoints/roles.py +++ b/server/endpoints/roles.py @@ -15,6 +15,7 @@ def __func(): else: current_app.logger.error('Cannot display roles. No roles exist.') return {"status": "roles do not exist"} + return __func() @@ -40,12 +41,13 @@ def __func(): running_context.db.session.commit() current_app.logger.info('Role added: {0}'.format({"name": role_name, - "description": description, - "urls": default_urls})) + "description": description, + "urls": default_urls})) return {"status": "role added " + role_name} else: current_app.logger.warning('Cannot add role {0}. Role already exists'.format(role_name)) return {"status": "role exists"} + return __func() @@ -60,6 +62,7 @@ def __func(): else: current_app.logger.error('Cannot display role {0}. Role does not exist.'.format(role_name)) return {"status": "role does not exist"} + return __func() @@ -78,10 +81,11 @@ def __func(): add_to_user_roles(role_name, form.pages) current_app.logger.info('Edited role {0} to {1}'.format(role_name, {"name": role_name, - "description": form.description.data, - "urls": form.pages.data})) + "description": form.description.data, + "urls": form.pages.data})) return role.display() else: current_app.logger.error('Cannot edit role {0}. Role does not exist.'.format(role_name)) return {"status": "role does not exist"} + return __func() diff --git a/server/interface.py b/server/interface.py index 01c3d37b1..57a436e8d 100644 --- a/server/interface.py +++ b/server/interface.py @@ -14,7 +14,7 @@ def settings(): choices = [(obj.email, str(obj.email)) for obj in running_context.User.query.all()] user_form.username.choices = choices add_user_form = forms.AddUserForm() - roles = [(x.name,str(x.name)) for x in running_context.Role.query.all()] + roles = [(x.name, str(x.name)) for x in running_context.Role.query.all()] add_user_form.roles.choices = roles return {"systemForm": forms.SettingsForm(), "userForm": user_form, "addUserForm": add_user_form } diff --git a/server/triggers.py b/server/triggers.py index 8753b4fcc..ccfc7a53e 100644 --- a/server/triggers.py +++ b/server/triggers.py @@ -77,7 +77,7 @@ def execute(data_in, input_in): Args: data_in (str): Data to be used to match against the conditionals - intput_in (str): The input to teh first step of the workflow + input_in (str): The input to the first step of the workflow Returns: Dictionary of {"status": }