Skip to content

Add a decorator to handle exceptions for SOAR action handlers #45

@zdc217

Description

@zdc217

We need a decorator to catch unhandled exceptions for debugging. For us to see the traceback we need it saved to the action result as in the code below. For security reasons this feature needs to be toggleable via the SOAR app.json.

@handle('test_connectivity')
    def _handle_test_connectivity(self, param):
        action_result = self.add_action_result(ActionResult(dict(param)))
        self.save_progress("Connecting to endpoint")
        # Note: There was an `auth` call when the `tdx` object was created.
        # This call results in a second call to `auth`
        tb = None
        msg = None
        try:
            raise Exception("This is a test")
        except Exception as ex:
            msg = ex
            tb = traceback.format_exc()

        # success = self.tdx.auth()

        action_result.add_data({"traceback": tb})

        if False:
            self.save_progress("Test Connectivity Passed")
            return action_result.set_status(
                phantom.APP_SUCCESS, "Active connection")
        else:
            self.save_progress("Test Connectivity Failed")
            return action_result.set_status(
                phantom.APP_ERROR, f"Failed connection: {msg}")

techservicesillinois/secops-soar-tdx#161

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions