imperva / imperva-sdk-python

A Python SDK for Imperva SecureSphere Open API
https://imperva.github.io/imperva-sdk-python/
Other
13 stars 11 forks source link

docs example (on changing severity on 'Anti Google Hacking - 2' policy does not work from API #44

Open andreireiand opened 4 years ago

andreireiand commented 4 years ago

This is the DOCs example:

` MX Web Service Custom Policy Class

pol = mx.get_web_service_custom_policy("Anti Google Hacking - 2") pol.Severity u'high' pol.Severity = 'medium' pol.ApplyTo [] ws <imperva_sdk 'WebService' Object - 'web service name'> pol.ApplyTo = [ws] pol.ApplyTo [<imperva_sdk 'WebService' Object - 'web service name'>]

Create user defined copy of policy

pol_dict = dict(pol) pol_dict['Name'] = 'user defined - %s' % pol_dict['Name'] mx.create_web_service_custom_policy(**pol_dict) <imperva_sdk 'WebServiceCustomPolicy' Object - 'user defined - Anti Google Hacking - 2'> `

In reality, one gets:

`

pol = mx.get_web_service_custom_policy("Anti Google Hacking - 2")

pol Out[388]: <imperva_sdk 'WebServiceCustomPolicy' Object - 'Anti Google Hacking - 2'>

pol.Severity Out[389]: 'high'

pol.Severity = 'medium' Traceback (most recent call last):

File "", line 1, in pol.Severity = 'medium'

File "/anaconda3/lib/python3.7/site-packages/imperva_sdk-0.2.0-py3.7.egg/imperva_sdk/WebServiceCustomPolicy.py", line 154, in Severity self._connection._update_web_service_custom_policy(Name=self._Name, Parameter='severity', Value=Severity)

File "/anaconda3/lib/python3.7/site-packages/imperva_sdk-0.2.0-py3.7.egg/imperva_sdk/MxConnection.py", line 934, in _update_web_service_custom_policy return WebServiceCustomPolicy._update_web_service_custom_policy(connection=self, Name=Name, Parameter=Parameter, Value=Value)

File "/anaconda3/lib/python3.7/site-packages/imperva_sdk-0.2.0-py3.7.egg/imperva_sdk/WebServiceCustomPolicy.py", line 337, in _update_web_service_custom_policy connection._mx_api('PUT', '/conf/webServiceCustomPolicies/%s' % Name, data=json.dumps(body))

File "/anaconda3/lib/python3.7/site-packages/imperva_sdk-0.2.0-py3.7.egg/imperva_sdk/MxConnection.py", line 257, in _mx_api raise MxException("MX returned errors - %s" % str(error_message))

MxException: MX returned errors - [{'description': 'This is a predefined ADC item that cannot be changed', 'error-code': 'IMP-10146'}]

`

Executed on latest release as of now.