summaryrefslogtreecommitdiff
path: root/binaryninjaapi.h
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2021-08-23 19:05:09 -0400
committerGlenn Smith <glenn@vector35.com>2021-11-18 21:37:52 -0500
commit994a42659dc500f602e83f91501ec4a959481fa5 (patch)
treeca783900c9a6d41dbdd98a1cd66a083d3e886578 /binaryninjaapi.h
parent60f2ecd9d1961f7cd700e01f802bcf640c9d50e0 (diff)
Enterprise apis and support
Also secrets provider + openUrl
Diffstat (limited to 'binaryninjaapi.h')
-rw-r--r--binaryninjaapi.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index dd443c80..629b8b31 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -37,6 +37,7 @@
#include <cstdint>
#include <type_traits>
#include <variant>
+#include <optional>
#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<BinaryView>) = 0;
virtual void ParseInfo(Ref<DebugInfo>, Ref<BinaryView>) = 0;
};
+
+ /*!
+ Class for storing secrets (e.g. tokens) in a system-specific manner
+ */
+ class SecretsProvider: public StaticCoreRefCountObject<BNSecretsProvider>
+ {
+ 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<std::string> 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<Ref<SecretsProvider>> 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<SecretsProvider> 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<std::string> 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;
+ };
}