summaryrefslogtreecommitdiff
path: root/plugins/warp/ui/plugin.cpp
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-08-26 23:59:38 -0400
committerMason Reed <mason@vector35.com>2025-10-01 21:38:39 -0400
commitede39aee7e00c40a43b67ca18dd8ab80ee863d85 (patch)
tree67c5eda347ece2282e3c888f38066b496e06dec8 /plugins/warp/ui/plugin.cpp
parenta1c46813e7f279aa4cfdb9dbb91c45b559ebeacd (diff)
[WARP] Enhanced network support
Diffstat (limited to 'plugins/warp/ui/plugin.cpp')
-rw-r--r--plugins/warp/ui/plugin.cpp90
1 files changed, 74 insertions, 16 deletions
diff --git a/plugins/warp/ui/plugin.cpp b/plugins/warp/ui/plugin.cpp
index dccea1f1..388fea3c 100644
--- a/plugins/warp/ui/plugin.cpp
+++ b/plugins/warp/ui/plugin.cpp
@@ -6,6 +6,7 @@
#include "matches.h"
#include "symbollist.h"
#include "viewframe.h"
+#include "shared/fetchdialog.h"
using namespace BinaryNinja;
@@ -32,11 +33,35 @@ Ref<BackgroundTask> GetMatcherTask()
return matcherTask;
}
+void ShowNetworkNotice()
+{
+ // By default, network access is disabled for WARP, this function will show the user a notice to enable it and restart.
+ const auto settings = Settings::Instance();
+ const bool networkNoticeShown = QSettings().value("warp/NetworkNoticeShown", false).toBool();
+ QSettings().setValue("warp/NetworkNoticeShown", true);
+ if (!networkNoticeShown && settings->Contains("network.enableWARP") && !settings->Get<bool>("network.enableWARP"))
+ {
+ const bool enable = ShowMessageBox("Enable WARP Network Access?",
+ "Network access is disabled by default. Enable WARP network features now?\n\n"
+ "You can change this later in Settings.",
+ YesNoButtonSet, InformationIcon) == YesButton;
+ settings->Set("network.enableWARP", enable);
+ // TODO: Add a notifyRestartRequired call here
+ if (enable)
+ ShowMessageBox("WARP Network Enabled", "Please restart Binary Ninja to allow WARP to make requests to the server.", OKButtonSet, InformationIcon);
+ else
+ ShowMessageBox("WARP Network Disabled", "WARP network access will remain disabled. You can enable it later from Settings.", OKButtonSet, InformationIcon);
+ }
+}
+
WarpSidebarWidget::WarpSidebarWidget(BinaryViewRef data) : SidebarWidget("WARP"), m_data(data)
{
- m_logger = LogRegistry::CreateLogger("WARPUI");
+ m_logger = LogRegistry::CreateLogger("WARP UI");
m_currentFrame = nullptr;
+ // If not already shown, opening the sidebar will give notice.
+ ShowNetworkNotice();
+
m_headerWidget = new QWidget();
QHBoxLayout *headerLayout = new QHBoxLayout();
headerLayout->setContentsMargins(0, 0, 0, 0);
@@ -46,20 +71,22 @@ WarpSidebarWidget::WarpSidebarWidget(BinaryViewRef data) : SidebarWidget("WARP")
headerToolbar->setContentsMargins(0, 0, 0, 0);
headerToolbar->setIconSize(QSize(20, 20));
- static auto matcherStopIcon = GetColoredIcon(":/icons/images/stop.png", getThemeColor(RedStandardHighlightColor));
- static auto matcherStartIcon = GetColoredIcon(":/icons/images/start.png",
- getThemeColor(GreenStandardHighlightColor));
- m_matcherAction = headerToolbar->addAction(matcherStartIcon, "Run Matcher", [this]() {
+ auto fetchIcon = GetColoredIcon(":/icons/images/arrow-pull.png", getThemeColor(BlueStandardHighlightColor));
+ auto fetchAction = headerToolbar->addAction(fetchIcon, "Fetch data from WARP containers", [this]() {
UIActionHandler *handler = m_currentFrame->getCurrentViewInterface()->actionHandler();
- if (Ref<BackgroundTask> matcherTask = GetMatcherTask())
- matcherTask->Cancel();
- else if (!isMatcherRunning)
- {
- handler->executeAction("WARP\\Run Matcher");
- setMatcherActionIcon(true);
- }
+ handler->executeAction("WARP\\Fetch");
});
- m_matcherAction->setToolTip("Run the matcher on all functions");
+ fetchAction->setToolTip("Fetch data from WARP containers");
+
+ auto commitIcon = GetColoredIcon(":/icons/images/arrow-push.png", getThemeColor(BlueStandardHighlightColor));
+ auto commitAction = headerToolbar->addAction(commitIcon, "Commit a WARP file to a source", [this]() {
+ UIActionHandler *handler = m_currentFrame->getCurrentViewInterface()->actionHandler();
+ handler->executeAction("WARP\\Commit File");
+ });
+ commitAction->setToolTip("Commit a WARP file to a source");
+
+ // We want to make it clear that the container actions for fetching and pushing are seperate.
+ headerToolbar->addSeparator();
auto loadIcon = GetColoredIcon(":/icons/images/file-add.png", getThemeColor(BlueStandardHighlightColor));
auto loadAction = headerToolbar->addAction(loadIcon, "Load Signature File", [this]() {
@@ -75,21 +102,36 @@ WarpSidebarWidget::WarpSidebarWidget(BinaryViewRef data) : SidebarWidget("WARP")
});
saveAction->setToolTip("Save data to a signature file");
+ headerToolbar->addSeparator();
+
+ static auto matcherStopIcon = GetColoredIcon(":/icons/images/stop.png", getThemeColor(RedStandardHighlightColor));
+ static auto matcherStartIcon = GetColoredIcon(":/icons/images/start.png",
+ getThemeColor(GreenStandardHighlightColor));
+ m_matcherAction = headerToolbar->addAction(matcherStartIcon, "Run Matcher", [this]() {
+ UIActionHandler *handler = m_currentFrame->getCurrentViewInterface()->actionHandler();
+ if (Ref<BackgroundTask> matcherTask = GetMatcherTask())
+ matcherTask->Cancel();
+ else if (!isMatcherRunning)
+ {
+ handler->executeAction("WARP\\Run Matcher");
+ setMatcherActionIcon(true);
+ }
+ });
+ m_matcherAction->setToolTip("Run the matcher on all functions");
+
auto refreshIcon = GetColoredIcon(":/icons/images/refresh.png", getThemeColor(BlueStandardHighlightColor));
auto refreshAction = headerToolbar->addAction(refreshIcon, "Refresh the view data", [this]() {
Update();
});
refreshAction->setToolTip("Refresh the sidebar data");
- // TODO: Add action for pushing to network sources.
-
// Push the toolbar to the right using a stretch space.
headerLayout->addStretch();
headerLayout->addWidget(headerToolbar, 0);
m_headerWidget->setLayout(headerLayout);
QFrame *currentFunctionFrame = new QFrame(this);
- m_currentFunctionWidget = new WarpCurrentFunctionWidget(nullptr);
+ m_currentFunctionWidget = new WarpCurrentFunctionWidget();
QVBoxLayout *currentFunctionLayout = new QVBoxLayout();
currentFunctionLayout->setContentsMargins(0, 0, 0, 0);
currentFunctionLayout->setSpacing(0);
@@ -104,6 +146,14 @@ WarpSidebarWidget::WarpSidebarWidget(BinaryViewRef data) : SidebarWidget("WARP")
matchedLayout->addWidget(m_matchedWidget);
matchedFrame->setLayout(matchedLayout);
+ QFrame *containerFrame = new QFrame(this);
+ m_containerWidget = new WarpContainersPane();
+ QVBoxLayout *containerLayout = new QVBoxLayout();
+ containerLayout->setContentsMargins(0, 0, 0, 0);
+ containerLayout->setSpacing(0);
+ containerLayout->addWidget(m_containerWidget);
+ containerFrame->setLayout(containerLayout);
+
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
@@ -111,6 +161,7 @@ WarpSidebarWidget::WarpSidebarWidget(BinaryViewRef data) : SidebarWidget("WARP")
auto tabWidget = new QTabWidget(this);
tabWidget->addTab(currentFunctionFrame, "Current Function");
tabWidget->addTab(matchedFrame, "Matched Functions");
+ tabWidget->addTab(containerFrame, "Containers");
m_analysisEvent = new AnalysisCompletionEvent(m_data, [this]() {
ExecuteOnMainThread([this]() {
@@ -120,6 +171,9 @@ WarpSidebarWidget::WarpSidebarWidget(BinaryViewRef data) : SidebarWidget("WARP")
layout->addWidget(tabWidget);
this->setLayout(layout);
+
+ // NOTE: This fetcher is shared with the fetch dialog that is constructed on initialization of this plugin.
+ m_currentFunctionWidget->SetFetcher(WarpFetcher::Global());
}
WarpSidebarWidget::~WarpSidebarWidget()
@@ -133,7 +187,9 @@ void WarpSidebarWidget::focus()
void WarpSidebarWidget::Update()
{
+ m_currentFunctionWidget->UpdateMatches();
m_matchedWidget->Update();
+ // TODO: Obviously this probably should not be called here.
setMatcherActionIcon(false);
}
@@ -180,6 +236,7 @@ void WarpSidebarWidget::notifyViewLocationChanged(View *view, const ViewLocation
WarpSidebarWidgetType::WarpSidebarWidgetType() : SidebarWidgetType(QImage(":/icons/images/warp.png"), "WARP")
{
+
}
@@ -194,6 +251,7 @@ BINARYNINJAPLUGIN void CorePluginDependencies()
BINARYNINJAPLUGIN bool UIPluginInit()
{
+ RegisterWarpFetchFunctionsCommand();
Sidebar::addSidebarWidgetType(new WarpSidebarWidgetType());
return true;
}