summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--binaryninjaapi.h28
-rw-r--r--binaryninjacore.h36
-rw-r--r--pluginmanager.cpp67
-rw-r--r--python/pluginmanager.py34
4 files changed, 53 insertions, 112 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 544c2e10..bab26345 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -2591,22 +2591,6 @@ namespace BinaryNinja
class RepoPlugin: public CoreRefCountObject<BNRepoPlugin, BNNewPluginReference, BNFreePlugin>
{
public:
- RepoPlugin(const std::string& path,
- bool installed,
- bool enabled,
- const std::string& api,
- const std::string& author,
- const std::string& description,
- const std::string& license,
- const std::string& licenseText,
- const std::string& longdescription,
- const std::string& minimimVersions,
- const std::string& name,
- const std::vector<PluginType>& pluginTypes,
- const std::string& url,
- const std::string& version,
- const std::string& repoPath,
- const std::string& gitModulesPath);
RepoPlugin(BNRepoPlugin* plugin);
std::string GetPath() const;
bool IsInstalled() const;
@@ -2630,11 +2614,6 @@ namespace BinaryNinja
class Repository: public CoreRefCountObject<BNRepository, BNNewRepositoryReference, BNFreeRepository>
{
public:
- Repository(const std::string& url, // URL of the git repository containing the plugins
- const std::string& repoPath, // Name of the directory to store this repository within the repositories directory
- const std::string& repoManifest="plugins", // Name of the of the inner directory and .json file
- const std::string& localReference="master",
- const std::string& remoteReference="origin");
Repository(BNRepository* repository);
~Repository();
std::string GetUrl() const;
@@ -2652,14 +2631,17 @@ namespace BinaryNinja
{
bool m_core;
public:
- RepositoryManager(std::vector<Ref<Repository>>& repoInfo, const std::string& enabledPluginsPath);
+ RepositoryManager(const std::string& enabledPluginsPath);
RepositoryManager(BNRepositoryManager* repoManager);
RepositoryManager();
~RepositoryManager();
bool CheckForUpdates();
std::vector<Ref<Repository>> GetRepositories();
Ref<Repository> GetRepositoryByPath(const std::string& repoName);
- bool AddRepository(Ref<Repository> repo);
+ bool AddRepository(const std::string& url,
+ const std::string& repoPath, // Relative path within the repositories directory
+ const std::string& localReference="master",
+ const std::string& remoteReference="origin");
bool EnablePlugin(const std::string& repoName, const std::string& pluginPath);
bool DisablePlugin(const std::string& repoName, const std::string& pluginPath);
bool InstallPlugin(const std::string& repoName, const std::string& pluginPath);
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 80fc715c..0b2375ef 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -2403,23 +2403,6 @@ extern "C"
BINARYNINJACOREAPI const char* BNPluginGetUrl(BNRepoPlugin* p);
BINARYNINJACOREAPI const char* BNPluginGetVersion(BNRepoPlugin* p);
BINARYNINJACOREAPI void BNFreePluginTypes(BNPluginType* r);
- BINARYNINJACOREAPI BNRepoPlugin* BNCreatePlugin(const char* path,
- bool installed,
- bool enabled,
- const char* api,
- const char* author,
- const char* description,
- const char* license,
- const char* licenseText,
- const char* longdescription,
- const char* minimimVersions,
- const char* name,
- const BNPluginType* pluginTypes,
- size_t pluginTypesSize,
- const char* url,
- const char* version,
- const char* repoPath,
- const char* gitModulesPath);
BINARYNINJACOREAPI BNRepoPlugin* BNNewPluginReference(BNRepoPlugin* r);
BINARYNINJACOREAPI void BNFreePlugin(BNRepoPlugin* plugin);
BINARYNINJACOREAPI const char* BNPluginGetPath(BNRepoPlugin* p);
@@ -2428,10 +2411,11 @@ extern "C"
BINARYNINJACOREAPI bool BNPluginIsEnabled(BNRepoPlugin* p);
BINARYNINJACOREAPI BNPluginUpdateStatus BNPluginGetPluginUpdateStatus(BNRepoPlugin* p);
BINARYNINJACOREAPI BNPluginType* BNPluginGetPluginTypes(BNRepoPlugin* p, size_t* count);
- BINARYNINJACOREAPI BNRepository* BNCreateRepository(const char* url,
- const char* repoPath,
- const char* localReference,
- const char* remoteReference);
+ BINARYNINJACOREAPI bool BNPluginEnable(BNRepoPlugin* p);
+ BINARYNINJACOREAPI bool BNPluginDisable(BNRepoPlugin* p);
+ BINARYNINJACOREAPI bool BNPluginInstall(BNRepoPlugin* p);
+ BINARYNINJACOREAPI bool BNPluginUninstall(BNRepoPlugin* p);
+
BINARYNINJACOREAPI BNRepository* BNNewRepositoryReference(BNRepository* r);
BINARYNINJACOREAPI void BNFreeRepository(BNRepository* r);
BINARYNINJACOREAPI char* BNRepositoryGetUrl(BNRepository* r);
@@ -2445,15 +2429,17 @@ extern "C"
BINARYNINJACOREAPI BNRepoPlugin* BNRepositoryGetPluginByPath(BNRepository* r, const char* pluginPath);
BINARYNINJACOREAPI const char* BNRepositoryGetPluginsPath(BNRepository* r);
- BINARYNINJACOREAPI BNRepositoryManager* BNCreateRepositoryManager(BNRepository** repos,
- size_t reposSize,
- const char* enabledPluginsPath);
+ BINARYNINJACOREAPI BNRepositoryManager* BNCreateRepositoryManager(const char* enabledPluginsPath);
BINARYNINJACOREAPI BNRepositoryManager* BNNewRepositoryManagerReference(BNRepositoryManager* r);
BINARYNINJACOREAPI void BNFreeRepositoryManager(BNRepositoryManager* r);
BINARYNINJACOREAPI bool BNRepositoryManagerCheckForUpdates(BNRepositoryManager* r);
BINARYNINJACOREAPI BNRepository** BNRepositoryManagerGetRepositories(BNRepositoryManager* r, size_t* count);
BINARYNINJACOREAPI void BNFreeRepositoryManagerRepositoriesList(BNRepository** r);
- BINARYNINJACOREAPI bool BNRepositoryManagerAddRepository(BNRepositoryManager* r, BNRepository* repo);
+ BINARYNINJACOREAPI bool BNRepositoryManagerAddRepository(BNRepositoryManager* r,
+ const char* url,
+ const char* repoPath,
+ const char* localReference,
+ const char* remoteReference);
BINARYNINJACOREAPI bool BNRepositoryManagerEnablePlugin(BNRepositoryManager* r, const char* repoName, const char* pluginPath);
BINARYNINJACOREAPI bool BNRepositoryManagerDisablePlugin(BNRepositoryManager* r, const char* repoName, const char* pluginPath);
BINARYNINJACOREAPI bool BNRepositoryManagerInstallPlugin(BNRepositoryManager* r, const char* repoName, const char* pluginPath);
diff --git a/pluginmanager.cpp b/pluginmanager.cpp
index ab2b23ee..95c8ea15 100644
--- a/pluginmanager.cpp
+++ b/pluginmanager.cpp
@@ -10,42 +10,6 @@ using namespace std;
return result; \
}while(0)
-RepoPlugin::RepoPlugin(const string& path,
- bool installed,
- bool enabled,
- const string& api,
- const string& author,
- const string& description,
- const string& license,
- const string& licenseText,
- const string& longdescription,
- const string& minimimVersions,
- const string& name,
- const vector<PluginType>& pluginTypes,
- const string& url,
- const string& version,
- const string& repoPath,
- const string& gitModulesPath)
-{
- m_object = BNCreatePlugin(path.c_str(),
- installed,
- enabled,
- api.c_str(),
- author.c_str(),
- description.c_str(),
- license.c_str(),
- licenseText.c_str(),
- longdescription.c_str(),
- minimimVersions.c_str(),
- name.c_str(),
- &pluginTypes[0],
- pluginTypes.size(),
- url.c_str(),
- version.c_str(),
- repoPath.c_str(),
- gitModulesPath.c_str());
-}
-
RepoPlugin::RepoPlugin(BNRepoPlugin* plugin)
{
m_object = plugin;
@@ -139,18 +103,6 @@ string RepoPlugin::GetVersion() const
RETURN_STRING(BNPluginGetVersion(m_object));
}
-Repository::Repository(const string& url,
- const string& repoPath,
- const string& repoManifest,
- const string& localReference,
- const string& remoteReference)
-{
- m_object = BNCreateRepository(url.c_str(),
- repoPath.c_str(),
- localReference.c_str(),
- remoteReference.c_str());
-}
-
Repository::Repository(BNRepository* r)
{
m_object = r;
@@ -205,14 +157,10 @@ string Repository::GetFullPath() const
RETURN_STRING(BNRepositoryGetPluginsPath(m_object));
}
-RepositoryManager::RepositoryManager(vector<Ref<Repository>>& repoInfo, const string& enabledPluginsPath)
+RepositoryManager::RepositoryManager(const string& enabledPluginsPath)
:m_core(false)
{
- BNRepository** buffer = new BNRepository*[repoInfo.size()];
- for (size_t i = 0; i < repoInfo.size(); i++)
- buffer[i] = repoInfo[i]->m_object;
- m_object = BNCreateRepositoryManager(buffer, repoInfo.size(), enabledPluginsPath.c_str());
- delete[] buffer;
+ m_object = BNCreateRepositoryManager(enabledPluginsPath.c_str());
}
RepositoryManager::RepositoryManager(BNRepositoryManager* mgr)
@@ -249,9 +197,16 @@ vector<Ref<Repository>> RepositoryManager::GetRepositories()
return repos;
}
-bool RepositoryManager::AddRepository(Ref<Repository> repo)
+bool RepositoryManager::AddRepository(const std::string& url,
+ const std::string& repoPath, // Relative path within the repositories directory
+ const std::string& localReference,
+ const std::string& remoteReference)
{
- return BNRepositoryManagerAddRepository(m_object, repo->GetObject());
+ return BNRepositoryManagerAddRepository(m_object,
+ url.c_str(),
+ repoPath.c_str(),
+ localReference.c_str(),
+ remoteReference.c_str());
}
Ref<Repository> RepositoryManager::GetRepositoryByPath(const std::string& repoPath)
diff --git a/python/pluginmanager.py b/python/pluginmanager.py
index 348f13fb..766b9b53 100644
--- a/python/pluginmanager.py
+++ b/python/pluginmanager.py
@@ -28,7 +28,8 @@ import startup
class RepoPlugin(object):
"""
- ``Plugin`` is a read-only class. Use RepositoryManager to Enable/Disable/Install/Uninstall plugins.
+ ``RepoPlugin` is mostly read-only, however you can install/uninstall enable/disable plugins. RepoPlugins are
+ created by parsing the plugins.json in a plugin repository.
"""
def __init__(self, handle):
self.handle = core.handle_of_type(handle, core.BNRepoPlugin)
@@ -49,11 +50,25 @@ class RepoPlugin(object):
"""Boolean True if the plugin is installed, False otherwise"""
return core.BNPluginIsInstalled(self.handle)
+ @installed.setter
+ def installed(self, state):
+ if state:
+ return core.BNPluginInstall(self.handle)
+ else:
+ return core.BNPluginUninstall(self.handle)
+
@property
def enabled(self):
"""Boolean True if the plugin is currently enabled, False otherwise"""
return core.BNPluginIsEnabled(self.handle)
+ @enabled.setter
+ def enabled(self, state):
+ if state:
+ return core.BNPluginEnable(self.handle)
+ else:
+ return core.BNPluginDisable(self.handle)
+
@property
def api(self):
"""string indicating the api used by the plugin"""
@@ -151,7 +166,7 @@ class Repository(object):
@property
def plugins(self):
- """List of Plugin objects contained within this repository"""
+ """List of RepoPlugin objects contained within this repository"""
pluginlist = []
count = ctypes.c_ulonglong(0)
result = core.BNRepositoryGetPlugins(self.handle, count)
@@ -168,6 +183,10 @@ class Repository(object):
class RepositoryManager(object):
+ """
+ ``RepositoryManager`` Keeps track of all the repositories and keeps the enabled_plugins.json file coherent with
+ the plugins that are installed/unstalled enabled/disabled
+ """
def __init__(self, handle=None):
self.handle = core.BNGetRepositoryManager()
@@ -236,7 +255,7 @@ class RepositoryManager(object):
``disable_plugin`` Disable the specified plugin, pluginpath
:param Repository or str repo: Repository containing the plugin to disable
- :param Plugin or str plugin: Plugin to disable
+ :param RepoPlugin or str plugin: RepoPlugin to disable
:return: Boolean value True if the plugin was successfully disabled, False otherwise
:rtype: Boolean
:Example:
@@ -261,7 +280,7 @@ class RepositoryManager(object):
``install_plugin`` install the specified plugin, pluginpath
:param Repository or str repo: Repository containing the plugin to install
- :param Plugin or str plugin: Plugin to install
+ :param RepoPlugin or str plugin: RepoPlugin to install
:return: Boolean value True if the plugin was successfully installed, False otherwise
:rtype: Boolean
:Example:
@@ -286,7 +305,7 @@ class RepositoryManager(object):
``uninstall_plugin`` uninstall the specified plugin, pluginpath
:param Repository or str repo: Repository containing the plugin to uninstall
- :param Plugin or str plugin: Plugin to uninstall
+ :param RepoPlugin or str plugin: RepoPlugin to uninstall
:return: Boolean value True if the plugin was successfully uninstalled, False otherwise
:rtype: Boolean
:Example:
@@ -311,7 +330,7 @@ class RepositoryManager(object):
``update_plugin`` update the specified plugin, pluginpath
:param Repository or str repo: Repository containing the plugin to update
- :param Plugin or str plugin: Plugin to update
+ :param RepoPlugin or str plugin: RepoPlugin to update
:return: Boolean value True if the plugin was successfully updated, False otherwise
:rtype: Boolean
:Example:
@@ -354,6 +373,5 @@ class RepositoryManager(object):
if not (isinstance(url, str) and isinstance(repopath, str) and
isinstance(localreference, str) and isinstance(remotereference, str)):
raise ValueError("Parameter is incorrect type")
- repo = core.BNCreateRepository(url, repopath, localreference, remotereference)
- return core.BNRepositoryManagerAddRepository(self.handle, repo)
+ return core.BNRepositoryManagerAddRepository(self.handle, url, repopath, localreference, remotereference)