Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is not possible to change scanner_id, target_id or config_id with modify_task #1305

Closed
y0urself opened this issue Sep 28, 2020 · 2 comments
Assignees

Comments

@y0urself
Copy link
Member

It is not possible to change scanner_id, target_id or config_id with modify_task. This effect might also appear in other modify functions of python-gvm ...
This also relates to modify_target and the Ports and Credential fields.

It seems to be an expected behaviour, that these values are immutable (and thus ignored) if the task is scheduled.
E.g.: the GSA-UI marks these fields as immutable, too:
gsa

If a task is not scheduled, these fields can be changed ...

gsa2

Assuming the task is immutable, this is what happens, if you try to change immutable fields with python-gvm:

$ gvm-xml '<modify_task task_id="foo" config_id="bar"/>'
<modify_task_response status="200" status_text="OK"/>
$ gvm-xml '<modify_task task_id="foo" scanner_id="bar2"/>'
<modify_task_response status="200" status_text="OK"/>
$ gvm-xml '<modify_task task_id="foo" target_id="bar3"/>'
<modify_task_response status="200" status_text="OK"/>
$ gvm-xml '<get_tasks task_id="foo"/>'
<get_tasks_response status="200" status_text="OK">...<task id="foo">...<config id="qux">...</config><target id="qux3">...</target>...<scanner id='qux2>...</scanner>...</get_tasks_response>

(The values don't change)

Expected behavior

Response with an error or info from gvmd if a field is currently immutable ..

Like for deletes:

~/Documents/greenbone$ gvm-xml 192.168.212.49 '<delete_target target_id="a1f478c1-27d0-4d8c-959f-150625186421"/>'
Response Error 400. Target is in use
~/Documents/greenbone$ gvm-xml 192.168.212.49 '<modify_target target_id="a1f478c1-27d0-4d8c-959f-150625186421" port_list_id="33d0cd82-57c6-11e1-8ed1-406186ea4fc5"/>'
<modify_target_response status="200" status_text="OK"/>
~/Documents/greenbone$ gvm-xml 192.168.212.49 '<modify_target target_id="a1f478c1-27d0-4d8c-959f-150625186421" port_list_id="1a7539e0-13fa-4a90-9110-178bf0dc8681"/>'
<modify_target_response status="200" status_text="OK"/>

Current behavior

gvmd responses with an "OK" but the value is not changed ...

GVM versions

any

Environment

Operating system:

any

Installation method / source: (packages, source installation)

any

@y0urself y0urself self-assigned this Sep 28, 2020
@y0urself y0urself changed the title It is not possible to change scanner_id or config_id with modify_task It is not possible to change scanner_id, target_id or config_id with modify_task Sep 28, 2020
@y0urself y0urself changed the title It is not possible to change scanner_id, target_id or config_id with modify_task It is not possible to change scanner_id, target_id or config_id with modify_task Sep 28, 2020
@y0urself y0urself removed their assignment Sep 28, 2020
@bjoernricks bjoernricks transferred this issue from greenbone/python-gvm Sep 28, 2020
@timopollmeier
Copy link
Member

Instead of using an attribute for the config id in the GMP command
(<modify_task task_id="foo" config_id="bar"/>)
you should be using an element with an id attribute like this:
<modify_task task id="foo"><config id="bar"/></modify_task>

In this case the modification should either work if the task is new or modifiable or the command should fail with an error response.
The same applies to setting the scanner and target of a task.

@y0urself
Copy link
Member Author

y0urself commented Oct 2, 2020

Oh yes. This works. Thanks!

 '<modify_task task_id="0efdaac6-a2de-4156-acee-d41cde37e754"><target id="5ca97fe1-694d-4e4a-bd4c-55529719d17e"/></modify_task>'
Response Error 400. Status must be New to edit Target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants