Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ BUG ] Parameter abstraction handling impacting calls that use arguments instead of keywords #263

Closed
cah-sean-whalen opened this issue Aug 11, 2021 · 3 comments · Fixed by #265
Assignees
Labels
bug 🐛 Something isn't working SDK usage General SDK usage issues and questions

Comments

@cah-sean-whalen
Copy link

cah-sean-whalen commented Aug 11, 2021

Describe the bug
Calling Hosts.GetDeviceDetails(agent_id) in falconpy 0.5.5 results in an exception.

Introduced in commit ec4d3a5#diff-82ae497787008b6c4bc2b8015761bd7bbcf9853942bf1a43a85cf776a7213673

  File "falconpy\_util.py", line 144, in factory
    return func(*args, **kwargs)
TypeError: GetDeviceDetails() got multiple values for argument 'parameters'

Environment (please complete the following information):

  • OS: Windows
  • Python 3.9
  • FalconPy: 0.5.4 - 0.5.6
@cah-sean-whalen cah-sean-whalen added the bug 🐛 Something isn't working label Aug 11, 2021
@jshcodes
Copy link
Member

HI @cah-sean-whalen -

Can you post a sample of the code you were executing so we can recreate this to debug?

@cah-sean-whalen
Copy link
Author

@jshcodes Here you go

from falconpy import hosts as FalconHosts

credentials = {
            'client_id': client_id,
            'client_secret': client_secret,
            'base_url': 'https://api.crowdstrike.com'
        }

agent_id = "aidgoeshere"

hosts = FalconHosts.Hosts(creds=credentials)

host_details = hosts.GetDeviceDetails(agent_id)'body']['resources'][0]

@jshcodes
Copy link
Member

jshcodes commented Aug 11, 2021

Ok I've recreated this, and can confirm. To resolve please update your code to the following:

Use keywords instead of arguments

from falconpy import hosts as FalconHosts

credentials = {
            'client_id': client_id,
            'client_secret': client_secret,
            'base_url': 'https://api.crowdstrike.com'   # Don't have to specify this for US-1
        }

agent_id = "aidgoeshere"

hosts = FalconHosts.Hosts(creds=credentials)

host_details = hosts.GetDeviceDetails(ids=agent_id)['body']['resources'][0]

This is being caused by the updated parameter abstraction, which is looping through all of your keywords trying to create the parameters payload. Since we didn't have a keyword in your sample, and we've not coded in an "assume arg 0", it's crashing as it has set the parameter dictionary default twice.

Looking into this now, in the interim, please make sure to specify keywords for calls that dynamically specify parameter dictionary payloads. I've confirmed this issue impacts v0.5.6 as well.

Thank you for the report! 😄

