From c602278b2a6a3776f8fafe524149ab8b959662b7 Mon Sep 17 00:00:00 2001 From: Gavin Schneider Date: Thu, 11 Jan 2018 13:47:26 -0800 Subject: [PATCH 1/2] Add support for silo identifier for multi-tenant login --- nexpose/nexpose.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/nexpose/nexpose.py b/nexpose/nexpose.py index 073493e..9f1149f 100644 --- a/nexpose/nexpose.py +++ b/nexpose/nexpose.py @@ -193,8 +193,10 @@ def request_and_create_objects_from_xml(requestor, xpath, object_creator): return create_objects_from_xml(requestor().iterfind(xpath), object_creator.__call__) -def BuildLoginRequest(username, password): +def BuildLoginRequest(username, password, silo_id=None): attributes = {'user-id': username, 'password': password} + if silo_id: + attributes['silo-id'] = silo_id login_request = create_element("LoginRequest", attributes) return login_request @@ -293,10 +295,10 @@ def GetSecurityConsoleStatus(self): class NexposeSession_APIv1d1(NexposeSessionBase): - def __init__(self, host, port, username, password): + def __init__(self, host, port, username, password, silo_id=None): NexposeSessionBase.__init__(self, host, port) self._URI_APIv1d1 = BuildURI_APIv1d1(host, port) - self._login_request = BuildLoginRequest(username, password) + self._login_request = BuildLoginRequest(username, password, silo_id) self._session_id = None # @@ -729,8 +731,8 @@ def RequestSendLog(self, xml_transport, keyid=0): class NexposeSession_APIv1d2(NexposeSession_APIv1d1): - def __init__(self, host, port, username, password): - NexposeSession_APIv1d1.__init__(self, host, port, username, password) + def __init__(self, host, port, username, password, silo_id=None): + NexposeSession_APIv1d1.__init__(self, host, port, username, password, silo_id) self._URI_APIv1d2 = BuildURI_APIv1d2(host, port) # @@ -1166,17 +1168,17 @@ def RequestVulnerabilityExceptionUpdateExpirationDate(self): class NexposeSession(NexposeSession_APIv1d2): @staticmethod - def CreateAndOpen(host, port, username, password): - session = NexposeSession.Create(host, port, username, password) + def CreateAndOpen(host, port, username, password, silo_id=None): + session = NexposeSession.Create(host, port, username, password, silo_id) session.Open() return session @staticmethod - def Create(host, port, username, password): - return NexposeSession(host, port, username, password) + def Create(host, port, username, password, silo_id=None): + return NexposeSession(host, port, username, password, silo_id=None) - def __init__(self, host, port, username, password): - NexposeSession_APIv1d2.__init__(self, host, port, username, password) + def __init__(self, host, port, username, password, silo_id=None): + NexposeSession_APIv1d2.__init__(self, host, port, username, password, silo_id=None) self.session_username = username # From 57dc2234a8f9572fad355395c39e96a5025b9ad7 Mon Sep 17 00:00:00 2001 From: Gavin Schneider Date: Wed, 17 Jan 2018 12:51:43 -0800 Subject: [PATCH 2/2] Fix some silo_id params --- nexpose/nexpose.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nexpose/nexpose.py b/nexpose/nexpose.py index 9f1149f..239af94 100644 --- a/nexpose/nexpose.py +++ b/nexpose/nexpose.py @@ -1175,10 +1175,10 @@ def CreateAndOpen(host, port, username, password, silo_id=None): @staticmethod def Create(host, port, username, password, silo_id=None): - return NexposeSession(host, port, username, password, silo_id=None) + return NexposeSession(host, port, username, password, silo_id) def __init__(self, host, port, username, password, silo_id=None): - NexposeSession_APIv1d2.__init__(self, host, port, username, password, silo_id=None) + NexposeSession_APIv1d2.__init__(self, host, port, username, password, silo_id) self.session_username = username #