From 06a794078561499dd9830497a00afda80f8da103 Mon Sep 17 00:00:00 2001 From: Adnan Khan Date: Sat, 14 Dec 2024 17:05:03 -0500 Subject: [PATCH] Add error handling to address #62. (#65) --- gatox/cli/cli.py | 10 ++++++++-- gatox/models/execution.py | 8 ++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/gatox/cli/cli.py b/gatox/cli/cli.py index 6016a66..efb08b2 100644 --- a/gatox/cli/cli.py +++ b/gatox/cli/cli.py @@ -337,8 +337,14 @@ def enumerate(args, parser): exec_wrapper.add_organizations(orgs) exec_wrapper.add_repositories(repos) - if args.output_json: - Output.write_json(exec_wrapper, args.output_json) + try: + + if args.output_json: + Output.write_json(exec_wrapper, args.output_json) + except Exception as output_error: + Output.error( + "Encountered an error writing the output JSON, this is likely a Gato-X bug." + ) def search(args, parser): diff --git a/gatox/models/execution.py b/gatox/models/execution.py index 6b5a815..0cadecc 100644 --- a/gatox/models/execution.py +++ b/gatox/models/execution.py @@ -52,10 +52,14 @@ def toJSON(self): "enumeration": { "timestamp": self.timestamp.ctime(), "organizations": [ - organization.toJSON() for organization in self.organizations + organization.toJSON() + for organization in self.organizations + if isinstance(organization, Organization) ], "repositories": [ - repository.toJSON() for repository in self.repositories + organization.toJSON() + for organization in self.organizations + if isinstance(organization, Repository) ], }, }