From 645e0c51e6293874acda429dc5e278b185704d9b Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Tue, 7 Dec 2021 20:11:59 -0500 Subject: [Enterprise] APIs for server name, version, id --- binaryninjacore.h | 4 ++++ python/enterprise.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/binaryninjacore.h b/binaryninjacore.h index c084eec9..e422ad77 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -2696,6 +2696,10 @@ extern "C" BINARYNINJACOREAPI bool BNIsEnterpriseServerConnected(void); BINARYNINJACOREAPI bool BNIsEnterpriseServerAuthenticated(void); BINARYNINJACOREAPI char* BNGetEnterpriseServerUsername(void); + BINARYNINJACOREAPI char* BNGetEnterpriseServerName(); + BINARYNINJACOREAPI char* BNGetEnterpriseServerId(); + BINARYNINJACOREAPI uint64_t BNGetEnterpriseServerVersion(); + BINARYNINJACOREAPI char* BNGetEnterpriseServerBuildId(); BINARYNINJACOREAPI uint64_t BNGetEnterpriseServerLicenseExpirationTime(void); BINARYNINJACOREAPI uint64_t BNGetEnterpriseServerLicenseDuration(void); BINARYNINJACOREAPI uint64_t BNGetEnterpriseServerReservationTimeLimit(void); diff --git a/python/enterprise.py b/python/enterprise.py index 7e6ebb18..5ea57f0c 100644 --- a/python/enterprise.py +++ b/python/enterprise.py @@ -86,12 +86,59 @@ def is_authenticated() -> bool: return core.BNIsEnterpriseServerAuthenticated() -def username() -> Optional[None]: +def username() -> Optional[str]: """ Get the username of the currently authenticated user to the Enterprise Server. :return: Username, if authenticated. None, otherwise. """ - return core.BNGetEnterpriseServerUsername() + value = core.BNGetEnterpriseServerUsername() + if value == "": + return None + return value + + +def server_name() -> Optional[str]: + """ + Get the display name of the currently connected server + :return: Display name of the currently connected server, if connected. None, otherwise + """ + value = core.BNGetEnterpriseServerName() + if value == "": + return None + return value + + +def server_id() -> Optional[str]: + """ + Get the internal id of the currently connected server + :return: Id of the currently connected server, if connected. None, otherwise + """ + value = core.BNGetEnterpriseServerId() + if value == "": + return None + return value + + +def server_version() -> Optional[int]: + """ + Get the version number of the currently connected server + :return: Version of the currently connected server, if connected. None, otherwise + """ + value = core.BNGetEnterpriseServerVersion() + if value == 0: + return None + return value + + +def server_build_id() -> Optional[str]: + """ + Get the build id string of the currently connected server + :return: Build id of the currently connected server, if connected. None, otherwise + """ + value = core.BNGetEnterpriseServerBuildId() + if value == "": + return None + return value def reservation_time_limit() -> int: -- cgit v1.3.1