@jshcodes jshcodes changed the title [ BUG ] Hosts.GetDeviceDetails() broke in falconpy 0.5.5 [ BUG ] Parameter abstraction handling impacting calls that use arguments instead of keywords Aug 11, 2021
@jshcodes jshcodes added the API usage General API usage issues and questions label Aug 11, 2021
@jshcodes jshcodes self-assigned this Aug 11, 2021
@jshcodes jshcodes added SDK usage General SDK usage issues and questions and removed API usage General API usage issues and questions labels Aug 11, 2021
jshcodes added a commit that referenced this issue Aug 12, 2021
jshcodes added a commit that referenced this issue Aug 13, 2021
ekmixon pushed a commit to ekmixon/falconpy that referenced this issue Aug 21, 2021
…ring, Direct authentication (CrowdStrike#265)

* Bump version -> 0.5.7

* Add partition new pattern. Related to CrowdStrike#248.

* Refactored. Closes CrowdStrike#247. Closes CrowdStrike#248.

* Refactored. Fixed refresh test.

* Fix typo

* Comments

* Reduced refresh test frequency to combat flakiness

* Re-enable all Python version within MacOS workflow

* Reduced refresh test to combat race condition

* Refactored - address pattern changes & reduce auth

* Refactored. Closes CrowdStrike#253. Closes CrowdStrike#258.

* Refactored. Closes CrowdStrike#248.

* Refactored. Closes CrowdStrike#250. Closes CrowdStrike#259.

* Refactored. Closes CrowdStrike#252. Closes CrowdStrike#257.

* Refactored. Closes CrowdStrike#251. Closes CrowdStrike#256.

* Refactored. Closes CrowdStrike#254. Closes CrowdStrike#255.

* Refactored to the latest pattern. Closes CrowdStrike#260.

* Add 201 to logout AllowedResponses

* Add 201 to logout AllowedResponses

* Add 201 to AllowedResponses

* Reduce MacOS testing to 3.9

* Fixed Content-Type header mismatch. Closes CrowdStrike#261.

* Unit test refactoring

* Missing credential_logout method

* Unit test refactoring

* Unit test debugging

* Unit test refactoring

* Filter deprecated classes from dynamic imports.

* Refactored unit testing

* Refactored unit testing

* Refactored unit testing

* Fixed content-type header mismatch. Closes CrowdStrike#262.

* Expanded unit testing to better cover file mgmt.

* Linting

* Unit test performance optimization

* Removed force_default dependance. Relates to CrowdStrike#263.

* Service classes require kwargs. Closes CrowdStrike#263. [BC]

* Refactored unit testing to speak to CrowdStrike#263

* Unit test refactoring

* Update CHANGELOG.md to current

* Refactored to new pattern (rev 3). Closes CrowdStrike#264.

* Unit test refactoring

* Comment updates

* Update CHANGELOG.md

* Better solution that closes CrowdStrike#263.

* Fix typo

* Fix typo

* Add after param to IOC query eps. Closes CrowdStrike#266.

* Update wordlist.txt

* Update CHANGELOG.md

* Fix typo

* Refactored to the latest pattern. Closes CrowdStrike#267.

* Update CHANGELOG.md

* Unit test refactor - reduce auth & test new paths

* Comment updates

* Comment updates

* Temporarily allow 500s for indicator check.

* Reduce logout unit test flakiness

* Removed 500 allowance for code paths check.

* Refactored. Relates to CrowdStrike#270. Closes CrowdStrike#271.

* Related to CrowdStrike#263. Related to CrowdStrike#270.

* Refactored. Related to CrowdStrike#270. Closes CrowdStrike#269.

* Refactored and expanded unit test coverage.

* Minor unit testing adjustments.

* Linting

* Comments

* More forgiving perform_action test

* Flaky unit test adjustments

* Refactored to the latest pattern. Closes CrowdStrike#272.

* Refactored unit testing to match latest pattern.

* Refactored to the latest pattern. Closes CrowdStrike#273.

* Refactored to the latest unit test pattern.

* Refactored to the latest pattern. Closes CrowdStrike#274.

* Add body payload validation to new pattern helper

* Minor unit test adjustments

* Refactored to the latest pattern. Closes CrowdStrike#275.

* Refactored to the latest unit test pattern

* Refactored to the latest pattern. Closes CrowdStrike#276.

* Refactored to the latest unit test pattern

* Reduce flaky unit test executions

* Fix typo

* Fix typo

* Fix typo

* Refactored to the latest pattern. Closes CrowdStrike#277.

* Refactored to the latest pattern. Closes CrowdStrike#278.

* Refactored to the latest unit test pattern

* Migrate auth to latest pattern

* Reduced token-related API requests

* Refactored to the latest pattern. Closes CrowdStrike#279.

* Refactored to the latest pattern. Closes CrowdStrike#280.

* Refactored to the latest pattern. Closes CrowdStrike#281.

* Refactored to the latest pattern. Closes CrowdStrike#282.

* Add direct authentication to Service Classes

* Direct authentication unit testing

* Fix typo

* Refactored to the latest pattern. Closes CrowdStrike#283.

* Refactored to the latest pattern. Closes CrowdStrike#284.

* Refactored to the latest pattern. Closes CrowdStrike#285.

* Easier method names (PEP8 versions)

* Unit test debugging

* Fix typo

* Unit test debugging

* Refactored to the latest pattern. Closes CrowdStrike#286.

* Refactored to the latest pattern. Closes CrowdStrike#287.

* Unit testing refinements to combat flakiness

* Unit testing refinements to combat flakiness.

* Unit testing refinements to combat flakiness

* Unit test refinements to combat response flakiness

* Unit testing refinements to address flakiness

* Unit test refinement to address flakiness

* Unit test refinement to combat flakiness

* Refactored to the latest pattern. Closes CrowdStrike#288.

* More unit test adjustments to combat flakiness

* Unit test adjustments to combat flakiness

* Refined failure detection

* Comments

* Refactored to the latest pattern. Closes CrowdStrike#289.

* Refactored to the latest pattern. Closes CrowdStrike#290.

* Refactored to Rev 3. Closes CrowdStrike#291. Closes CrowdStrike#292.

* Refactored to the latest pattern. Closes CrowdStrike#293.

* Refactored to the latest pattern. Closes CrowdStrike#294.

* Refactored to the latest pattern. Closes CrowdStrike#295.

* Refactored to the latest pattern. Closes CrowdStrike#296.

* Refactored to the latest pattern. Closes CrowdStrike#297.

* Refactored to the latest pattern. Closes CrowdStrike#298.

* Refactored to the latest pattern. Closes CrowdStrike#299.

* Major pattern update. Bump version -> 0.6.0.

* Add direct authentication functionality

* Add direct authentication handler

* Direct authentication code coverage updates

* Update CHANGELOG.md

* Update wordlist.txt

* Update CHANGELOG.md

* Update CHANGELOG.md

* Comments

* Fixed missing HTTP method specification

* Update class types diagram

* Update CHANGELOG.md

* Update CHANGELOG.md

* Remove duplicative action_name parameter check

* Add report_executions endpoints

* Add scheduled_reports endpoints

* Add new endpoints

* Linting

* Add Report Executions Service Class

* Add Scheduled Reports Service Class

* Fix typo (Wrong endpoint module import)

* New unit tests to cover new Service Classes

* Update CHANGELOG.md

* Add new ZTA compliance endpoint

* Add new compliance endpoint to ZTA Service Class

* Updated unit test to cover new code paths

* Update CHANGELOG.md

* Update wordlist.txt

* Fix missing IDs parameter form. (Uber-class req)

* Abstract HTTP method from ep module in svc classes

* Fix typo

* Remove unnecessary HTTP method specification

* Adjust unit test

* Fix typo

* Adjusted unit test to provide better code coverage
jshcodes added a commit that referenced this issue Dec 10, 2021
* Update CHANGELOG.md

* Update README.md

* Bump version -> 0.8.10

* Add Message Center endpoints

* Add Message Center body payload handlers.

* Add single argument handler to get_sample method.

* Linting

* Expand unit testing to cover new code paths.

* Better missing keyword handling. Fixes #263.

* Add Message Center Service Class.

* Fix docstrings.

* Fix linting.

* Update wordlist.txt

* Update CHANGELOG.md

* Expand unit testing. Linting.

* Update CHANGELOG.md

* Fix truly weird typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working SDK usage General SDK usage issues and questions
Projects
None yet
2 participants