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

wrong handling of xml.etreeElementTree objects #19

Closed
lesinigo opened this issue Jun 18, 2020 · 7 comments
Closed

wrong handling of xml.etreeElementTree objects #19

lesinigo opened this issue Jun 18, 2020 · 7 comments

Comments

@lesinigo
Copy link
Contributor

This library has code like this in multiple places:

if (some_xml_element.find('something_else')):
    do_some_stuff

Under some Python / xml.etree versions this will not work as intended, for example I am getting this output from Nmap().nmap_version_detection() (notice missing information about port state and service exposed on the port):

{'port': '443',
 'protocol': 'tcp'}

In the case of Nmap().nmap_version_detection() this happens because <state> and <service> do not have any further sub-elements and as the docs say:

Elements with no subelements will test as False. This behavior will change in future versions. Use specific len(elem) or elem is None test instead.

Changing if(port.find("service")): with if port.find("service") is not None: will restore correct behaviour and give complete results like:

 {'port': '443',
  'protocol': 'tcp',
  'reason': 'syn-ack',
  'reason_ttl': '0',
  'service': {'conf': '10',
              'devicetype': 'security-misc',
              'method': 'probed',
              'name': 'http',
              'product': 'Fortinet security device httpd',
              'tunnel': 'ssl'},
  'state': 'open'}]
@nmmapper
Copy link
Owner

Thank you for that insight. Will get time to fix that, Also if you can open a pull request about it that would be fine.

@lesinigo
Copy link
Contributor Author

I sent pr #21 with some untested code, I will use that in my development but I will be able to test only some of the code paths.

@nmmapper
Copy link
Owner

okay

@lesinigo
Copy link
Contributor Author

lesinigo commented Jul 2, 2020

thank you for merging. as far as I can tell this issue should be resolved, but I hadn't exercised all possible code paths.
If you feel confident about the changes I'd propose to close this issue as resolved.

@lesinigo
Copy link
Contributor Author

lesinigo commented Jul 2, 2020

oh and if you could cut a new release on PyPI that would be great

@nmmapper
Copy link
Owner

nmmapper commented Jul 2, 2020

Okay let get that done.

@lesinigo
Copy link
Contributor Author

lesinigo commented Jul 9, 2020

Thank you @wangoloj for your quick support, you've been very helpful.

As far as I can tell this problem is now fixed in code and also in the PyPI released version, I'm closing the issue.

@lesinigo lesinigo closed this as completed Jul 9, 2020
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

2 participants