Skip to content

Commit

Permalink
Add ConfigurationAssessmentEvaluationLogic service collection
Browse files Browse the repository at this point in the history
  • Loading branch information
jshcodes committed Dec 22, 2023
1 parent 099b0d5 commit 40eb234
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/falconpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
from .alerts import Alerts
from .api_complete import APIHarness, APIHarnessV2
from .cloud_snapshots import CloudSnapshots
from .configuration_assessment_evaluation_logic import ConfigurationAssessmentEvaluationLogic
from .cloud_connect_aws import CloudConnectAWS
from .cspm_registration import CSPMRegistration
from .custom_ioa import CustomIOA
Expand Down Expand Up @@ -182,7 +183,7 @@
"NoAuthenticationMechanism", "InvalidIndex", "version", "InvalidCredentialFormat",
"UnnecessaryEncodingUsed", "APIHarnessV2", "CustomStorage", "FoundryLogScale",
"RealTimeResponseAudit", "Workflows", "DeprecatedClass", "DeprecatedOperation",
"SDKDeprecationWarning"
"SDKDeprecationWarning", "ConfigurationAssessmentEvaluationLogic"
]
"""
This is free and unencumbered software released into the public domain.
Expand Down
2 changes: 2 additions & 0 deletions src/falconpy/_endpoint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from ._alerts import _alerts_endpoints
from ._cloud_connect_aws import _cloud_connect_aws_endpoints
from ._cloud_snapshots import _cloud_snapshots_endpoints
from ._configuration_assessment_evaluation_logic import _configuration_assessment_evaluation_logic_endpoints
from ._cspm_registration import _cspm_registration_endpoints
from ._custom_ioa import _custom_ioa_endpoints
from ._custom_storage import _custom_storage_endpoints
Expand Down Expand Up @@ -100,6 +101,7 @@
api_endpoints.extend(_alerts_endpoints)
api_endpoints.extend(_cloud_connect_aws_endpoints)
api_endpoints.extend(_cloud_snapshots_endpoints)
api_endpoints.extend(_configuration_assessment_evaluation_logic_endpoints)
api_endpoints.extend(_cspm_registration_endpoints)
api_endpoints.extend(_custom_ioa_endpoints)
api_endpoints.extend(_custom_storage_endpoints)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
"""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 <https://unlicense.org>
"""

_configuration_assessment_evaluation_logic_endpoints = [
[
"getEvaluationLogicMixin0",
"GET",
"/configuration-assessment/entities/evaluation-logic/v1",
"Get details on evaluation logic items by providing one or more finding IDs.",
"configuration_assessment_evaluation_logic",
[
{
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "multi",
"description": "One or more evaluation logic finding IDs.",
"name": "ids",
"in": "query",
"required": True
}
]
]
]
88 changes: 88 additions & 0 deletions src/falconpy/configuration_assessment_evaluation_logic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
"""CrowdStrike Falcon Configuration Assessment Evaluation Logic 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 <https://unlicense.org>
"""
from typing import Dict, Union
from ._util import force_default, process_service_request, handle_single_argument
from ._service_class import ServiceClass
from ._endpoint._configuration_assessment_evaluation_logic import (
_configuration_assessment_evaluation_logic_endpoints as Endpoints
)


class ConfigurationAssessmentEvaluationLogic(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_evaluation_logic(self: object, *args, parameters: dict = None, **kwargs) -> Dict[str, Union[int, dict]]:
"""Get details on evaluation logic items by providing one or more finding IDs.
Keyword arguments:
ids -- One or more evaluation logic finding IDs.
parameters -- Full parameters payload dictionary. Not required if using other keywords.
Arguments: When not specified, the first argument to this method is assumed to be 'ids'.
All others are ignored.
Returns: dict object containing API response.
HTTP Method: GET
Swagger URL
"""
return process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id="getEvaluationLogicMixin0",
keywords=kwargs,
params=handle_single_argument(args, parameters, "ids")
)

# This method name aligns to the operation ID in the API but
# does not conform to snake_case / PEP8 and is defined here for
# backwards compatibility / ease of use purposes
getEvaluationLogicMixin0 = get_evaluation_logic
27 changes: 27 additions & 0 deletions tests/test_configuration_assessment_evaluation_logic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
test_configuration_assessment_evaluation_logic.py -
This class tests the configuration assessment evaluation logic service class
"""
import os
import sys
from datetime import datetime, timedelta
# Authentication via the test_authorization.py
from tests import test_authorization as Authorization
# Import our sibling src folder into the path
sys.path.append(os.path.abspath('src'))
# Classes to test - manually imported from sibling folder
from falconpy import ConfigurationAssessmentEvaluationLogic

auth = Authorization.TestAuthorization()
config = auth.getConfigObject()
falcon = ConfigurationAssessmentEvaluationLogic(auth_object=config)
AllowedResponses = [200, 201, 403, 404, 429]


class TestMobileEnrollment:
"""Class to test the Mobile Enrollment Service Class."""

def test_get_eval_logic(self):
"""Pytest harness hook"""
result = falcon.get_evaluation_logic(ids="12345678")
assert bool(result["status_code"] in AllowedResponses) is True

0 comments on commit 40eb234

Please sign in to comment.