From 555d41345806efb73f67e6965f675ed03c775d38 Mon Sep 17 00:00:00 2001 From: Joshua Hiller <74007258+jshcodes@users.noreply.github.com> Date: Mon, 8 Nov 2021 18:40:48 -0500 Subject: [PATCH] [DEPLOY] v0.8.2 - Handle incorrectly specified parameter payload values (#424) * Update _util.py * Bump version -> 0.8.2 * Update CHANGELOG.md * Update CHANGELOG.md * Expanded unit testing to complete code coverage. * Update comment * Fix unit test method call * Update wordlist.txt Co-authored-by: valerianrossigneux --- .github/wordlist.txt | 1 + CHANGELOG.md | 5 +++++ src/falconpy/_util.py | 10 +++++++++- src/falconpy/_version.py | 2 +- tests/test_uber_api_complete.py | 14 ++++++++++++++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/.github/wordlist.txt b/.github/wordlist.txt index ffbfe70c8..7de753fef 100644 --- a/.github/wordlist.txt +++ b/.github/wordlist.txt @@ -491,6 +491,7 @@ urlencoded urllib util uuid +valerianrossigneux validator ver www diff --git a/CHANGELOG.md b/CHANGELOG.md index a4c0cf722..378a061a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# Version 0.8.2 +## Issues resolved ++ Fixed: Issue in `_util.args_to_params` when handling Python reserved words defined as keys incorrectly in the parameter dictionary. Closes #422. + - Special thanks to @valerianrossigneux for originally identifying this issue, and his assistance testing a fix. :bow: + # Version 0.8.1 ## Added features and functionality + Added: New Discover Service Class and matching unit testing to represent the recently released Falcon Discover API. diff --git a/src/falconpy/_util.py b/src/falconpy/_util.py index d2e120ad5..b991683ba 100644 --- a/src/falconpy/_util.py +++ b/src/falconpy/_util.py @@ -320,6 +320,7 @@ def args_to_params(payload: dict, passed_arguments: dict, endpoints: list, epnam Returns: dictionary representing QueryString parameters. """ + returned_payload = {} if epname != "Manual": # pylint: disable=R1702 for arg in passed_arguments: eps = [ep[5] for ep in endpoints if epname in ep[0]][0] @@ -337,7 +338,14 @@ def args_to_params(payload: dict, passed_arguments: dict, endpoints: list, epnam # Unrecognized argument pass - return payload + # Clean up reserved word conversions when passing in an invalid raw payload + for element in payload: + if not isinstance(element, str): + returned_payload[element.__name__] = payload[element] + else: + returned_payload[element] = payload[element] + + return returned_payload def process_service_request(calling_object: object, diff --git a/src/falconpy/_version.py b/src/falconpy/_version.py index 31ba9a083..dea964c75 100644 --- a/src/falconpy/_version.py +++ b/src/falconpy/_version.py @@ -35,7 +35,7 @@ For more information, please refer to """ -_VERSION = '0.8.1' +_VERSION = '0.8.2' _MAINTAINER = 'Joshua Hiller' _AUTHOR = 'CrowdStrike' _AUTHOR_EMAIL = 'falconpy@crowdstrike.com' diff --git a/tests/test_uber_api_complete.py b/tests/test_uber_api_complete.py index f80d441f3..95970ba72 100644 --- a/tests/test_uber_api_complete.py +++ b/tests/test_uber_api_complete.py @@ -229,9 +229,23 @@ def uberCCAWS_DisableSSLVerify(self): else: return False + def uber_test_invalid_reserved_word_payload(self): + params = { + "limit": 1, + "facet": "cve,host_info", + filter:"created_timestamp:>'2021-01-01T00:00:01Z'" + } + if falcon.command("combinedQueryVulnerabilities", parameters=params)["status_code"] in AllowedResponses: + return True + else: + return False + def test_GetAWSSettings(self): assert self.uberCCAWS_GetAWSSettings() is True + def test_reserved_words(self): + assert self.uber_test_invalid_reserved_word_payload() is True + def test_QueryAWSAccounts(self): assert self.uberCCAWS_QueryAWSAccounts() is True