-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathdevice_control_policies.py
More file actions
1021 lines (885 loc) · 45.6 KB
/
device_control_policies.py
File metadata and controls
1021 lines (885 loc) · 45.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""CrowdStrike Falcon Device Control Policies 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>
"""
# pylint: disable=C0302
from typing import Dict, Union
from ._util import generate_error_result, force_default, args_to_params
from ._util import process_service_request, handle_single_argument
from ._payload import (
generic_payload_list,
device_policy_payload,
default_device_policy_config_payload,
device_classes_policy_payload,
device_policy_bluetooth_config_payload,
device_control_policy_payload_v2
)
from ._result import Result
from ._service_class import ServiceClass
from ._endpoint._device_control_policies import _device_control_policies_endpoints as Endpoints
class DeviceControlPolicies(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.token())
"""
@force_default(defaults=["parameters"], default_types=["dict"])
def query_combined_policy_members(self: object,
parameters: dict = None,
**kwargs
) -> Union[Dict[str, Union[int, dict]], Result]:
"""Search for a Device Control Policy members and return full detail.
Search for members of a Device Control Policy in your environment by
providing an FQL filter and paging details. Returns a set of host details
which match the filter criteria.
Keyword arguments:
id -- The ID of the Device Control Policy to search for members of
filter -- The filter expression that should be used to limit the results. FQL syntax.
limit -- The maximum number of records to return in this response. [Integer, 1-5000]
Use with the offset parameter to manage pagination of results.
offset -- The offset to start retrieving records from. Integer.
Use with the limit parameter to manage pagination of results.
parameters - full parameters payload, not required if using other keywords.
sort -- The property to sort by. FQL syntax.
This method only supports keywords for providing arguments.
Returns: dict object containing API response.
HTTP Method: GET
Swagger URL
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
/device-control-policies/queryCombinedDeviceControlPolicyMembers
"""
return process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id="queryCombinedDeviceControlPolicyMembers",
keywords=kwargs,
params=parameters
)
@force_default(defaults=["parameters"], default_types=["dict"])
def query_combined_policies(self: object,
parameters: dict = None,
**kwargs
) -> Union[Dict[str, Union[int, dict]], Result]:
"""Search for a Device Control Policies and return full detail.
Search for Device Control Policies in your environment by providing an FQL filter and
paging details. Returns a set of Device Control Policies which match the filter criteria.
Keyword arguments:
filter -- The filter expression that should be used to limit the results. FQL syntax.
limit -- The maximum number of records to return in this response. [Integer, 1-5000]
Use with the offset parameter to manage pagination of results.
offset -- The offset to start retrieving records from. Integer.
Use with the limit parameter to manage pagination of results.
parameters - full parameters payload, not required if using other keywords.
sort -- The property to sort by. FQL syntax.
created_by modified_timestamp
created_timestamp name
enabled platform_name
modified_by precedence
This method only supports keywords for providing arguments.
Returns: dict object containing API response.
HTTP Method: GET
Swagger URL
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
/device-control-policies/queryCombinedDeviceControlPolicies
"""
return process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id="queryCombinedDeviceControlPolicies",
keywords=kwargs,
params=parameters
)
def get_default_policies(self: object) -> dict:
"""Retrieve the configuration for a Default Device Control Policy.
Keyword arguments:
This method does not accept keyword arguments.
Arguments: This method does not accept arguments.
Returns: dict object containing API response.
HTTP Method: GET
Swagger URL
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
/device-control-policies/getDefaultDeviceControlPolicies
"""
return process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id="getDefaultDeviceControlPolicies"
)
@force_default(defaults=["body"], default_types=["dict"])
def update_default_policies(self: object, body: dict = None, **kwargs) -> dict:
"""Update Device Control Policies by specifying the ID of the policy and details to update.
Keyword arguments:
blocked_notification -- dictionary containing the custom message and enablement status
for the blocked notification. Dictionary.
{
"custom_message": "string",
"use_custom": true
}
blocked_custom_message -- Message to use for blocked notifications. Using this keyword will
automatically generate the necessary blocked_notification dictionary.
String.
body -- full body payload, not required if using other keywords.
{
"custom_notifications": {
"blocked_notification": {
"custom_message": "string",
"use_custom": true
},
"restricted_notification": {
"custom_message": "string",
"use_custom": true
}
}
}
restricted_custom_message -- message to use for restricted notifications. Using this keyword will
automatically generate the necessary restricted_notification dictionary.
String.
restricted_notification -- dictionary containing the custom message and enablement status
for the restricted notification. Dictionary.
{
"custom_message": "string",
"use_custom": true
}
This method only supports keywords for providing arguments.
Returns: dict object containing API response.
HTTP Method: PATCH
Swagger URL
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
/device-control-policies/updateDefaultDeviceControlPolicies
"""
if not body:
body = default_device_policy_config_payload(passed_keywords=kwargs)
return process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id="updateDefaultDeviceControlPolicies",
body=body
)
@force_default(defaults=["parameters", "body"], default_types=["dict", "dict"])
def perform_action(self: object,
body: dict = None,
parameters: dict = None,
**kwargs
) -> Union[Dict[str, Union[int, dict]], Result]:
"""Perform a Device Control Policy action.
Keyword arguments:
action_name -- action to perform: 'add-host-group', 'add-rule-group', 'disable', 'enable',
'remove-rule-group' or 'remove-host-group'.
action_parameters -- Action specific parameter options. List of dictionaries.
{
"name": "string",
"value": "string"
}
body -- full body payload, not required if keywords are used.
{
"action_parameters": [
{
"name": "group_id",
"value": "string"
}
],
"ids": [
"string"
]
}
group_id -- Host Group ID to apply the policy to. String.
Overridden if action_parameters is specified.
ids -- Device Control policy ID(s) to perform actions against. String or list of strings.
parameters - full parameters payload, not required if action_name is provided as a keyword.
This method only supports keywords for providing arguments.
Returns: dict object containing API response.
HTTP Method: POST
Swagger URL
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
/device-control-policies/performDeviceControlPoliciesAction
"""
_allowed_actions = ['add-host-group', 'disable', 'enable', 'remove-host-group']
operation_id = "performDeviceControlPoliciesAction"
parameter_payload = args_to_params(parameters, kwargs, Endpoints, operation_id)
action_name = parameter_payload.get("action_name", "Not Specified")
if action_name.lower() in _allowed_actions:
if not body:
body = generic_payload_list(submitted_keywords=kwargs, payload_value="ids")
if kwargs.get("group_id", None):
body["action_parameters"] = [{
"name": "group_id",
"value": kwargs.get("group_id", None)
}]
# Passing an action_parameters list will override the group_id keyword
if kwargs.get("action_parameters", None):
body["action_parameters"] = kwargs.get("action_parameters", None)
returned = process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id=operation_id,
body=body,
keywords=kwargs,
params=parameters
)
else:
returned = generate_error_result("Invalid value specified for action_name parameter.")
return returned
@force_default(defaults=["body"], default_types=["dict"])
def update_policy_classes(self: object, body: dict = None, **kwargs) -> Union[Dict[str, Union[int, dict]], Result]:
"""Update device control policy's classes (USB and Bluetooth).
Keyword arguments:
body -- full body payload, not required if keywords are used.
{
"policies": [
{
"bluetooth_classes": {
"classes": [
{
"action": "string",
"class": "string",
"minor_classes": [
{
"action": "string",
"minor_class": "string"
}
]
}
],
"delete_exceptions": [
"string"
],
"upsert_exceptions": [
{
"action": "string",
"class": "string",
"description": "string",
"expiration_time": "UTC date string",
"id": "string",
"minor_classes": [
"string"
],
"product_id": "string",
"product_name": "string",
"vendor_id": "string",
"vendor_id_source": "string",
"vendor_name": "string"
}
]
},
"id": "string",
"usb_classes": {
"classes": [
{
"action": "string",
"class": "string"
}
],
"delete_exceptions": [
"string"
],
"upsert_exceptions": [
{
"action": "string",
"class": "string",
"combined_id": "string",
"description": "string",
"expiration_time": "UTC date string",
"id": "string",
"product_id": "string",
"product_name": "string",
"serial_number": "string",
"use_wildcard": boolean,
"vendor_id": "string",
"vendor_name": "string"
}
]
}
}
]
}
bluetooth_classes -- Bluetooth device control policy. Dictionary.
id -- Device control policy ID. String.
usb_classes -- USB device control policy. Dictionary.
This method only supports keywords for providing arguments.
Returns: dict object containing API response.
HTTP Method: PATCH
Swagger URL
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
/device-control-with-bluetooth/patchDeviceControlPoliciesClassesV1
"""
if not body:
body = device_classes_policy_payload(kwargs)
return process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id="patchDeviceControlPoliciesClassesV1",
body=body
)
def get_default_settings(self: object) -> Union[Dict[str, Union[int, dict]], Result]:
"""Get default device control settings (USB and Bluetooth).
Keyword arguments:
This method does not accept keyword arguments.
Arguments:
This method does not accept arguments.
Returns: dict object containing API response.
HTTP Method: GET
Swagger URL
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
/device-control-with-bluetooth/getDefaultDeviceControlSettings
"""
return process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id="getDefaultDeviceControlSettings"
)
@force_default(defaults=["body"], default_types=["dict"])
def update_default_settings(self: object, body: dict = None, **kwargs) -> Union[Dict[str, Union[int, dict]], Result]:
"""Update the configuration for Default Device Control Settings.
Keyword arguments:
body -- full body payload, not required if keywords are used.
{
"bluetooth_custom_notifications": {
"blocked_notification": {
"custom_message": "string",
"use_custom": boolean
}
},
"usb_custom_notifications": {
"blocked_notification": {
"custom_message": "string",
"use_custom": boolean
},
"restricted_notification": {
"custom_message": "string",
"use_custom": boolean
}
},
"usb_exceptions": [
{
"delete_exceptions": [
"string"
],
"platform_name": "string",
"upsert_exceptions": [
{
"action": "string",
"class": "string",
"combined_id": "string",
"description": "string",
"id": "string",
"product_id": "string",
"product_name": "string",
"serial_number": "string",
"vendor_id": "string",
"vendor_name": "string"
}
]
}
]
}
bluetooth_custom_notifications -- Custom bluetooth notifications. Dictionary.
usb_custom_notifications -- Custom USB notifications. Dictionary.
usb_exceptions -- USB exceptions. Dictionary or list of dictionaries.
This method only supports keywords for providing arguments.
Returns: dict object containing API response.
HTTP Method: PATCH
Swagger URL
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
/device-control-with-bluetooth/patchDeviceControlPoliciesClassesV1
"""
if not body:
body = device_policy_bluetooth_config_payload(kwargs)
return process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id="updateDefaultDeviceControlSettings",
body=body
)
@force_default(defaults=["body"], default_types=["dict"])
def set_precedence(self: object, body: dict = None, **kwargs) -> Union[Dict[str, Union[int, dict]], Result]:
"""Set Device Control Policy precedence.
Sets the precedence of Device Control Policies based on the order of IDs specified in
the request. The first ID specified will have the highest precedence and the last ID
specified will have the lowest. You must specify all non-Default Policies for a platform
when updating precedence.
Keyword arguments:
body -- full body payload, not required if keywords are used.
{
"ids": [
"string"
],
"platform_name": "Windows"
}
ids -- Device Control policy ID(s) to perform actions against. String or list of strings.
platform_name -- OS platform name.
This method only supports keywords for providing arguments.
Returns: dict object containing API response.
HTTP Method: POST
Swagger URL
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
/device-control-policies/performDeviceControlPoliciesAction
"""
if not body:
body = generic_payload_list(submitted_keywords=kwargs, payload_value="ids")
if kwargs.get("platform_name", None):
body["platform_name"] = kwargs.get("platform_name", None)
return process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id="setDeviceControlPoliciesPrecedence",
body=body
)
@force_default(defaults=["parameters"], default_types=["dict"])
def get_policies(self: object, *args, parameters: dict = None, **kwargs) -> Union[Dict[str, Union[int, dict]], Result]:
"""Retrieve a set of Device Control Policies by specifying their IDs.
Keyword arguments:
ids -- List of Device Control Policy IDs to retrieve. String or list of strings.
parameters -- full parameters payload, not required if ids is provided as a keyword.
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
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
/device-control-policies/getDeviceControlPolicies
"""
return process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id="getDeviceControlPolicies",
keywords=kwargs,
params=handle_single_argument(args, parameters, "ids")
)
@force_default(defaults=["body"], default_types=["dict"])
def create_policies(self: object, body: dict = None, **kwargs) -> Union[Dict[str, Union[int, dict]], Result]:
"""Create Device Control Policies by specifying details about the policy to create.
Keyword arguments:
body -- full body payload, not required if keywords are used.
{
"resources": [
{
"clone_id": "string",
"description": "string",
"name": "string",
"platform_name": "Windows",
"settings": {
"classes": [
{
"action": "FULL_ACCESS",
"exceptions": [
{
"action": "string",
"combined_id": "string",
"description": "string",
"expiration_time": "2023-06-08T06:04:53.563Z",
"id": "string",
"product_id": "string",
"product_id_decimal": "string",
"product_name": "string",
"serial_number": "string",
"use_wildcard": true,
"vendor_id": "string",
"vendor_id_decimal": "string",
"vendor_name": "string"
}
],
"id": "string"
}
],
"custom_notifications": {
"blocked_notification": {
"custom_message": "string",
"use_custom": true
},
"restricted_notification": {
"custom_message": "string",
"use_custom": true
}
},
"delete_exceptions": [
"string"
],
"end_user_notification": "SILENT",
"enforcement_mode": "MONITOR_ONLY",
"enhanced_file_metadata": true
}
}
]
}
clone_id -- ID of the Device Control Policy to clone. String.
description -- Device Control Policy description. String.
name -- Device Control Policy name. String.
platform_name -- Name of the operating system platform. String.
settings -- Device Control policy specific settings. Dictionary.
See above for JSON dictionary format example.
This method only supports keywords for providing arguments.
Returns: dict object containing API response.
HTTP Method: POST
Swagger URL
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
/device-control-policies/createDeviceControlPolicies
"""
if not body:
body = device_policy_payload(passed_keywords=kwargs)
return process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id="createDeviceControlPolicies",
body=body
)
@force_default(defaults=["parameters"], default_types=["dict"])
def delete_policies(self: object, *args, parameters: dict = None, **kwargs) -> Union[Dict[str, Union[int, dict]], Result]:
"""Delete a set of Device Control Policies by specifying their IDs.
Keyword arguments:
ids -- List of Device Control Policy IDs to delete. String or list of strings.
parameters -- full parameters payload, not required if ids is provided as a keyword.
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: DELETE
Swagger URL
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
/device-control-policies/createDeviceControlPolicies
"""
return process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id="deleteDeviceControlPolicies",
keywords=kwargs,
params=handle_single_argument(args, parameters, "ids")
)
@force_default(defaults=["parameters"], default_types=["dict"])
def get_policies_v2(self: object, *args, parameters: dict = None, **kwargs) -> Union[Dict[str, Union[int, dict]], Result]:
"""Get device control policies for the given filter criteria. Supports USB and Bluetooth.
Keyword arguments:
ids -- List of Device Control Policy IDs to retrieve. String or list of strings.
parameters -- full parameters payload, not required if ids is provided as a keyword.
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
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
/device-control-with-bluetooth/getDeviceControlPoliciesV2
"""
return process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id="getDeviceControlPoliciesV2",
keywords=kwargs,
params=handle_single_argument(args, parameters, "ids")
)
@force_default(defaults=["body"], default_types=["dict"])
def create_policies_v2(self: object, body: dict = None, **kwargs) -> Union[Dict[str, Union[int, dict]], Result]:
"""Create Device Control Policies by specifying details about the policy to create.
Keyword arguments:
body -- full body payload, not required if keywords are used.
{
"policies": [
{
"bluetooth_settings": {
"custom_end_user_notifications": {
"blocked_notification": {
"custom_message": "string",
"use_custom": boolean
}
},
"end_user_notification": "string",
"enforcement_mode": "string"
},
"clone_id": "string",
"description": "string",
"name": "string",
"platform_name": "string",
"usb_settings": {
"custom_notifications": {
"blocked_notification": {
"custom_message": "string",
"use_custom": boolean
},
"restricted_notification": {
"custom_message": "string",
"use_custom": boolean
}
},
"end_user_notification": "string",
"enforcement_mode": "string",
"enhanced_file_metadata": boolean,
"whitelist_mode": "string"
}
}
]
}
bluetooth_settings -- Device Control policy USB specific settings. Dictionary.
See above for JSON dictionary format example.
clone_id -- ID of the Device Control Policy to clone. String.
description -- Device Control Policy description. String.
name -- Device Control Policy name. String.
platform_name -- Name of the operating system platform. String.
usb_settings -- Device Control policy USB specific settings. Dictionary.
See above for JSON dictionary format example.
This method only supports keywords for providing arguments.
Returns: dict object containing API response.
HTTP Method: POST
Swagger URL
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
/device-control-policies/createDeviceControlPolicies
"""
if not body:
body = device_control_policy_payload_v2(passed_keywords=kwargs)
return process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id="postDeviceControlPoliciesV2",
body=body
)
@force_default(defaults=["body"], default_types=["dict"])
def update_policies_v2(self: object, body: dict = None, **kwargs) -> Union[Dict[str, Union[int, dict]], Result]:
"""Create Device Control Policies by specifying details about the policy to create.
Keyword arguments:
body -- full body payload, not required if keywords are used.
{
"policies": [
{
"bluetooth_settings": {
"custom_end_user_notifications": {
"blocked_notification": {
"custom_message": "string",
"use_custom": boolean
}
},
"end_user_notification": "string",
"enforcement_mode": "string"
},
"description": "string",
"id": "string",
"name": "string",
"platform_name": "string",
"usb_settings": {
"custom_notifications": {
"blocked_notification": {
"custom_message": "string",
"use_custom": boolean
},
"restricted_notification": {
"custom_message": "string",
"use_custom": boolean
}
},
"end_user_notification": "string",
"enforcement_mode": "string",
"enhanced_file_metadata": boolean,
"whitelist_mode": "string"
}
}
]
}
bluetooth_settings -- Device Control policy USB specific settings. Dictionary.
See above for JSON dictionary format example.
description -- Device Control Policy description. String.
id -- ID of the Device Control Policy to update. String.
name -- Device Control Policy name. String.
platform_name -- Name of the operating system platform. String.
usb_settings -- Device Control policy USB specific settings. Dictionary.
See above for JSON dictionary format example.
This method only supports keywords for providing arguments.
Returns: dict object containing API response.
HTTP Method: PATCH
Swagger URL
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
/device-control-with-bluetooth/patchDeviceControlPoliciesV2
"""
if not body:
body = device_control_policy_payload_v2(passed_keywords=kwargs)
return process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id="patchDeviceControlPoliciesV2",
body=body
)
@force_default(defaults=["body"], default_types=["dict"])
def update_policies(self: object, body: dict = None, **kwargs) -> Union[Dict[str, Union[int, dict]], Result]:
"""Update Device Control Policies by specifying the ID of the policy and details to update.
Keyword arguments:
body -- full body payload, not required if keywords are used.
{
"resources": [
{
"description": "string",
"id": "string",
"name": "string",
"settings": {
"classes": [
{
"action": "FULL_ACCESS",
"exceptions": [
{
"action": "string",
"combined_id": "string",
"description": "string",
"expiration_time": "2023-06-08T06:10:39.965Z",
"id": "string",
"product_id": "string",
"product_id_decimal": "string",
"product_name": "string",
"serial_number": "string",
"use_wildcard": true,
"vendor_id": "string",
"vendor_id_decimal": "string",
"vendor_name": "string"
}
],
"id": "string"
}
],
"custom_notifications": {
"blocked_notification": {
"custom_message": "string",
"use_custom": true
},
"restricted_notification": {
"custom_message": "string",
"use_custom": true
}
},
"delete_exceptions": [
"string"
],
"end_user_notification": "SILENT",
"enforcement_mode": "MONITOR_ONLY",
"enhanced_file_metadata": true
}
}
]
}
id -- ID of the Device Control Policy to update. String.
description -- Device Control Policy description. String.
name -- Device Control Policy name. String.
settings -- Device Control policy specific settings. Dictionary.
See above for JSON dictionary format example.
This method only supports keywords for providing arguments.
Returns: dict object containing API response.
HTTP Method: PATCH
Swagger URL
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
/device-control-policies/updateDeviceControlPolicies
"""
if not body:
body = device_policy_payload(passed_keywords=kwargs)
return process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id="updateDeviceControlPolicies",
body=body
)
@force_default(defaults=["parameters"], default_types=["dict"])
def query_policy_members(self: object, parameters: dict = None, **kwargs) -> Union[Dict[str, Union[int, dict]], Result]:
"""Search for a Device Control Policy members and return their IDs.
Search for members of a Device Control Policy in your environment by providing
an FQL filter and paging details. Returns a set of Agent IDs which match the filter
criteria.
Keyword arguments:
id -- The ID of the Device Control Policy to search for members of
filter -- The filter expression that should be used to limit the results. FQL syntax.
limit -- The maximum number of records to return in this response. [Integer, 1-5000]
Use with the offset parameter to manage pagination of results.
offset -- The offset to start retrieving records from. Integer.
Use with the limit parameter to manage pagination of results.
parameters - full parameters payload, not required if using other keywords.
sort -- The property to sort by. FQL syntax.
This method only supports keywords for providing arguments.
Returns: dict object containing API response.
HTTP Method: GET
Swagger URL
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
/device-control-policies/queryDeviceControlPolicyMembers
"""
return process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id="queryDeviceControlPolicyMembers",
keywords=kwargs,
params=parameters
)
@force_default(defaults=["parameters"], default_types=["dict"])
def query_policies(self: object, parameters: dict = None, **kwargs) -> Union[Dict[str, Union[int, dict]], Result]:
"""Search for a Device Control Policies and return their IDs.
Search for Device Control Policies in your environment by providing an
FQL filter and paging details. Returns a set of Device Control Policy IDs
which match the filter criteria.
Keyword arguments:
filter -- The filter expression that should be used to limit the results. FQL syntax.
limit -- The maximum number of records to return in this response. [Integer, 1-5000]
Use with the offset parameter to manage pagination of results.
offset -- The offset to start retrieving records from. Integer.
Use with the limit parameter to manage pagination of results.
parameters - full parameters payload, not required if using other keywords.
sort -- The property to sort by. FQL syntax.
created_by modified_timestamp
created_timestamp name
enabled platform_name
modified_by precedence
This method only supports keywords for providing arguments.
Returns: dict object containing API response.
HTTP Method: GET
Swagger URL
https://assets.falcon.crowdstrike.com/support/api/swagger.html#
/device-control-policies/queryDeviceControlPolicyMembers
"""
return process_service_request(
calling_object=self,
endpoints=Endpoints,
operation_id="queryDeviceControlPolicies",
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
queryCombinedDeviceControlPolicyMembers = query_combined_policy_members
queryCombinedDeviceControlPolicies = query_combined_policies