Skip to content

Commit 5c7f81c

Browse files
committed
Add Cloud Security Compliance service collection
1 parent ae7a630 commit 5c7f81c

File tree

7 files changed

+328
-1
lines changed

7 files changed

+328
-1
lines changed

src/falconpy/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
from .cloud_azure_registration import CloudAzureRegistration
116116
from .cloud_oci_registration import CloudOCIRegistration
117117
from .cloud_security_assets import CloudSecurityAssets
118+
from .cloud_security_compliance import CloudSecurityCompliance
118119
from .cloud_snapshots import CloudSnapshots
119120
from .container_image_compliance import ContainerImageCompliance, ComplianceAssessments
120121
from .configuration_assessment_evaluation_logic import ConfigurationAssessmentEvaluationLogic
@@ -249,7 +250,8 @@
249250
"ContainerImageCompliance", "FaaSExecution", "HEC", "IngestBaseURL", "IngestFormat",
250251
"IngestPayload", "HTTPEventCollector", "IngestConfig", "SessionManager", "TimeUnit",
251252
"Color", "Indicator", "random_string", "KubernetesContainerCompliance", "find_operation",
252-
"InvalidRoute", "InvalidServiceCollection", "InvalidOperationSearch", "ITAutomation", "F4IT"
253+
"InvalidRoute", "InvalidServiceCollection", "InvalidOperationSearch", "ITAutomation", "F4IT",
254+
"CloudSecurityCompliance"
253255
]
254256
"""
255257
This is free and unencumbered software released into the public domain.

src/falconpy/_endpoint/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from .deprecated import _cloud_azure_registration_deprecated
2525
from .deprecated import _cloud_oci_registration_deprecated
2626
from .deprecated import _cloud_security_assets_deprecated
27+
from .deprecated import _cloud_security_compliance_deprecated
2728
from .deprecated import _correlation_rules_deprecated
2829
from .deprecated import _custom_ioa_deprecated
2930
from .deprecated import _d4c_registration_deprecated
@@ -56,6 +57,7 @@
5657
from ._cloud_azure_registration import _cloud_azure_registration_endpoints
5758
from ._cloud_oci_registration import _cloud_oci_registration_endpoints
5859
from ._cloud_security_assets import _cloud_security_assets_endpoints
60+
from ._cloud_security_compliance import _cloud_security_compliance_endpoints
5961
from ._cloud_connect_aws import _cloud_connect_aws_endpoints
6062
from ._cloud_snapshots import _cloud_snapshots_endpoints
6163
from ._container_image_compliance import _container_image_compliance_endpoints
@@ -152,6 +154,7 @@
152154
api_endpoints.extend(_cloud_azure_registration_endpoints)
153155
api_endpoints.extend(_cloud_oci_registration_endpoints)
154156
api_endpoints.extend(_cloud_security_assets_endpoints)
157+
api_endpoints.extend(_cloud_security_compliance_endpoints)
155158
api_endpoints.extend(_cloud_snapshots_endpoints)
156159
api_endpoints.extend(_container_image_compliance_endpoints)
157160
api_endpoints.extend(_configuration_assessment_evaluation_logic_endpoints)
@@ -242,6 +245,7 @@
242245
deprecated_endpoints.extend(_cloud_azure_registration_deprecated)
243246
deprecated_endpoints.extend(_cloud_oci_registration_deprecated)
244247
deprecated_endpoints.extend(_cloud_security_assets_deprecated)
248+
deprecated_endpoints.extend(_cloud_security_compliance_deprecated)
245249
deprecated_endpoints.extend(_correlation_rules_deprecated)
246250
deprecated_endpoints.extend(_certificate_based_exclusions_deprecated)
247251
deprecated_endpoints.extend(_custom_ioa_deprecated)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
"""Internal API endpoint constant library.
2+
3+
_______ __ _______ __ __ __
4+
| _ .----.-----.--.--.--.--| | _ | |_.----|__| |--.-----.
5+
|. 1___| _| _ | | | | _ | 1___| _| _| | <| -__|
6+
|. |___|__| |_____|________|_____|____ |____|__| |__|__|__|_____|
7+
|: 1 | |: 1 |
8+
|::.. . | CROWDSTRIKE FALCON |::.. . | FalconPy
9+
`-------' `-------'
10+
11+
OAuth2 API - Customer SDK
12+
13+
This is free and unencumbered software released into the public domain.
14+
15+
Anyone is free to copy, modify, publish, use, compile, sell, or
16+
distribute this software, either in source code form or as a compiled
17+
binary, for any purpose, commercial or non-commercial, and by any
18+
means.
19+
20+
In jurisdictions that recognize copyright laws, the author or authors
21+
of this software dedicate any and all copyright interest in the
22+
software to the public domain. We make this dedication for the benefit
23+
of the public at large and to the detriment of our heirs and
24+
successors. We intend this dedication to be an overt act of
25+
relinquishment in perpetuity of all present and future rights to this
26+
software under copyright law.
27+
28+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
31+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
32+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
33+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
34+
OTHER DEALINGS IN THE SOFTWARE.
35+
36+
For more information, please refer to <https://unlicense.org>
37+
"""
38+
39+
_cloud_security_compliance_endpoints = [
40+
[
41+
"cloud_compliance_framework_posture_summaries",
42+
"GET",
43+
"/cloud-security-compliance/entities/framework-posture-summaries/v1",
44+
"Get sections and requirements with scores for benchmarks.",
45+
"cloud_security_compliance",
46+
[
47+
{
48+
"maxItems": 20,
49+
"type": "array",
50+
"items": {
51+
"type": "string"
52+
},
53+
"collectionFormat": "csv",
54+
"description": "The uuids of compliance frameworks to retrieve (maximum 20 IDs allowed).",
55+
"name": "ids",
56+
"in": "query",
57+
"required": True
58+
}
59+
]
60+
],
61+
[
62+
"cloud_compliance_rule_posture_summaries",
63+
"GET",
64+
"/cloud-security-compliance/entities/rule-posture-summaries/v1",
65+
"Get compliance score and counts for rules.",
66+
"cloud_security_compliance",
67+
[
68+
{
69+
"maxItems": 300,
70+
"type": "array",
71+
"items": {
72+
"type": "string"
73+
},
74+
"collectionFormat": "csv",
75+
"description": "The uuids of compliance rules to retrieve (maximum 300 IDs allowed).",
76+
"name": "ids",
77+
"in": "query",
78+
"required": True
79+
}
80+
]
81+
]
82+
]

src/falconpy/_endpoint/deprecated/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from ._cloud_azure_registration import _cloud_azure_registration_endpoints
3636
from ._cloud_oci_registration import _cloud_oci_registration_endpoints
3737
from ._cloud_security_assets import _cloud_security_assets_endpoints
38+
from ._cloud_security_compliance import _cloud_security_compliance_endpoints
3839
from ._custom_ioa import _custom_ioa_endpoints
3940
from ._correlation_rules import _correlation_rules_endpoints
4041
from ._d4c_registration import _d4c_registration_endpoints
@@ -62,6 +63,7 @@
6263
_cloud_azure_registration_deprecated = _cloud_azure_registration_endpoints
6364
_cloud_oci_registration_deprecated = _cloud_oci_registration_endpoints
6465
_cloud_security_assets_deprecated = _cloud_security_assets_endpoints
66+
_cloud_security_compliance_deprecated = _cloud_security_compliance_endpoints
6567
_correlation_rules_deprecated = _correlation_rules_endpoints
6668
_custom_ioa_deprecated = _custom_ioa_endpoints
6769
_d4c_registration_deprecated = _d4c_registration_endpoints
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
"""Internal API endpoint constant library (deprecated operations).
2+
3+
_______ __ _______ __ __ __
4+
| _ .----.-----.--.--.--.--| | _ | |_.----|__| |--.-----.
5+
|. 1___| _| _ | | | | _ | 1___| _| _| | <| -__|
6+
|. |___|__| |_____|________|_____|____ |____|__| |__|__|__|_____|
7+
|: 1 | |: 1 |
8+
|::.. . | CROWDSTRIKE FALCON |::.. . | FalconPy
9+
`-------' `-------'
10+
11+
OAuth2 API - Customer SDK
12+
13+
This is free and unencumbered software released into the public domain.
14+
15+
Anyone is free to copy, modify, publish, use, compile, sell, or
16+
distribute this software, either in source code form or as a compiled
17+
binary, for any purpose, commercial or non-commercial, and by any
18+
means.
19+
20+
In jurisdictions that recognize copyright laws, the author or authors
21+
of this software dedicate any and all copyright interest in the
22+
software to the public domain. We make this dedication for the benefit
23+
of the public at large and to the detriment of our heirs and
24+
successors. We intend this dedication to be an overt act of
25+
relinquishment in perpetuity of all present and future rights to this
26+
software under copyright law.
27+
28+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
31+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
32+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
33+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
34+
OTHER DEALINGS IN THE SOFTWARE.
35+
36+
For more information, please refer to <https://unlicense.org>
37+
"""
38+
39+
_cloud_security_compliance_endpoints = [
40+
[
41+
"cloud-compliance-framework-posture-summaries",
42+
"GET",
43+
"/cloud-security-compliance/entities/framework-posture-summaries/v1",
44+
"Get sections and requirements with scores for benchmarks.",
45+
"cloud_security_compliance",
46+
[
47+
{
48+
"maxItems": 20,
49+
"type": "array",
50+
"items": {
51+
"type": "string"
52+
},
53+
"collectionFormat": "csv",
54+
"description": "The uuids of compliance frameworks to retrieve (maximum 20 IDs allowed).",
55+
"name": "ids",
56+
"in": "query",
57+
"required": True
58+
}
59+
]
60+
],
61+
[
62+
"cloud-compliance-rule-posture-summaries",
63+
"GET",
64+
"/cloud-security-compliance/entities/rule-posture-summaries/v1",
65+
"Get compliance score and counts for rules.",
66+
"cloud_security_compliance",
67+
[
68+
{
69+
"maxItems": 300,
70+
"type": "array",
71+
"items": {
72+
"type": "string"
73+
},
74+
"collectionFormat": "csv",
75+
"description": "The uuids of compliance rules to retrieve (maximum 300 IDs allowed).",
76+
"name": "ids",
77+
"in": "query",
78+
"required": True
79+
}
80+
]
81+
]
82+
]
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
"""CrowdStrike Falcon CloudSecurityCompliance API interface class.
2+
3+
_______ __ _______ __ __ __
4+
| _ .----.-----.--.--.--.--| | _ | |_.----|__| |--.-----.
5+
|. 1___| _| _ | | | | _ | 1___| _| _| | <| -__|
6+
|. |___|__| |_____|________|_____|____ |____|__| |__|__|__|_____|
7+
|: 1 | |: 1 |
8+
|::.. . | CROWDSTRIKE FALCON |::.. . | FalconPy
9+
`-------' `-------'
10+
11+
OAuth2 API - Customer SDK
12+
13+
This is free and unencumbered software released into the public domain.
14+
15+
Anyone is free to copy, modify, publish, use, compile, sell, or
16+
distribute this software, either in source code form or as a compiled
17+
binary, for any purpose, commercial or non-commercial, and by any
18+
means.
19+
20+
In jurisdictions that recognize copyright laws, the author or authors
21+
of this software dedicate any and all copyright interest in the
22+
software to the public domain. We make this dedication for the benefit
23+
of the public at large and to the detriment of our heirs and
24+
successors. We intend this dedication to be an overt act of
25+
relinquishment in perpetuity of all present and future rights to this
26+
software under copyright law.
27+
28+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
31+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
32+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
33+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
34+
OTHER DEALINGS IN THE SOFTWARE.
35+
36+
For more information, please refer to <https://unlicense.org>
37+
"""
38+
from typing import Dict, Union
39+
from ._util import force_default, process_service_request, handle_single_argument
40+
from ._result import Result
41+
from ._service_class import ServiceClass
42+
from ._endpoint._cloud_security_compliance import _cloud_security_compliance_endpoints as Endpoints
43+
44+
45+
class CloudSecurityCompliance(ServiceClass):
46+
"""The only requirement to instantiate an instance of this class is one of the following.
47+
48+
- a valid client_id and client_secret provided as keywords.
49+
- a credential dictionary with client_id and client_secret containing valid API credentials
50+
{
51+
"client_id": "CLIENT_ID_HERE",
52+
"client_secret": "CLIENT_SECRET_HERE"
53+
}
54+
- a previously-authenticated instance of the authentication service class (oauth2.py)
55+
- a valid token provided by the authentication service class (oauth2.py)
56+
"""
57+
58+
@force_default(defaults=["parameters"], default_types=["dict"])
59+
def framework_posture_summaries(self: object,
60+
*args,
61+
parameters: dict = None,
62+
**kwargs
63+
) -> Union[Dict[str, Union[int, dict]], Result]:
64+
"""Get sections and requirements with scores for benchmarks.
65+
66+
Keyword arguments:
67+
ids -- The UUIDs of compliance frameworks to retrieve (maximum 20 IDs allowed). String or list of strings.
68+
parameters -- Full parameters payload dictionary. Not required if using other keywords.
69+
70+
Arguments: When not specified, the first argument to this method is assumed to be 'ids'.
71+
All others are ignored.
72+
73+
Returns: dict object containing API response.
74+
75+
HTTP Method: GET
76+
77+
Swagger URL
78+
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
79+
/cloud-security-compliance/cloud-compliance-framework-posture-summaries
80+
"""
81+
return process_service_request(
82+
calling_object=self,
83+
endpoints=Endpoints,
84+
operation_id="cloud_compliance_framework_posture_summaries",
85+
keywords=kwargs,
86+
params=handle_single_argument(args, parameters, "ids")
87+
)
88+
89+
@force_default(defaults=["parameters"], default_types=["dict"])
90+
def rule_posture_summaries(self: object,
91+
*args,
92+
parameters: dict = None,
93+
**kwargs
94+
) -> Union[Dict[str, Union[int, dict]], Result]:
95+
"""Get compliance score and counts for rules.
96+
97+
Keyword arguments:
98+
ids -- The uuids of compliance rules to retrieve (maximum 300 IDs allowed).
99+
parameters -- Full parameters payload dictionary. Not required if using other keywords.
100+
101+
Arguments: When not specified, the first argument to this method is assumed to be 'ids'.
102+
All others are ignored.
103+
104+
Returns: dict object containing API response.
105+
106+
HTTP Method: GET
107+
108+
Swagger URL
109+
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
110+
/cloud-security-compliance/cloud-compliance-rule-posture-summaries
111+
"""
112+
return process_service_request(
113+
calling_object=self,
114+
endpoints=Endpoints,
115+
operation_id="cloud_compliance_rule_posture_summaries",
116+
keywords=kwargs,
117+
params=handle_single_argument(args, parameters, "ids")
118+
)
119+
120+
cloud_compliance_framework_posture_summaries = framework_posture_summaries
121+
cloud_compliance_rule_posture_summaries = rule_posture_summaries
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# test_cloud_security_compliance.py
2+
# This class tests the cloud_security_compliance service class
3+
4+
# import json
5+
import os
6+
import sys
7+
8+
# Authentication via the test_authorization.py
9+
from tests import test_authorization as Authorization
10+
11+
# Import our sibling src folder into the path
12+
sys.path.append(os.path.abspath('src'))
13+
# Classes to test - manually imported from sibling folder
14+
from falconpy import CloudSecurityCompliance
15+
16+
auth = Authorization.TestAuthorization()
17+
config = auth.getConfigObject()
18+
falcon = CloudSecurityCompliance(auth_object=config)
19+
AllowedResponses = [200, 201, 207, 400, 403, 404, 429]
20+
21+
22+
class TestCloudSecurityCompliance:
23+
def test_all_code_paths(self):
24+
error_checks = True
25+
tests = {
26+
"cloud_compliance_framework_posture_summaries": falcon.framework_posture_summaries("1ab2c345-67d8-90e1-2345-6789f0a12bc3"),
27+
"cloud_compliance_rule_posture_summaries": falcon.rule_posture_summaries(ids="1ab2c345-67d8-90e1-2345-6789f0a12bc3"),
28+
}
29+
for key in tests:
30+
if tests[key]["status_code"] not in AllowedResponses:
31+
error_checks = False
32+
# print(key)
33+
# print(tests[key])
34+
assert error_checks

0 commit comments

Comments
 (0)