From 994a42659dc500f602e83f91501ec4a959481fa5 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Mon, 23 Aug 2021 19:05:09 -0400 Subject: Enterprise apis and support Also secrets provider + openUrl --- binaryninjaapi.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index dd443c80..629b8b31 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -37,6 +37,7 @@ #include #include #include +#include #include "binaryninjacore.h" #include "json/json.h" @@ -730,6 +731,8 @@ __attribute__ ((format (printf, 1, 2))) BNMessageBoxButtonResult ShowMessageBox(const std::string& title, const std::string& text, BNMessageBoxButtonSet buttons = OKButtonSet, BNMessageBoxIcon icon = InformationIcon); + bool OpenUrl(const std::string& url); + /*! Split a single progress function into equally sized subparts. This function takes the original progress function and returns a new function whose signature @@ -5722,6 +5725,7 @@ __attribute__ ((format (printf, 1, 2))) virtual BNMessageBoxButtonResult ShowMessageBox(const std::string& title, const std::string& text, BNMessageBoxButtonSet buttons = OKButtonSet, BNMessageBoxIcon icon = InformationIcon) = 0; + virtual bool OpenUrl(const std::string& url) = 0; }; typedef BNPluginOrigin PluginOrigin; @@ -6218,5 +6222,78 @@ __attribute__ ((format (printf, 1, 2))) virtual bool IsValid(Ref) = 0; virtual void ParseInfo(Ref, Ref) = 0; }; + + /*! + Class for storing secrets (e.g. tokens) in a system-specific manner + */ + class SecretsProvider: public StaticCoreRefCountObject + { + std::string m_nameForRegister; + + protected: + SecretsProvider(const std::string& name); + SecretsProvider(BNSecretsProvider* provider); + + static bool HasDataCallback(void* ctxt, const char* key); + static char* GetDataCallback(void* ctxt, const char* key); + static bool StoreDataCallback(void* ctxt, const char* key, const char* data); + static bool DeleteDataCallback(void* ctxt, const char* key); + + public: + /*! + Check if data for a specific key exists, but do not retrieve it + \param key Key for data + \return True if data exists + */ + virtual bool HasData(const std::string& key) = 0; + /*! + Retrieve data for the given key, if it exists + \param key Key for data + \return Optional with data, if it exists, or empty optional if it does not exist + or otherwise could not be retrieved. + */ + virtual std::optional GetData(const std::string& key) = 0; + /*! + Store data with the given key + \param key Key for data + \param data Data to store + \return True if the data was stored + */ + virtual bool StoreData(const std::string& key, const std::string& data) = 0; + /*! + Delete stored data with the given key + \param key Key for data + \return True if it was deleted + */ + virtual bool DeleteData(const std::string& key) = 0; + + /*! + Retrieve the list of providers + \return A list of registered providers + */ + static std::vector> GetList(); + /*! + Retrieve a provider by name + \param name Name of provider + \return Provider object, if one with the given name is regestered, or nullptr if not + */ + static Ref GetByName(const std::string& name); + /*! + Register a new provider + \param provider New provider to register + */ + static void Register(SecretsProvider* provider); + }; + + class CoreSecretsProvider: public SecretsProvider + { + public: + CoreSecretsProvider(BNSecretsProvider* provider); + + virtual bool HasData(const std::string& key) override; + virtual std::optional GetData(const std::string& key) override; + virtual bool StoreData(const std::string& key, const std::string& data) override; + virtual bool DeleteData(const std::string& key) override; + }; } -- cgit v1.3.1