-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ConfigurationAssessmentEvaluationLogic service collection
- Loading branch information
Showing
5 changed files
with
179 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/falconpy/_endpoint/_configuration_assessment_evaluation_logic.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
] | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |