diff --git a/src/falconpy/__init__.py b/src/falconpy/__init__.py index 9934d34da..e0fe8febf 100644 --- a/src/falconpy/__init__.py +++ b/src/falconpy/__init__.py @@ -104,7 +104,6 @@ from .cspm_registration import CSPMRegistration from .custom_ioa import CustomIOA from .custom_storage import CustomStorage -from .datascanner import DataScanner from .d4c_registration import D4CRegistration from .detects import Detects from .device_control_policies import DeviceControlPolicies @@ -203,7 +202,7 @@ "ContainerAlerts", "ContainerDetections", "ContainerImages", "ContainerPackages", "ContainerVulnerabilities", "DriftIndicators", "UnidentifiedContainers", "ImageAssessmentPolicies", "APIIntegrations", "ThreatGraph", "ExposureManagement", - "DataScanner", "CertificateBasedExclusions", "ComplianceAssessments", "HostMigration" + "CertificateBasedExclusions", "ComplianceAssessments", "HostMigration" ] """ This is free and unencumbered software released into the public domain. diff --git a/src/falconpy/_endpoint/__init__.py b/src/falconpy/_endpoint/__init__.py index d8fb97ee5..765ef0fa8 100644 --- a/src/falconpy/_endpoint/__init__.py +++ b/src/falconpy/_endpoint/__init__.py @@ -37,7 +37,6 @@ from .deprecated import _scheduled_reports_deprecated from .deprecated import _zero_trust_assessment_deprecated from .deprecated import _certificate_based_exclusions_deprecated -from .deprecated import _datascanner_deprecated from .deprecated import _deprecated_operation_mapping from .deprecated import _deprecated_class_mapping @@ -109,7 +108,6 @@ from ._spotlight_vulnerabilities import _spotlight_vulnerabilities_endpoints from ._tailored_intelligence import _tailored_intelligence_endpoints from ._threatgraph import _threatgraph_endpoints -from ._datascanner import _datascanner_endpoints from ._unidentified_containers import _unidentified_containers_endpoints from ._user_management import _user_management_endpoints from ._workflows import _workflows_endpoints @@ -132,7 +130,6 @@ api_endpoints.extend(_cspm_registration_endpoints) api_endpoints.extend(_custom_ioa_endpoints) api_endpoints.extend(_custom_storage_endpoints) -api_endpoints.extend(_datascanner_endpoints) api_endpoints.extend(_d4c_registration_endpoints) api_endpoints.extend(_detects_endpoints) api_endpoints.extend(_device_control_policies_endpoints) @@ -194,7 +191,6 @@ deprecated_endpoints = [] deprecated_endpoints.extend(_certificate_based_exclusions_deprecated) deprecated_endpoints.extend(_custom_ioa_deprecated) -deprecated_endpoints.extend(_datascanner_deprecated) deprecated_endpoints.extend(_d4c_registration_deprecated) deprecated_endpoints.extend(_discover_deprecated) deprecated_endpoints.extend(_fdr_deprecated) diff --git a/src/falconpy/_endpoint/_datascanner.py b/src/falconpy/_endpoint/_datascanner.py deleted file mode 100644 index fb55c41d4..000000000 --- a/src/falconpy/_endpoint/_datascanner.py +++ /dev/null @@ -1,80 +0,0 @@ -"""Internal API endpoint constant library. - - _______ __ _______ __ __ __ -| _ .----.-----.--.--.--.--| | _ | |_.----|__| |--.-----. -|. 1___| _| _ | | | | _ | 1___| _| _| | <| -__| -|. |___|__| |_____|________|_____|____ |____|__| |__|__|__|_____| -|: 1 | |: 1 | -|::.. . | CROWDSTRIKE FALCON |::.. . | FalconPy -`-------' `-------' - -OAuth2 API - Customer SDK - -This is free and unencumbered software released into the public domain. - -Anyone is free to copy, modify, publish, use, compile, sell, or -distribute this software, either in source code form or as a compiled -binary, for any purpose, commercial or non-commercial, and by any -means. - -In jurisdictions that recognize copyright laws, the author or authors -of this software dedicate any and all copyright interest in the -software to the public domain. We make this dedication for the benefit -of the public at large and to the detriment of our heirs and -successors. We intend this dedication to be an overt act of -relinquishment in perpetuity of all present and future rights to this -software under copyright law. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -For more information, please refer to -""" - -_datascanner_endpoints = [ - [ - "get_image_registry_credentials", - "GET", - "/data-security-dspm/entities/image-registry-credentials/v1", - "", - "datascanner", - [] - ], - [ - "get_data_scanner_tasks", - "GET", - "/data-security-dspm/entities/scanner-tasks/v1", - "", - "datascanner", - [ - { - "type": "string", - "description": "ID of the data scanner", - "name": "X-Scanner-Id", - "in": "header", - "required": True - } - ] - ], - [ - "update_data_scanner_tasks", - "PATCH", - "/data-security-dspm/entities/scanner-tasks/v1", - "", - "datascanner", - [ - { - "type": "string", - "description": "ID of the data scanner", - "name": "X-Scanner-Id", - "in": "header", - "required": True - } - ] - ] -] diff --git a/src/falconpy/_endpoint/deprecated/__init__.py b/src/falconpy/_endpoint/deprecated/__init__.py index 7c7ec56a8..5bd72ac17 100644 --- a/src/falconpy/_endpoint/deprecated/__init__.py +++ b/src/falconpy/_endpoint/deprecated/__init__.py @@ -50,7 +50,6 @@ from ._zero_trust_assessment import _zero_trust_assessment_endpoints from ._mapping import _deprecated_op_mapping, _deprecated_cls_mapping from ._certificate_based_exclusions import _certificate_based_exclusions_endpoints -from ._datascanner import _datascanner_endpoints _custom_ioa_deprecated = _custom_ioa_endpoints _d4c_registration_deprecated = _d4c_registration_endpoints @@ -70,6 +69,5 @@ _scheduled_reports_deprecated = _scheduled_reports_endpoints _zero_trust_assessment_deprecated = _zero_trust_assessment_endpoints _certificate_based_exclusions_deprecated = _certificate_based_exclusions_endpoints -_datascanner_deprecated = _datascanner_endpoints _deprecated_operation_mapping = _deprecated_op_mapping _deprecated_class_mapping = _deprecated_cls_mapping diff --git a/src/falconpy/_endpoint/deprecated/_datascanner.py b/src/falconpy/_endpoint/deprecated/_datascanner.py deleted file mode 100644 index e6a1c4786..000000000 --- a/src/falconpy/_endpoint/deprecated/_datascanner.py +++ /dev/null @@ -1,80 +0,0 @@ -"""Internal API endpoint constant library (deprecated operations). - - _______ __ _______ __ __ __ -| _ .----.-----.--.--.--.--| | _ | |_.----|__| |--.-----. -|. 1___| _| _ | | | | _ | 1___| _| _| | <| -__| -|. |___|__| |_____|________|_____|____ |____|__| |__|__|__|_____| -|: 1 | |: 1 | -|::.. . | CROWDSTRIKE FALCON |::.. . | FalconPy -`-------' `-------' - -OAuth2 API - Customer SDK - -This is free and unencumbered software released into the public domain. - -Anyone is free to copy, modify, publish, use, compile, sell, or -distribute this software, either in source code form or as a compiled -binary, for any purpose, commercial or non-commercial, and by any -means. - -In jurisdictions that recognize copyright laws, the author or authors -of this software dedicate any and all copyright interest in the -software to the public domain. We make this dedication for the benefit -of the public at large and to the detriment of our heirs and -successors. We intend this dedication to be an overt act of -relinquishment in perpetuity of all present and future rights to this -software under copyright law. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -For more information, please refer to -""" - -_datascanner_endpoints = [ - [ - "get-image-registry-credentials", - "GET", - "/data-security-dspm/entities/image-registry-credentials/v1", - "", - "datascanner", - [] - ], - [ - "get-data-scanner-tasks", - "GET", - "/data-security-dspm/entities/scanner-tasks/v1", - "", - "datascanner", - [ - { - "type": "string", - "description": "ID of the data scanner", - "name": "X-Scanner-Id", - "in": "header", - "required": True - } - ] - ], - [ - "update-data-scanner-tasks", - "PATCH", - "/data-security-dspm/entities/scanner-tasks/v1", - "", - "datascanner", - [ - { - "type": "string", - "description": "ID of the data scanner", - "name": "X-Scanner-Id", - "in": "header", - "required": True - } - ] - ] -] diff --git a/src/falconpy/_payload/_certificate_based_exclusions.py b/src/falconpy/_payload/_certificate_based_exclusions.py index b9933b0f5..29a1c0689 100644 --- a/src/falconpy/_payload/_certificate_based_exclusions.py +++ b/src/falconpy/_payload/_certificate_based_exclusions.py @@ -35,40 +35,42 @@ For more information, please refer to """ + from typing import Dict, List, Union def certificate_based_exclusions_payload(passed_keywords: dict) -> Dict[str, List[Dict[str, Union[str, int]]]]: - """Create a properly formatted payload for exclusion creatio - { - "resources": [ - { - "applied_globally": true, - "certificate": { - "issuer": "string", - "serial": "string", - "subject": "string", - "thumbprint": "string", - "valid_from": "2024-07-17T16:55:01.502Z", - "valid_to": "2024-07-17T16:55:01.502Z" - }, - "children_cids": [ - "string" - ], - "comment": "string", - "created_by": "string", - "created_on": "2024-07-17T16:55:01.502Z", - "description": "string", - "host_groups": [ - "string" - ], - "modified_by": "string", - "modified_on": "2024-07-17T16:55:01.502Z", - "name": "string", - "status": "string" - } - ] - } + """Create a properly formatted payload for exclusion creation. + + { + "resources": [ + { + "applied_globally": true, + "certificate": { + "issuer": "string", + "serial": "string", + "subject": "string", + "thumbprint": "string", + "valid_from": "2024-07-17T16:55:01.502Z", + "valid_to": "2024-07-17T16:55:01.502Z" + }, + "children_cids": [ + "string" + ], + "comment": "string", + "created_by": "string", + "created_on": "2024-07-17T16:55:01.502Z", + "description": "string", + "host_groups": [ + "string" + ], + "modified_by": "string", + "modified_on": "2024-07-17T16:55:01.502Z", + "name": "string", + "status": "string" + } + ] + } """ returned = { "resources": [] diff --git a/src/falconpy/certificate_based_exclusions.py b/src/falconpy/certificate_based_exclusions.py index 63d480f45..baa0f9324 100644 --- a/src/falconpy/certificate_based_exclusions.py +++ b/src/falconpy/certificate_based_exclusions.py @@ -35,6 +35,7 @@ For more information, please refer to """ + from typing import Dict, Union from ._util import force_default, process_service_request, handle_single_argument from ._service_class import ServiceClass @@ -54,9 +55,10 @@ class CertificateBasedExclusions(ServiceClass): - a previously-authenticated instance of the authentication service class (oauth2.py) - a valid token provided by the authentication service class (oauth2.py) """ + @force_default(defaults=["parameters"], default_types=["dict"]) def get_exclusions(self: object, *args, parameters: dict = None, **kwargs) -> Dict[str, Union[int, dict]]: - """Find all exclusion IDs matching the query with filter + """Find all exclusion IDs matching the query with filter. Keyword arguments: ids -- One or more exclusion IDs . String or list of strings. @@ -130,7 +132,8 @@ def create_exclusions(self: object, body: dict = None, **kwargs) -> Dict[str, Un calling_object=self, endpoints=Endpoints, operation_id="cb_exclusions_create_v1", - body=body + body=body, + keywords=kwargs ) @force_default(defaults=["parameters"], default_types=["dict"]) @@ -159,7 +162,7 @@ def delete_exclusions(self: object, *args, parameters: dict = None, **kwargs) -> keywords=kwargs, params=handle_single_argument(args, parameters, "ids") ) - + @force_default(defaults=["body"], default_types=["dict"]) def update_exclusions(self: object, body: dict = None, **kwargs) -> Dict[str, Union[int, dict]]: """Update Certificate Based Exclusions. @@ -267,7 +270,7 @@ def query_certificates(self: object, parameters: dict = None, **kwargs) -> Dict[ keywords=kwargs, params=parameters ) - + # These method names align to the operation IDs in the API but # do not conform to snake_case / PEP8 and are defined here for # backwards compatibility / ease of use purposes diff --git a/src/falconpy/compliance_assessments.py b/src/falconpy/compliance_assessments.py index a1aae1a32..2cf00d3c7 100644 --- a/src/falconpy/compliance_assessments.py +++ b/src/falconpy/compliance_assessments.py @@ -35,6 +35,7 @@ For more information, please refer to """ + from typing import Dict, Union from ._util import force_default, process_service_request from ._service_class import ServiceClass @@ -53,6 +54,7 @@ class ComplianceAssessments(ServiceClass): - a previously-authenticated instance of the authentication service class (oauth2.py) - a valid token provided by the authentication service class (oauth2.py) """ + @force_default(defaults=["parameters"], default_types=["dict"]) def aggregate_cluster_assessments(self: object, parameters: dict = None, **kwargs) -> Dict[str, Union[int, dict]]: """Get the assessments for each cluster. @@ -99,7 +101,8 @@ def aggregate_image_assessments(self: object, parameters: dict = None, **kwargs) image_id: Image ID cloud_info.cloud_provider: Cloud provider asset_type: asset type (container image) - compliance_finding.severity: Compliance finding severity; available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) + compliance_finding.severity: Compliance finding severity; + available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) compliance_finding.framework: Compliance finding framework (available values: CIS) image_repository: Image repository cloud_info.cloud_account_id: Cloud account ID @@ -141,7 +144,8 @@ def aggregate_rules_assessments(self: object, parameters: dict = None, **kwargs) cloud_info.cloud_account_id: Cloud account ID cloud_info.cloud_provider: Cloud provider compliance_finding.id: Compliance finding ID - compliance_finding.severity: Compliance finding severity; available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) + compliance_finding.severity: Compliance finding severity; + available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) cloud_info.cluster_name: Kubernetes cluster name image_id: Image ID image_tag: Image tag @@ -168,7 +172,7 @@ def aggregate_rules_assessments(self: object, parameters: dict = None, **kwargs) @force_default(defaults=["parameters"], default_types=["dict"]) def aggregate_failed_containers_by_rules(self: object, parameters: dict = None, **kwargs) -> Dict[str, Union[int, dict]]: - """get the containers grouped into rules on which they failed + """Get the containers grouped into rules on which they failed. Keyword arguments: filter -- "Filter results using a query in Falcon Query Language (FQL). Supported Filters: @@ -181,7 +185,8 @@ def aggregate_failed_containers_by_rules(self: object, parameters: dict = None, compliance_finding.framework: Compliance finding framework (available values: CIS) cloud_info.cloud_provider: Cloud provider compliance_finding.id: Compliance finding ID - compliance_finding.severity: Compliance finding severity; available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) + compliance_finding.severity: Compliance finding severity; + available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) cid: Customer ID image_id: Image ID image_digest: Image digest (sha256 digest) @@ -206,8 +211,9 @@ def aggregate_failed_containers_by_rules(self: object, parameters: dict = None, ) @force_default(defaults=["parameters"], default_types=["dict"]) - def aggregate_failed_containers_count_by_severity(self: object, parameters: dict = None, **kwargs) -> Dict[str, Union[int, dict]]: - """Get the failed containers count grouped into severity levels + def aggregate_failed_containers_count_by_severity(self: object, + parameters: dict = None, **kwargs) -> Dict[str, Union[int, dict]]: + """Get the failed containers count grouped into severity levels. Keyword arguments: filter -- "Filter results using a query in Falcon Query Language (FQL). Supported Filters: @@ -216,7 +222,8 @@ def aggregate_failed_containers_count_by_severity(self: object, parameters: dict compliance_finding.id: Compliance finding ID image_registry: Image registry compliance_finding.name: Compliance finding Name - compliance_finding.severity: Compliance finding severity; available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) + compliance_finding.severity: Compliance finding severity; + available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) cloud_info.cluster_name: Kubernetes cluster name cloud_info.cloud_account_id: Cloud account ID image_id: Image ID @@ -246,7 +253,7 @@ def aggregate_failed_containers_count_by_severity(self: object, parameters: dict @force_default(defaults=["parameters"], default_types=["dict"]) def aggregate_failed_images_by_rules(self: object, parameters: dict = None, **kwargs) -> Dict[str, Union[int, dict]]: - """get the images grouped into rules on which they failed + """Get the images grouped into rules on which they failed. Keyword arguments: filter -- "Filter results using a query in Falcon Query Language (FQL). Supported Filters: @@ -260,7 +267,8 @@ def aggregate_failed_images_by_rules(self: object, parameters: dict = None, **kw compliance_finding.framework: Compliance finding framework (available values: CIS) cloud_info.namespace: Kubernetes namespace cid: Customer ID - compliance_finding.severity: Compliance finding severity; available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) + compliance_finding.severity: Compliance finding severity; + available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) cloud_info.cloud_provider: Cloud provider compliance_finding.id: Compliance finding ID image_id: Image ID @@ -284,14 +292,16 @@ def aggregate_failed_images_by_rules(self: object, parameters: dict = None, **kw ) @force_default(defaults=["parameters"], default_types=["dict"]) - def aggregate_failed_images_count_by_severity(self: object, parameters: dict = None, **kwargs) -> Dict[str, Union[int, dict]]: - """Get the failed images count grouped into severity levels + def aggregate_failed_images_count_by_severity(self: object, + parameters: dict = None, **kwargs) -> Dict[str, Union[int, dict]]: + """Get the failed images count grouped into severity levels. Keyword arguments: filter -- "Filter results using a query in Falcon Query Language (FQL). Supported Filters: image_tag: Image tag compliance_finding.name: Compliance finding Name - compliance_finding.severity: Compliance finding severity; available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) + compliance_finding.severity: Compliance finding severity; + available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) cloud_info.cloud_account_id: Cloud account ID image_digest: Image digest (sha256 digest) image_registry: Image registry @@ -336,7 +346,8 @@ def aggregate_failed_rules_by_clusters(self: object, parameters: dict = None, ** image_registry: Image registry cloud_info.cloud_region: Cloud region asset_type: asset type (container, image) - compliance_finding.severity: Compliance finding severity; available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) + compliance_finding.severity: Compliance finding severity; + available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) cid: Customer ID compliance_finding.id: Compliance finding ID compliance_finding.framework: Compliance finding framework (available values: CIS) @@ -377,7 +388,8 @@ def aggregate_failed_rules_by_image(self: object, parameters: dict = None, **kwa cloud_info.cloud_region: Cloud region cloud_info.cloud_account_id: Cloud account ID asset_type: asset type (container, image) - compliance_finding.severity: Compliance finding severity; available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) + compliance_finding.severity: Compliance finding severity; + available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) image_id: Image ID image_digest: Image digest (sha256 digest) compliance_finding.framework: Compliance finding framework (available values: CIS) @@ -402,7 +414,8 @@ def aggregate_failed_rules_by_image(self: object, parameters: dict = None, **kwa ) @force_default(defaults=["parameters"], default_types=["dict"]) - def aggregate_failed_rules_count_by_severity(self: object, parameters: dict = None, **kwargs) -> Dict[str, Union[int, dict]]: + def aggregate_failed_rules_count_by_severity(self: object, + parameters: dict = None, **kwargs) -> Dict[str, Union[int, dict]]: """Get the failed rules count grouped into severity levels. Keyword arguments: @@ -416,7 +429,8 @@ def aggregate_failed_rules_count_by_severity(self: object, parameters: dict = No compliance_finding.framework: Compliance finding framework (available values: CIS) image_repository: Image repository cloud_info.cloud_account_id: Cloud account ID - compliance_finding.severity: Compliance finding severity; available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) + compliance_finding.severity: Compliance finding severity; + available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) asset_type: asset type (container, image) cloud_info.cluster_name: Kubernetes cluster name cloud_info.cloud_provider: Cloud provider @@ -450,7 +464,8 @@ def aggregate_rules_by_status(self: object, parameters: dict = None, **kwargs) - image_tag: Image tag compliance_finding.name: Compliance finding Name asset_type: asset type (container, image) - compliance_finding.severity: Compliance finding severity; available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) + compliance_finding.severity: Compliance finding severity; + available values: 4, 3, 2, 1 (4: critical, 3: high, 2: medium, 1:low) cid: Customer ID container_name: Container name cloud_info.cluster_name: Kubernetes cluster name diff --git a/src/falconpy/datascanner.py b/src/falconpy/datascanner.py deleted file mode 100644 index d3905f83c..000000000 --- a/src/falconpy/datascanner.py +++ /dev/null @@ -1,154 +0,0 @@ -"""CrowdStrike Falcon Datascanner API interface class. - - _______ __ _______ __ __ __ -| _ .----.-----.--.--.--.--| | _ | |_.----|__| |--.-----. -|. 1___| _| _ | | | | _ | 1___| _| _| | <| -__| -|. |___|__| |_____|________|_____|____ |____|__| |__|__|__|_____| -|: 1 | |: 1 | -|::.. . | CROWDSTRIKE FALCON |::.. . | FalconPy -`-------' `-------' - -OAuth2 API - Customer SDK - -This is free and unencumbered software released into the public domain. - -Anyone is free to copy, modify, publish, use, compile, sell, or -distribute this software, either in source code form or as a compiled -binary, for any purpose, commercial or non-commercial, and by any -means. - -In jurisdictions that recognize copyright laws, the author or authors -of this software dedicate any and all copyright interest in the -software to the public domain. We make this dedication for the benefit -of the public at large and to the detriment of our heirs and -successors. We intend this dedication to be an overt act of -relinquishment in perpetuity of all present and future rights to this -software under copyright law. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -For more information, please refer to -""" -from typing import Dict, Union -from ._util import force_default, process_service_request -from ._service_class import ServiceClass -from ._endpoint._datascanner import _datascanner_endpoints as Endpoints - - -class DataScanner(ServiceClass): - """The only requirement to instantiate an instance of this class is one of the following. - - - a valid client_id and client_secret provided as keywords. - - a credential dictionary with client_id and client_secret containing valid API credentials - { - "client_id": "CLIENT_ID_HERE", - "client_secret": "CLIENT_SECRET_HERE" - } - - a previously-authenticated instance of the authentication service class (oauth2.py) - - a valid token provided by the authentication service class (oauth2.py) - """ - - @force_default(defaults=["parameters"], default_types=["dict"]) - def get_image_registry_credentials(self: object) -> Dict[str, Union[int, dict]]: - """Retrieve the registry credentials. - - HTTP Method: GET - - Swagger URL - ---- - https://assets.falcon.crowdstrike.com/support/api/swagger.html#/datascanner/get-image-registry-credentials - - Keyword arguments - ---- - This method does not accept keyword arguments. - - Arguments - ---- - This method does not accept arguments. - - Returns - ---- - dict - Dictionary object containing API response. - """ - return process_service_request( - calling_object=self, - endpoints=Endpoints, - operation_id="get_image_registry_credentials", - ) - - @force_default(defaults=["parameters"], default_types=["dict"]) - def get_data_scanner_tasks(self: object, parameters: dict = None, **kwargs) -> Dict[str, Union[int, dict]]: - """Retrieve data scanner tasks identified by the id. - - HTTP Method: GET - - Swagger URL - ---- - https://assets.falcon.crowdstrike.com/support/api/swagger.html#/datascanner/get-data-scanner-tasks - - Keyword arguments - ---- - X-Scanner-Id : str (required) - id of the data scanner. - - This method only supports keywords for providing arguments. - - Returns - ---- - dict - Dictionary object containing API response. - """ - return process_service_request( - calling_object=self, - endpoints=Endpoints, - operation_id="get_data_scanner_tasks", - keywords=kwargs, - params=parameters - ) - - @force_default(defaults=["parameters"], default_types=["dict"]) - def update_data_scanner_tasks(self: object, parameters: dict = None, **kwargs) -> Dict[str, Union[int, dict]]: - """Update data scanner tasks, as identified by the X-Scanner-Id. - - HTTP Method: PATCH - - Swagger URL - ---- - https://assets.falcon.crowdstrike.com/support/api/swagger.html#/datascanner/update-data-scanner-tasks - - Keyword arguments - ---- - X-Scanner-Id : str - ID of the data scanner - X-Machine-Id : str - Provider ID of the machine - - This method only supports keywords for providing arguments. - - Returns - ---- - dict - Dictionary object containing API response. - """ - - return process_service_request( - calling_object=self, - endpoints=Endpoints, - operation_id="update_data_scanner_tasks", - keywords=kwargs, - params=parameters - ) - - # These method names align to the operation IDs in the API but - # do not conform to snake_case / PEP8 and are defined here for - # backwards compatibility / ease of use purposes - get_image_registry_credentials = get_image_registry_credentials - get_data_scanner_tasks = get_data_scanner_tasks - update_data_scanner_tasks = update_data_scanner_tasks diff --git a/src/falconpy/host_migration.py b/src/falconpy/host_migration.py index ea7c2d3b3..4bfd388a8 100644 --- a/src/falconpy/host_migration.py +++ b/src/falconpy/host_migration.py @@ -35,6 +35,7 @@ For more information, please refer to """ + from typing import Dict, Union from ._util import force_default, process_service_request, generate_error_result, handle_single_argument from ._service_class import ServiceClass @@ -128,9 +129,8 @@ def aggregate_host_migration(self: object, body: list = None, **kwargs) -> Dict[ HTTP Method: POST Swagger URL - https://assets.falcon.crowdstrike.com/support/api/swagger.html#/host-migration/HostMigrationAggregatesV1 + https://assets.falcon.crowdstrike.com/support/api/swagger.html#/host-migration/HostMigrationAggregatesV1 """ - if not body: body = [aggregate_payload(submitted_keywords=kwargs)] @@ -198,7 +198,7 @@ def aggregate_migration(self: object, body: list = None, **kwargs) -> Dict[str, Type 1 - Terms "type": "terms" Supported field values: name, id, migration_id, target_cid, status, migration_status, created_by. - sort on terms type must be done on the same value as field and include a direction (asc or desc). + sort on terms type must be done on the same value as field and include a direction (asc or desc). Supports all supported FQL fields. Examples sort value: status|asc or created_by|desc. @@ -214,7 +214,6 @@ def aggregate_migration(self: object, body: list = None, **kwargs) -> Dict[str, Swagger URL https://assets.falcon.crowdstrike.com/support/api/swagger.html#/host-migration/MigrationAggregatesV1 """ - if not body: body = [aggregate_payload(submitted_keywords=kwargs)] @@ -230,10 +229,9 @@ def perform_host_migration_action(self: object, body: dict = None, parameters: dict = None, **kwargs) -> Dict[str, Union[int, dict]]: - """Perform an action on host migrations + """Perform an action on host migrations. Keyword arguments: - id -- The migration job to perform actions on. String. action_name -- The action to perform @@ -344,7 +342,6 @@ def get_host_migration_details(self: object, body: dict = None, **kwargs) -> Dic Swagger URL https://assets.falcon.crowdstrike.com/support/api/swagger.html#/host-migration/GetHostMigrationsV1 """ - if not body: body = generic_payload_list(submitted_keywords=kwargs, payload_value="ids" @@ -359,7 +356,7 @@ def get_host_migration_details(self: object, body: dict = None, **kwargs) -> Dic @force_default(defaults=["body"], default_types=["dict"]) def get_migration_destination(self: object, body: dict = None, **kwargs) -> Dict[str, Union[int, dict]]: - """Gets destinations for a migration + """Get destinations for a migration. Keyword arguments: body -- full body payload, not required if using other keywords. @@ -381,7 +378,6 @@ def get_migration_destination(self: object, body: dict = None, **kwargs) -> Dict Swagger URL https://assets.falcon.crowdstrike.com/support/api/swagger.html#/host-migration/GetMigrationDestinationsV1 """ - if not body: if kwargs.get("device_ids", None): body = generic_payload_list(submitted_keywords=kwargs, @@ -401,7 +397,7 @@ def perform_migration_job_action(self: object, body: dict = None, parameters: dict = None, **kwargs) -> Dict[str, Union[int, dict]]: - """Perform an action on host migrations + """Perform an action on host migrations. Keyword arguments: action_name -- The action to perform @@ -478,7 +474,7 @@ def perform_migration_job_action(self: object, @force_default(defaults=["parameters"], default_types=["dict"]) def get_migration_job_details(self: object, *args, parameters: dict = None, **kwargs) -> Dict[str, Union[int, dict]]: - """Get migration job details + """Get migration job details. Keyword arguments: ids -- The migration jobs of interest. @@ -552,7 +548,7 @@ def create_migration(self: object, body: dict = None, **kwargs) -> Dict[str, Uni @force_default(defaults=["parameters"], default_types=["dict"]) def query_host_migration_ids(self: object, parameters: dict = None, **kwargs) -> Dict[str, Union[int, dict]]: - """Query host migration IDs + """Query host migration IDs. Provide a FQL filter and paging details. diff --git a/tests/test_certificate_based_exclusions.py b/tests/test_certificate_based_exclusions.py index 184c80d3e..8c0436c31 100644 --- a/tests/test_certificate_based_exclusions.py +++ b/tests/test_certificate_based_exclusions.py @@ -24,15 +24,15 @@ def test_all_code_paths(self): error_checks = True tests = { "get_exclusions": falcon.get_exclusions(ids="1234567"), - "create_exclusions": falcon.create_exclusions("12345678"), + "create_exclusions": falcon.create_exclusions(body={}), "delete_exclusions": falcon.delete_exclusions(ids="1234567"), - "update_exclusions": falcon.update_exclusions("exclusion_here"), + "update_exclusions": falcon.update_exclusions(body={}), "get_certificates": falcon.get_certificates(ids="1234567"), "query_certificates": falcon.query_certificates() } for key in tests: if tests[key]["status_code"] not in AllowedResponses: error_checks = False - # print(key) - # print(tests[key]) + # print(key) + # print(tests[key]) assert error_checks diff --git a/tests/test_compliance_assessments.py b/tests/test_compliance_assessments.py index 22b5687b5..a69930d83 100644 --- a/tests/test_compliance_assessments.py +++ b/tests/test_compliance_assessments.py @@ -38,6 +38,6 @@ def test_all_code_paths(self): for key in tests: if tests[key]["status_code"] not in AllowedResponses: error_checks = False - # print(key) - # print(tests[key]) + # print(key) + # print(tests[key]) assert error_checks diff --git a/tests/test_datascanner.py b/tests/test_datascanner.py deleted file mode 100644 index 39d0e2292..000000000 --- a/tests/test_datascanner.py +++ /dev/null @@ -1,35 +0,0 @@ -# test_certificate_based_exclusions.py -# This class tests the CertificateBasedExclusions service class - -# import json -import os -import sys - -# Authentication via the test_authorization.py -from tests import test_authorization as Authorization - -# Classes to test - manually imported from sibling folder -from falconpy import DataScanner -# Import our sibling src folder into the path -sys.path.append(os.path.abspath('src')) - -auth = Authorization.TestAuthorization() -config = auth.getConfigObject() -falcon = DataScanner(auth_object=config) -AllowedResponses = [200, 201, 207, 400, 404, 429, 500] - - -class TestDataScanner: - def test_all_code_paths(self): - error_checks = True - tests = { - "get_image_registry_credentials": falcon.get_image_registry_credentials(), - "get_data_scanner_tasks": falcon.get_data_scanner_tasks(), - "update_data_scanner_tasks": falcon.update_data_scanner_tasks() - } - for key in tests: - if tests[key]["status_code"] not in AllowedResponses: - error_checks = False - # print(key) - # print(tests[key]) - assert error_checks diff --git a/tests/test_host_migration.py b/tests/test_host_migration.py index a95802001..3a261db27 100644 --- a/tests/test_host_migration.py +++ b/tests/test_host_migration.py @@ -54,6 +54,6 @@ def test_all_code_paths(self): for key in tests: if tests[key]["status_code"] not in AllowedResponses: error_checks = False - print(key) - print(tests[key]) + # print(key) + # print(tests[key]) assert error_checks