nexpose-client-python icon indicating copy to clipboard operation
nexpose-client-python copied to clipboard

Creating a site causes a NexposeFailureException: java.lang.NullPointerException

Open santsys opened this issue 8 years ago • 1 comments

I'm using v0.1.2 of the nexpose library in this instance (older deployment).

Background: I am attempting to create a new site in Nexpose with host information.

In some Nexpose environments (both running 6.5.1) the error NexposeFailureException: java.lang.NullPointerException is generated, but in other environments, everything works fine. Does anyone have any idea of why the call would work in one environment but not in another?

Here is part of a stack trace.

File "test_nexpose.py", line 340, in createNexposeSite
    return session.SaveSiteConfiguration(site_cfg)

File "/usr/local/lib/python2.7/site-packages/nexpose/nexpose.py", line 1347, in SaveSiteConfiguration\n",
    return self._ExecuteSave(self.RequestSiteSave, site_configuration, 'SiteSaveResponse', 'site-id')  # TODO: if this turns out to be 'id' instead of 'site-id' than remove the parameter from the function,

File "/usr/local/lib/python2.7/site-packages/nexpose/nexpose.py", line 1176, in _ExecuteSave,
    response = self.VerifySuccess(save_function(object_to_save.AsXML(exclude_id=False))),

File "/usr/local/lib/python2.7/site-packages/nexpose/nexpose.py", line 1312, in VerifySuccess,
    raise NexposeFailureException(message)",

NexposeFailureException: java.lang.NullPointerException

Here is the basics of how i'm creating the site:

def createNexposeSite(session=None, hosts=list()):
    """
    Create a new site containing the specified hosts.
    This uses the default scan engine 'full-audit-without-web-spider'
    (Full audit without Web Spider).
    """
    if session is None:
        session = initNexposeSession()

    if session is None:
        LOG.error('Unable to open session. Exiting.')
        return None

    site_name = "TempSite-Nexpose-" + datetime.now().strftime("%Y%m%dT%H%M%z")
    site_desc = "Temp Site for hosts that should be scanned."
    site_cfg = nexpose.SiteConfiguration.Create()
    site_cfg.id = -1
    site_cfg.name = site_name
    site_cfg.description = site_desc

    if len(hosts) > 0:
        for h in hosts:
            s_host_range = Range(h, None)
            site_cfg.hosts.append(s_host_range)

    return session.SaveSiteConfiguration(site_cfg)

santsys avatar Jan 12 '18 14:01 santsys

Do you happen to have any error log or stack trace from nsc.log on the console when this occurs? I've seen a few instances on the old community site where someone had a console that was somehow broken and could not view/edit/create sites, and it was a vague NPE like this. I have not determined the cause of that issue, though, nor have I been able to reproduce it. They were new installs and a reinstall likely resolved it for them.

gschneider-r7 avatar Jan 17 '18 20:01 gschneider-r7