laceworksdk.api.v2.vulnerability_policies
Lacework VulnerabilityPolicies API wrapper.
1# -*- coding: utf-8 -*- 2""" 3Lacework VulnerabilityPolicies API wrapper. 4""" 5 6from laceworksdk.api.crud_endpoint import CrudEndpoint 7 8 9class VulnerabilityPoliciesAPI(CrudEndpoint): 10 11 def __init__(self, session): 12 """ 13 Initializes the VulnerabilityPoliciesAPI object. 14 15 :param session: An instance of the HttpSession class 16 17 :return VulnerabilityPoliciesAPI object. 18 """ 19 20 super().__init__(session, "VulnerabilityPolicies") 21 22 def create(self, 23 policy_type, 24 policy_name, 25 severity, 26 state, 27 filter, 28 props, 29 policy_eval_type=None, 30 fail_on_violation=False, 31 alert_on_violation=False, 32 **request_params): 33 """ 34 A method to create a new VulnerabilityPolicies object. 35 36 :param policy_type: A string representing the type of the policy. 37 :param policy_name: A string representing the name of the policy. 38 :param severity: A string representing the severity of the policy. 39 ("Info", "Low", "Medium", "High", "Critical") 40 :param state: A boolean representing the state of the policy. 41 :param filter: 42 obj: 43 :param rule: An object representing a policy filter rule. 44 obj: 45 :param operator: A string representing the rule operator. 46 ("include", "exclude", "equals", "notEquals") 47 :param values: An array of strings representing the rule values. 48 :param exception: An object representing a policy filter exception. 49 obj: 50 :param operator: A string representing the rule operator. 51 ("include", "exclude", "equals", "notEquals") 52 :param values: An array of strings representing the exception values. 53 :param props: An object containing properties of the policy. 54 obj: 55 :param description: A string representing the property description. 56 :param createdBy: A string representing the creator of the property. 57 :param updatedBy: A string representing the updater of the property. 58 :param policy_eval_type: A string representing the policy evaluation type. 59 :param fail_on_violation: A boolean representing whether the policy should fail on violations. 60 :param alert_on_violation: A boolean representing whether the policy should alert on violations. 61 :param request_params: Additional request parameters. 62 (provides support for parameters that may be added in the future) 63 64 :return response json 65 """ 66 67 return super().create( 68 policy_type=policy_type, 69 policy_name=policy_name, 70 severity=severity, 71 state=int(bool(state)), 72 filter=filter, 73 props=props, 74 policy_eval_type=policy_eval_type, 75 fail_on_violation=int(bool(fail_on_violation)), 76 alert_on_violation=int(bool(alert_on_violation)), 77 **request_params 78 ) 79 80 def get(self, 81 guid=None): 82 """ 83 A method to get VulnerabilityPolicies objects. 84 85 :param guid: A string representing the object GUID. 86 87 :return response json 88 """ 89 90 return super().get(id=guid) 91 92 def get_by_guid(self, 93 guid): 94 """ 95 A method to get a VulnerabilityPolicies object by GUID. 96 97 :param guid: A string representing the object GUID. 98 99 :return response json 100 """ 101 102 return self.get(guid=guid) 103 104 def update(self, 105 guid, 106 policy_type=None, 107 policy_name=None, 108 severity=None, 109 state=None, 110 filter=None, 111 props=None, 112 policy_eval_type=None, 113 fail_on_violation=None, 114 alert_on_violation=None, 115 **request_params): 116 """ 117 A method to update a VulnerabilityPolicies object. 118 119 :param guid: A string representing the object GUID. 120 :param policy_type: A string representing the type of the policy. 121 :param policy_name: A string representing the name of the policy. 122 :param severity: A string representing the severity of the policy. 123 ("Info", "Low", "Medium", "High", "Critical") 124 :param state: A boolean representing the state of the policy. 125 :param filter: 126 obj: 127 :param rule: An object representing a policy filter rule. 128 obj: 129 :param operator: A string representing the rule operator. 130 ("include", "exclude", "equals", "notEquals") 131 :param values: An array of strings representing the rule values. 132 :param exception: An object representing a policy filter exception. 133 obj: 134 :param operator: A string representing the rule operator. 135 ("include", "exclude", "equals", "notEquals") 136 :param values: An array of strings representing the exception values. 137 :param props: An object containing properties of the policy. 138 obj: 139 :param description: A string representing the property description. 140 :param createdBy: A string representing the creator of the property. 141 :param updatedBy: A string representing the updater of the property. 142 :param policy_eval_type: A string representing the policy evaluation type. 143 :param fail_on_violation: A boolean representing whether the policy should fail on violations. 144 :param alert_on_violation: A boolean representing whether the policy should alert on violations. 145 :param request_params: Additional request parameters. 146 (provides support for parameters that may be added in the future) 147 148 :return response json 149 """ 150 151 if state is not None: 152 state = int(bool(state)) 153 if fail_on_violation is not None: 154 fail_on_violation = int(bool(fail_on_violation)) 155 if alert_on_violation is not None: 156 alert_on_violation = int(bool(alert_on_violation)) 157 158 return super().update( 159 guid, 160 policy_type=policy_type, 161 policy_name=policy_name, 162 severity=severity, 163 state=state, 164 filter=filter, 165 props=props, 166 policy_eval_type=policy_eval_type, 167 fail_on_violation=fail_on_violation, 168 alert_on_violation=alert_on_violation, 169 **request_params 170 ) 171 172 def delete(self, 173 guid): 174 """ 175 A method to delete a VulnerabilityPolicies object. 176 177 :param guid: A string representing the object GUID. 178 179 :return response json 180 """ 181 182 return super().delete(id=guid)
10class VulnerabilityPoliciesAPI(CrudEndpoint): 11 12 def __init__(self, session): 13 """ 14 Initializes the VulnerabilityPoliciesAPI object. 15 16 :param session: An instance of the HttpSession class 17 18 :return VulnerabilityPoliciesAPI object. 19 """ 20 21 super().__init__(session, "VulnerabilityPolicies") 22 23 def create(self, 24 policy_type, 25 policy_name, 26 severity, 27 state, 28 filter, 29 props, 30 policy_eval_type=None, 31 fail_on_violation=False, 32 alert_on_violation=False, 33 **request_params): 34 """ 35 A method to create a new VulnerabilityPolicies object. 36 37 :param policy_type: A string representing the type of the policy. 38 :param policy_name: A string representing the name of the policy. 39 :param severity: A string representing the severity of the policy. 40 ("Info", "Low", "Medium", "High", "Critical") 41 :param state: A boolean representing the state of the policy. 42 :param filter: 43 obj: 44 :param rule: An object representing a policy filter rule. 45 obj: 46 :param operator: A string representing the rule operator. 47 ("include", "exclude", "equals", "notEquals") 48 :param values: An array of strings representing the rule values. 49 :param exception: An object representing a policy filter exception. 50 obj: 51 :param operator: A string representing the rule operator. 52 ("include", "exclude", "equals", "notEquals") 53 :param values: An array of strings representing the exception values. 54 :param props: An object containing properties of the policy. 55 obj: 56 :param description: A string representing the property description. 57 :param createdBy: A string representing the creator of the property. 58 :param updatedBy: A string representing the updater of the property. 59 :param policy_eval_type: A string representing the policy evaluation type. 60 :param fail_on_violation: A boolean representing whether the policy should fail on violations. 61 :param alert_on_violation: A boolean representing whether the policy should alert on violations. 62 :param request_params: Additional request parameters. 63 (provides support for parameters that may be added in the future) 64 65 :return response json 66 """ 67 68 return super().create( 69 policy_type=policy_type, 70 policy_name=policy_name, 71 severity=severity, 72 state=int(bool(state)), 73 filter=filter, 74 props=props, 75 policy_eval_type=policy_eval_type, 76 fail_on_violation=int(bool(fail_on_violation)), 77 alert_on_violation=int(bool(alert_on_violation)), 78 **request_params 79 ) 80 81 def get(self, 82 guid=None): 83 """ 84 A method to get VulnerabilityPolicies objects. 85 86 :param guid: A string representing the object GUID. 87 88 :return response json 89 """ 90 91 return super().get(id=guid) 92 93 def get_by_guid(self, 94 guid): 95 """ 96 A method to get a VulnerabilityPolicies object by GUID. 97 98 :param guid: A string representing the object GUID. 99 100 :return response json 101 """ 102 103 return self.get(guid=guid) 104 105 def update(self, 106 guid, 107 policy_type=None, 108 policy_name=None, 109 severity=None, 110 state=None, 111 filter=None, 112 props=None, 113 policy_eval_type=None, 114 fail_on_violation=None, 115 alert_on_violation=None, 116 **request_params): 117 """ 118 A method to update a VulnerabilityPolicies object. 119 120 :param guid: A string representing the object GUID. 121 :param policy_type: A string representing the type of the policy. 122 :param policy_name: A string representing the name of the policy. 123 :param severity: A string representing the severity of the policy. 124 ("Info", "Low", "Medium", "High", "Critical") 125 :param state: A boolean representing the state of the policy. 126 :param filter: 127 obj: 128 :param rule: An object representing a policy filter rule. 129 obj: 130 :param operator: A string representing the rule operator. 131 ("include", "exclude", "equals", "notEquals") 132 :param values: An array of strings representing the rule values. 133 :param exception: An object representing a policy filter exception. 134 obj: 135 :param operator: A string representing the rule operator. 136 ("include", "exclude", "equals", "notEquals") 137 :param values: An array of strings representing the exception values. 138 :param props: An object containing properties of the policy. 139 obj: 140 :param description: A string representing the property description. 141 :param createdBy: A string representing the creator of the property. 142 :param updatedBy: A string representing the updater of the property. 143 :param policy_eval_type: A string representing the policy evaluation type. 144 :param fail_on_violation: A boolean representing whether the policy should fail on violations. 145 :param alert_on_violation: A boolean representing whether the policy should alert on violations. 146 :param request_params: Additional request parameters. 147 (provides support for parameters that may be added in the future) 148 149 :return response json 150 """ 151 152 if state is not None: 153 state = int(bool(state)) 154 if fail_on_violation is not None: 155 fail_on_violation = int(bool(fail_on_violation)) 156 if alert_on_violation is not None: 157 alert_on_violation = int(bool(alert_on_violation)) 158 159 return super().update( 160 guid, 161 policy_type=policy_type, 162 policy_name=policy_name, 163 severity=severity, 164 state=state, 165 filter=filter, 166 props=props, 167 policy_eval_type=policy_eval_type, 168 fail_on_violation=fail_on_violation, 169 alert_on_violation=alert_on_violation, 170 **request_params 171 ) 172 173 def delete(self, 174 guid): 175 """ 176 A method to delete a VulnerabilityPolicies object. 177 178 :param guid: A string representing the object GUID. 179 180 :return response json 181 """ 182 183 return super().delete(id=guid)
A class used to implement CRUD create/read/update/delete functionality for Lacework API Endpoints
VulnerabilityPoliciesAPI(session)
12 def __init__(self, session): 13 """ 14 Initializes the VulnerabilityPoliciesAPI object. 15 16 :param session: An instance of the HttpSession class 17 18 :return VulnerabilityPoliciesAPI object. 19 """ 20 21 super().__init__(session, "VulnerabilityPolicies")
Initializes the VulnerabilityPoliciesAPI object.
Parameters
- session: An instance of the HttpSession class
:return VulnerabilityPoliciesAPI object.
def
create( self, policy_type, policy_name, severity, state, filter, props, policy_eval_type=None, fail_on_violation=False, alert_on_violation=False, **request_params):
23 def create(self, 24 policy_type, 25 policy_name, 26 severity, 27 state, 28 filter, 29 props, 30 policy_eval_type=None, 31 fail_on_violation=False, 32 alert_on_violation=False, 33 **request_params): 34 """ 35 A method to create a new VulnerabilityPolicies object. 36 37 :param policy_type: A string representing the type of the policy. 38 :param policy_name: A string representing the name of the policy. 39 :param severity: A string representing the severity of the policy. 40 ("Info", "Low", "Medium", "High", "Critical") 41 :param state: A boolean representing the state of the policy. 42 :param filter: 43 obj: 44 :param rule: An object representing a policy filter rule. 45 obj: 46 :param operator: A string representing the rule operator. 47 ("include", "exclude", "equals", "notEquals") 48 :param values: An array of strings representing the rule values. 49 :param exception: An object representing a policy filter exception. 50 obj: 51 :param operator: A string representing the rule operator. 52 ("include", "exclude", "equals", "notEquals") 53 :param values: An array of strings representing the exception values. 54 :param props: An object containing properties of the policy. 55 obj: 56 :param description: A string representing the property description. 57 :param createdBy: A string representing the creator of the property. 58 :param updatedBy: A string representing the updater of the property. 59 :param policy_eval_type: A string representing the policy evaluation type. 60 :param fail_on_violation: A boolean representing whether the policy should fail on violations. 61 :param alert_on_violation: A boolean representing whether the policy should alert on violations. 62 :param request_params: Additional request parameters. 63 (provides support for parameters that may be added in the future) 64 65 :return response json 66 """ 67 68 return super().create( 69 policy_type=policy_type, 70 policy_name=policy_name, 71 severity=severity, 72 state=int(bool(state)), 73 filter=filter, 74 props=props, 75 policy_eval_type=policy_eval_type, 76 fail_on_violation=int(bool(fail_on_violation)), 77 alert_on_violation=int(bool(alert_on_violation)), 78 **request_params 79 )
A method to create a new VulnerabilityPolicies object.
Parameters
- policy_type: A string representing the type of the policy.
- policy_name: A string representing the name of the policy.
- severity: A string representing the severity of the policy. ("Info", "Low", "Medium", "High", "Critical")
- state: A boolean representing the state of the policy.
- filter: obj: :param rule: An object representing a policy filter rule. obj: :param operator: A string representing the rule operator. ("include", "exclude", "equals", "notEquals") :param values: An array of strings representing the rule values. :param exception: An object representing a policy filter exception. obj: :param operator: A string representing the rule operator. ("include", "exclude", "equals", "notEquals") :param values: An array of strings representing the exception values.
- props: An object containing properties of the policy. obj: :param description: A string representing the property description. :param createdBy: A string representing the creator of the property. :param updatedBy: A string representing the updater of the property.
- policy_eval_type: A string representing the policy evaluation type.
- fail_on_violation: A boolean representing whether the policy should fail on violations.
- alert_on_violation: A boolean representing whether the policy should alert on violations.
- request_params: Additional request parameters. (provides support for parameters that may be added in the future)
:return response json
def
get(self, guid=None):
81 def get(self, 82 guid=None): 83 """ 84 A method to get VulnerabilityPolicies objects. 85 86 :param guid: A string representing the object GUID. 87 88 :return response json 89 """ 90 91 return super().get(id=guid)
A method to get VulnerabilityPolicies objects.
Parameters
- guid: A string representing the object GUID.
:return response json
def
get_by_guid(self, guid):
93 def get_by_guid(self, 94 guid): 95 """ 96 A method to get a VulnerabilityPolicies object by GUID. 97 98 :param guid: A string representing the object GUID. 99 100 :return response json 101 """ 102 103 return self.get(guid=guid)
A method to get a VulnerabilityPolicies object by GUID.
Parameters
- guid: A string representing the object GUID.
:return response json
def
update( self, guid, policy_type=None, policy_name=None, severity=None, state=None, filter=None, props=None, policy_eval_type=None, fail_on_violation=None, alert_on_violation=None, **request_params):
105 def update(self, 106 guid, 107 policy_type=None, 108 policy_name=None, 109 severity=None, 110 state=None, 111 filter=None, 112 props=None, 113 policy_eval_type=None, 114 fail_on_violation=None, 115 alert_on_violation=None, 116 **request_params): 117 """ 118 A method to update a VulnerabilityPolicies object. 119 120 :param guid: A string representing the object GUID. 121 :param policy_type: A string representing the type of the policy. 122 :param policy_name: A string representing the name of the policy. 123 :param severity: A string representing the severity of the policy. 124 ("Info", "Low", "Medium", "High", "Critical") 125 :param state: A boolean representing the state of the policy. 126 :param filter: 127 obj: 128 :param rule: An object representing a policy filter rule. 129 obj: 130 :param operator: A string representing the rule operator. 131 ("include", "exclude", "equals", "notEquals") 132 :param values: An array of strings representing the rule values. 133 :param exception: An object representing a policy filter exception. 134 obj: 135 :param operator: A string representing the rule operator. 136 ("include", "exclude", "equals", "notEquals") 137 :param values: An array of strings representing the exception values. 138 :param props: An object containing properties of the policy. 139 obj: 140 :param description: A string representing the property description. 141 :param createdBy: A string representing the creator of the property. 142 :param updatedBy: A string representing the updater of the property. 143 :param policy_eval_type: A string representing the policy evaluation type. 144 :param fail_on_violation: A boolean representing whether the policy should fail on violations. 145 :param alert_on_violation: A boolean representing whether the policy should alert on violations. 146 :param request_params: Additional request parameters. 147 (provides support for parameters that may be added in the future) 148 149 :return response json 150 """ 151 152 if state is not None: 153 state = int(bool(state)) 154 if fail_on_violation is not None: 155 fail_on_violation = int(bool(fail_on_violation)) 156 if alert_on_violation is not None: 157 alert_on_violation = int(bool(alert_on_violation)) 158 159 return super().update( 160 guid, 161 policy_type=policy_type, 162 policy_name=policy_name, 163 severity=severity, 164 state=state, 165 filter=filter, 166 props=props, 167 policy_eval_type=policy_eval_type, 168 fail_on_violation=fail_on_violation, 169 alert_on_violation=alert_on_violation, 170 **request_params 171 )
A method to update a VulnerabilityPolicies object.
Parameters
- guid: A string representing the object GUID.
- policy_type: A string representing the type of the policy.
- policy_name: A string representing the name of the policy.
- severity: A string representing the severity of the policy. ("Info", "Low", "Medium", "High", "Critical")
- state: A boolean representing the state of the policy.
- filter: obj: :param rule: An object representing a policy filter rule. obj: :param operator: A string representing the rule operator. ("include", "exclude", "equals", "notEquals") :param values: An array of strings representing the rule values. :param exception: An object representing a policy filter exception. obj: :param operator: A string representing the rule operator. ("include", "exclude", "equals", "notEquals") :param values: An array of strings representing the exception values.
- props: An object containing properties of the policy. obj: :param description: A string representing the property description. :param createdBy: A string representing the creator of the property. :param updatedBy: A string representing the updater of the property.
- policy_eval_type: A string representing the policy evaluation type.
- fail_on_violation: A boolean representing whether the policy should fail on violations.
- alert_on_violation: A boolean representing whether the policy should alert on violations.
- request_params: Additional request parameters. (provides support for parameters that may be added in the future)
:return response json
def
delete(self, guid):
173 def delete(self, 174 guid): 175 """ 176 A method to delete a VulnerabilityPolicies object. 177 178 :param guid: A string representing the object GUID. 179 180 :return response json 181 """ 182 183 return super().delete(id=guid)
A method to delete a VulnerabilityPolicies object.
Parameters
- guid: A string representing the object GUID.
:return response json