imperva / imperva/imperva-sdk-python

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

Open
#44 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
14
Forks
10
PR merge metrics
No merged PRs in 30d

Description

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

>>> pol.ApplyTo = [ws]
>>> pol.ApplyTo
[]
>>> # 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)

`

In reality, one gets:

`

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

pol
Out[388]:

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the documented custom-policy example alongside imperva_sdk/WebServiceCustomPolicy.py, especially the Severity setter and update method, and MxConnection.py where the API request is made. Reproduce the predefined-policy update against the reported API behavior, then determine whether the documentation or SDK behavior is inconsistent and verify the corrected example or handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.