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

modify_target Error: HOSTS requires an EXCLUDE_HOSTS #187

Closed
sarritzu opened this issue Dec 10, 2019 · 6 comments
Closed

modify_target Error: HOSTS requires an EXCLUDE_HOSTS #187

sarritzu opened this issue Dec 10, 2019 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@sarritzu
Copy link

Hello,

just to let you know that the function "modify_target" requires the "exclude_hosts" parameter if you set the "hosts" parameter. Even if it's supposed to be optional...

e.g. you will get that error if you try to call

gmp.modify_target(target_id, hosts=['192.168.1.2'])

you will get the error:

gvm.errors.GvmError: ('Error in response. HOSTS requires an EXCLUDE_HOSTS', <Element modify_target_response at 0x7fe668f3f588>)

In order to avoid the error you have to use instead:

gmp.modify_target(target_id, hosts=['192.168.1.2'], exclude_hosts=[''])

@bjoernricks
Copy link
Member

Thanks for the info. For me this is actually an issue in gvmd but we should implement a workaround in python-gvm.

@bjoernricks bjoernricks transferred this issue from greenbone/gvm-tools Dec 10, 2019
@bjoernricks bjoernricks added the bug Something isn't working label Dec 10, 2019
@bjoernricks
Copy link
Member

@y0urself do you have some time to validate this issue and implement a fix? Something like

if hosts and exclude_hosts is None:
  exclude_hosts = ['']

@y0urself
Copy link
Member

Sure

@y0urself y0urself self-assigned this Dec 10, 2019
@bjoernricks
Copy link
Member

Thanks!

@y0urself
Copy link
Member

If I tested this bug correctly, it appears when I use the gmp.modify_target() method and also if I directly send a <modify_target> request over ssh.
I have done a workaround for the gmp class, but it will not help, when you use raw xml requests - these need to look like this:

<modify_target target_id='fancy_id'>
  <name>really good name</name>
  <hosts>some,hosts,here</hosts>
  <exclude_hosts/>
</modify_target>

or

<modify_target target_id='fancy_id'>
  <name>really good name</name>
  <hosts>some,hosts,here</hosts>
  <exclude_hosts></exclude_hosts>
</modify_target>

@y0urself y0urself mentioned this issue Dec 13, 2019
3 tasks
@bjoernricks
Copy link
Member

Should be fixed with #188

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants