diff --git a/src/n0s1/controllers/confluence_controller.py b/src/n0s1/controllers/confluence_controller.py index 22b2930..5dcb548 100644 --- a/src/n0s1/controllers/confluence_controller.py +++ b/src/n0s1/controllers/confluence_controller.py @@ -122,6 +122,7 @@ def is_connected(self): return False def get_data(self, include_coments=False, limit=None): + from atlassian.confluence import ApiPermissionError if not self._client: return {} @@ -150,6 +151,11 @@ def get_data(self, include_coments=False, limit=None): while not pages_finished: try: pages = self._client.get_all_pages_from_space(key, start=pages_start, limit=limit) + except ApiPermissionError as e: + message = str(e) + f" get_all_pages_from_space({key}, start={pages_start}, limit={limit}). Skipping..." + self.log_message(message, logging.WARNING) + pages = [{}] + break except Exception as e: message = str(e) + f" get_all_pages_from_space({key}, start={pages_start}, limit={limit})" self.log_message(message, logging.WARNING) diff --git a/src/n0s1/controllers/jira_controller.py b/src/n0s1/controllers/jira_controller.py index 198c0f9..e502fec 100644 --- a/src/n0s1/controllers/jira_controller.py +++ b/src/n0s1/controllers/jira_controller.py @@ -65,6 +65,7 @@ def is_connected(self): return False def get_data(self, include_coments=False, limit=None): + from jira.exceptions import JIRAError if not self._client: return {} start = 0 @@ -85,6 +86,11 @@ def get_data(self, include_coments=False, limit=None): while not issues_finished: try: issues = self._client.search_issues(ql, startAt=issue_start, maxResults=limit) + except JIRAError as e: + self.log_message(f"Error while searching issues on Jira project: [{key}]. Skipping...", logging.WARNING) + self.log_message(e) + issues = [{}] + break except Exception as e: message = str(e) + f" client.search_issues({ql}, startAt={issue_start}, maxResults={limit})" self.log_message(message, logging.WARNING) diff --git a/src/n0s1/n0s1.py b/src/n0s1/n0s1.py index cf7fde3..ed6d669 100755 --- a/src/n0s1/n0s1.py +++ b/src/n0s1/n0s1.py @@ -641,10 +641,18 @@ def main(callback=None): message = f"Starting scan in {mode} mode..." log_message(message) - scan(regex_config, controller, scan_arguments) - _save_report(report_format) - - log_message("Done!") + try: + scan(regex_config, controller, scan_arguments) + except KeyboardInterrupt: + log_message("Keyboard interrupt detected. Saving findings and exiting...") + sys.exit(130) + except Exception as e: + log_message("Execution interrupted by an exception. Saving partial report and exiting...") + log_message(e) + sys.exit(1) + finally: + _save_report(report_format) + log_message("Done!") if __name__ == "__main__":