greenbone / python-gvm

Greenbone Vulnerability Management Python Library
https://greenbone.github.io/python-gvm/
GNU General Public License v3.0
107 stars 60 forks source link

Cannot get extra details for get_tls_certificates using gvm-script or gvm-pyshell #292

Closed frankerooney closed 4 years ago

frankerooney commented 4 years ago

Background: I would like to pull all tls certificates discovered by gvm by using the gmp api, with the optional sources as it will form an incredibly useful way of alerting about certificates which are expiring/expired. Looking at the logs, gsad seems to pull certificates with the source data included using the xml "<get_tls_certificates details=\"1\"/>. This works fine with using gvm-cli, although the api here:

https://docs.greenbone.net/API/GMP/gmp-20.08.html#command_get_tls_certificates

doesn't seem to mention the @details option, just the not dissimilar option of @include_certificate_data which also works to fetch the actual certificate within the xml via gvm-cli.

Within gvm-script or gvm-pyshell, the optional @include_certificate_data functions fine - the same data is fetched as with gvm-cli using that option, but the python module does not recognise the "details=1" or "details=True" boolean option which seems undocumented but which gsad uses.

The docs do mention the element and underlying data, but I can't work out how to pull them in with any other method apart from the details option, and would prefer not to parse the xml from gvm-cli if I can use Python instead.

Thank you Andy

Expected behavior

Certificate detail (sources etc) are fetched as part of the query, using the option details="1"

Current behavior

python produces an error : get_tls_certificates() got an unexpected keyword argument 'details'

Steps to reproduce

I'm using gvm-script with something like: def main(gmp, args): certs=gmp.get_tls_certificates(details='1') ..

other options do work as noted, e.g. def main(gmp, args): cert_filter='rows=-1' certs=gmp.get_tls_certificates(include_certificate_data='1',filter=cert_filter)

..without issue.

GVM versions

Greenbone Security Assistant 20.08.0~git-d26e061f9-gsa-20.08 Greenbone Vulnerability Manager 20.08.0~git-c04cad16-gvmd-20.08 OpenVAS 20.8.0 gvm-libs 20.8.0~git-c316e62-gvm-libs-20.08 gvm-cli 2.2.0.dev1 (API version 20.8.1)

Environment

Ubuntu 20.04 Source installation

y0urself commented 4 years ago

Yeah. The details parameter is not implemented in the python-gvm API: https://github.com/greenbone/python-gvm/blob/master/gvm/protocols/gmpv9/gmpv9.py#L447

y0urself commented 4 years ago

Can confirm, that several data is missing with include_certificate_data instead of details ... Can confirm, that the details option is missing in the Documentation ...

I will add the details flag to get_tls_certificate and get_tls_certificates.

frankerooney commented 4 years ago

Awesome, thanks so much