From d8a41141006aa1b14d2d903ccee85834dfd54ea3 Mon Sep 17 00:00:00 2001 From: frikky Date: Wed, 25 Jan 2023 13:47:42 +0100 Subject: [PATCH] Fixed user attributes error handling by dumping to json before return --- active-directory/1.0.0/README.md | 2 +- active-directory/1.0.0/src/app.py | 9 +++++---- email/1.2.0/api.yaml | 2 +- shuffle-tools/1.2.0/src/app.py | 7 +++++++ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/active-directory/1.0.0/README.md b/active-directory/1.0.0/README.md index 113484fa..e99000f2 100644 --- a/active-directory/1.0.0/README.md +++ b/active-directory/1.0.0/README.md @@ -23,7 +23,7 @@ Get-ADDomain 3. Find the response from "UsersContainer" and use this for Base DN and Search Base ## Typical issues -- InvalidCredentials: This happens when the credentials are wrong. +- InvalidCredentials: This happens when the credentials are wrong. See #authentication to understand if your format for your username/password is correct. ## Features get user attributes -- done diff --git a/active-directory/1.0.0/src/app.py b/active-directory/1.0.0/src/app.py index fdf04e73..3930dcf9 100644 --- a/active-directory/1.0.0/src/app.py +++ b/active-directory/1.0.0/src/app.py @@ -133,16 +133,17 @@ def user_attributes( result = json.loads(c.response_to_json()) if len(result["entries"]) == 0: - return { + return json.dumps({ "success": False, "result": result, "reason": "No user found for %s" % samaccountname, - } + }) + except Exception as e: - return { + return json.dumps({ "success": False, "reason": "Failed to get users in user attributes: %s" % e, - } + }) result = result["entries"][0] diff --git a/email/1.2.0/api.yaml b/email/1.2.0/api.yaml index ac3bc572..798b12c8 100644 --- a/email/1.2.0/api.yaml +++ b/email/1.2.0/api.yaml @@ -183,8 +183,8 @@ actions: description: Include raw body in email export multiline: false options: - - "false" - "true" + - "false" required: true schema: type: bool diff --git a/shuffle-tools/1.2.0/src/app.py b/shuffle-tools/1.2.0/src/app.py index 0be125a6..cb5652e7 100644 --- a/shuffle-tools/1.2.0/src/app.py +++ b/shuffle-tools/1.2.0/src/app.py @@ -565,10 +565,14 @@ def execute_bash(self, code, shuffle_input): def filter_list(self, input_list, field, check, value, opposite): self.logger.info(f"\nRunning function with list {input_list}") + # Remove hashtags on the fly + # E.g. #.fieldname or .#.fieldname + flip = False if str(opposite).lower() == "true": flip = True + try: #input_list = eval(input_list) # nosec input_list = json.loads(input_list) @@ -590,6 +594,9 @@ def filter_list(self, input_list, field, check, value, opposite): input_list = [input_list] + if str(value).lower() == "null": + value = "none" + self.logger.info(f"\nRunning with check \"%s\" on list of length %d\n" % (check, len(input_list))) found_items = [] new_list = []