Skip to content

Commit 1d825a8

Browse files
authored
v0.4.1 - action_name, missing methods, CSPM class (#67)
* v0.4.1 - action_name, missing methods, CSPM class * Updated return type decorator on byte result ops * v4.0.1 README.md updates * v4.0.1 README.md updates * v4.0.1 README.md updates * v4.0.1 README.md updates * UpdatedDetectsByIdsV2 validator fix, minor changes
1 parent 9e879ff commit 1d825a8

24 files changed

+765
-240
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ This SDK provides two distinct methods for interacting with CrowdStrike's Falcon
1212
## Quick Install / Uninstall
1313
Stable releases of FalconPy are available on PyPI:
1414
```shell
15-
$ python -m pip install crowdstrike-falconpy
15+
$ python3 -m pip install crowdstrike-falconpy
1616
```
1717

1818
If you'd like to try the *absolute bleeding edge*, an automated GitHub action releases a test package with every merged pull request. To install the testing version:
1919
```shell
20-
$ python -m pip install -i https://test.pypi.org/simple crowdstrike-falconpy
20+
$ python3 -m pip install -i https://test.pypi.org/simple crowdstrike-falconpy
2121
```
2222

2323
To uninstall/remove FalconPy:
2424
```shell
25-
$ python -m pip uninstall crowdstrike-falconpy
25+
$ python3 -m pip uninstall crowdstrike-falconpy
2626
```
2727

2828
# Service classes
@@ -34,8 +34,8 @@ $ python -m pip uninstall crowdstrike-falconpy
3434
| [CrowdStrike Custom Indicators of Compromose (IOCs) APIs](https://falcon.crowdstrike.com/support/documentation/88/custom-ioc-apis) | [./src/falconpy/iocs.py](./src/falconpy/iocs.py) |
3535
| [CrowdStrike Detections APIs](https://falcon.crowdstrike.com/support/documentation/85/detection-and-prevention-policies-apis) | [./src/falconpy/detects.py](./src/falconpy/detects.py) |
3636
| [CrowdStrike Event Streams API](https://falcon.crowdstrike.com/support/documentation/89/event-streams-apis)| [./src/falconpy/event_streams.py](./src/falconpy/event_streams.py) |
37-
| [CrowdStrike Falcon Horizon APIs](https://falcon.crowdstrike.com/support/documentation/137/falcon-horizon-apis) | *Coming Soon* |
38-
| [CrowdStrike Falon X APIs](https://falcon.crowdstrike.com/support/documentation/92/falcon-x-apis) | *Coming Soon* |
37+
| [CrowdStrike Falcon Horizon APIs](https://falcon.crowdstrike.com/support/documentation/137/falcon-horizon-apis) | [./src/falconpy/cspm_registration.py](./src/falconpy/cspm_registration.py) |
38+
| [CrowdStrike Falcon X APIs](https://falcon.crowdstrike.com/support/documentation/92/falcon-x-apis) | *Coming Soon* |
3939
| [CrowdStrike Firewall Management API](https://falcon.crowdstrike.com/support/documentation/107/falcon-firewall-management-apis) | [./src/falconpy/firewall_management.py](./src/falconpy/firewall_management.py) |
4040
| [CrowdStrike Firewall Policy Management](https://falcon.crowdstrike.com/support/documentation/107/falcon-firewall-management-apis) | [./src/falconpy/firewall_policies.py](./src/falconpy/firewall_policies.py) |
4141
| [CrowdStrike Host Groups API](https://falcon.crowdstrike.com/support/documentation/84/host-and-host-group-management-apis) | [./src/falconpy/host_group.py](./src/falconpy/host_group.py) |

src/falconpy/README.MD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ These classes are part of the falconpy project, a python interface handler to th
33

44
### Currently implemented:
55
+ `cloud_connect_aws.py` https://assets.falcon.crowdstrike.com/support/api/swagger.html#/cloud-connect-aws
6+
+ `cspm-registration.py` https://assets.falcon.crowdstrike.com/support/api/swagger.html#/cspm-registration
67
+ `detects.py` https://assets.falcon.crowdstrike.com/support/api/swagger.html#/detects
78
+ `device_control_policies.py` https://assets.falcon.crowdstrike.com/support/api/swagger.html#/device-control-policies
89
+ `event_streams.py` https://assets.falcon.crowdstrike.com/support/api/swagger.html#/event-streams
@@ -24,7 +25,6 @@ These classes are part of the falconpy project, a python interface handler to th
2425

2526
### Planned
2627
+ `d4c-registration.py` https://assets.falcon.crowdstrike.com/support/api/swagger.html#/d4c-registration
27-
+ `cspm-registration.py` https://assets.falcon.crowdstrike.com/support/api/swagger.html#/cspm-registration
2828
+ `installation-tokens.py` https://assets.falcon.crowdstrike.com/support/api/swagger.html#/installation-tokens
2929
+ `custom-ioa.py` https://assets.falcon.crowdstrike.com/support/api/swagger.html#/custom-ioa
3030
+ `malquery.py` https://assets.falcon.crowdstrike.com/support/api/swagger.html#/malquery

src/falconpy/_endpoint.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@
5757
["DeleteCSPMAwsAccount", "DELETE", "/cloud-connect-cspm-aws/entities/account/v1?ids={}"],
5858
["GetCSPMAwsConsoleSetupURLs", "GET", "/cloud-connect-cspm-aws/entities/console-setup-urls/v1"],
5959
["GetCSPMAwsAccountScriptsAttachment", "GET", "/cloud-connect-cspm-aws/entities/user-scripts-download/v1"],
60-
["GetCSPMAzureAccount", "GET", "/cloud-connect-cspm-azure/entities/account/v1?ids={}"],
61-
["CreateCSPMAzureAccount", "POST", "/cloud-connect-cspm-azure/entities/account/v1"],
60+
["GetCSPMAzureAccount2", "GET", "/cloud-connect-cspm-azure/entities/account/v1?ids={}"],
61+
["CreateCSPMAzureAccount2", "POST", "/cloud-connect-cspm-azure/entities/account/v1"],
6262
["DeleteCSPMAzureAccount", "DELETE", "/cloud-connect-cspm-azure/entities/account/v1?ids={}"],
63-
["UpdateCSPMAzureAccountClientID", "PATCH", "/cloud-connect-cspm-azure/entities/client-id/v1"],
64-
["GetCSPMAzureUserScriptsAttachment", "GET", "/cloud-connect-cspm-azure/entities/user-scripts-download/v1"],
63+
["UpdateCSPMAzureAccountClientID2", "PATCH", "/cloud-connect-cspm-azure/entities/client-id/v1"],
64+
["GetCSPMAzureUserScriptsAttachment2", "GET", "/cloud-connect-cspm-azure/entities/user-scripts-download/v1"],
6565
["GetCSPMCGPAccount", "GET", "/cloud-connect-gcp/entities/account/v1?ids={}"],
6666
["CreateCSPMGCPAccount", "POST", "/cloud-connect-gcp/entities/account/v1"],
6767
["GetCSPMGCPUserScriptsAttachment", "GET", "/cloud-connect-gcp/entities/user-scripts-download/v1"],
@@ -73,6 +73,7 @@
7373
["queryCombinedGroupMembers", "GET", "/devices/combined/host-group-members/v1"],
7474
["queryCombinedHostGroups", "GET", "/devices/combined/host-groups/v1"],
7575
["PerformActionV2", "POST", "/devices/entities/devices-actions/v2"],
76+
["UpdateDeviceTags", "PATCH", "/devices/entities/devices/tags/v1"],
7677
["GetDeviceDetails", "GET", "/devices/entities/devices/v1?ids={}"],
7778
["performGroupAction", "POST", "/devices/entities/host-group-actions/v1"],
7879
["getHostGroups", "GET", "/devices/entities/host-groups/v1?ids={}"],

src/falconpy/_util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,7 @@ def perform_request(method: str = "", endpoint: str = "", headers: dict = None,
188188
returned = Result()(405, {}, {"errors": [{"message": "Invalid API service method."}], "resources": ""})
189189

190190
return returned
191+
192+
193+
def generate_error_result(message: str = "An error has occurred. Check your payloads and try again.", code: int = 500) -> dict:
194+
return Result()(status_code=code, headers={}, body={"errors": [{"message": f"{message}"}], "resources": ""})

src/falconpy/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
3737
For more information, please refer to <https://unlicense.org>
3838
"""
39-
_version = '0.4.0'
39+
_version = '0.4.1'
4040
_maintainer = 'Joshua Hiller'
4141
_author = 'CrowdStrike'
4242
_author_email = '[email protected]'

src/falconpy/api_complete.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def deauthenticate(self: object) -> bool:
109109
# NOTE: Not specifying datatypes for "ids" and "partition" parameters
110110
# to allow developers to pass str / lists / integers as necessary
111111
def command(self: object, action: str = "", parameters: dict = {}, body: dict = {}, data: dict = {},
112-
headers: dict = {}, ids=None, partition=None, override: str = None,
112+
headers: dict = {}, ids=None, partition=None, override: str = None, action_name: str = None,
113113
files: list = [], file_name: str = None, content_type: str = None): # May return dict or object datatypes
114114
""" Checks token expiration, renewing when necessary, then performs the request. """
115115
if self.token_expired():
@@ -120,13 +120,18 @@ def command(self: object, action: str = "", parameters: dict = {}, body: dict =
120120
CMD = [a for a in self.commands if a[0] == action]
121121
if CMD:
122122
FULL_URL = self.base_url+"{}".format(CMD[0][2])
123+
# Consider calculating ? vs & character replacement
123124
if ids:
124125
ID_LIST = str(parse_id_list(ids)).replace(",", "&ids=")
125126
FULL_URL = FULL_URL.format(ID_LIST)
127+
if action_name:
128+
delim = "&" if "?" in FULL_URL else "?"
129+
FULL_URL = f"{FULL_URL}{delim}action_name={str(action_name)}" # TODO: Additional action_name restrictions?
126130
if partition:
127131
FULL_URL = FULL_URL.format(str(partition))
128132
if file_name:
129-
FULL_URL = "{}?file_name={}".format(FULL_URL, str(file_name))
133+
delim = "&" if "?" in FULL_URL else "?"
134+
FULL_URL = f"{FULL_URL}{delim}file_name={str(action_name)}"
130135
HEADERS = self.headers()
131136
for item in headers:
132137
HEADERS[item] = headers[item]

0 commit comments

Comments
 (0)