Skip to content

Show Binary Ninja's MCRIT requests as background tasks - #35

Merged
danielplohmann merged 3 commits into
familiary:mainfrom
r0ny123:binja-native-tasks
Oct 12, 2026
Merged

danielplohmann merged 3 commits into
familiary:mainfrom
r0ny123:binja-native-tasks

Conversation

@r0ny123

@r0ny123 r0ny123 commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

This builds on #33, which builds on #31. Only a368d28 is new: the diff also shows those two PRs' commits, and shrinks once they merge.

flowchart LR
  main --> 31["#31 requests off the UI thread"]
  31 --> 33["#33 label fetch, overview rendering"]
  33 --> 35["#35 status bar tasks, per-file log"]
  31 --> 34["#34 connection reuse, parallel block lookups"]
Loading

Since #31, requests to the MCRIT server run on plain threads. A slow one, such as fetching labels for a large result (a minute against mcrit.malpedia.io for 151,306 ids), leaves no trace in Binary Ninja except the activity line in the MCRIT sidebar. This PR runs them as BackgroundTaskThreads, which Binary Ninja lists in its status bar next to its own analysis tasks. Backend.run_request takes a title for that, as run_background already does, and each caller names its request:

request status bar text
upload MCRIT: uploading the SMDA report
job list MCRIT: fetching matching jobs
new matching job MCRIT: requesting a matching job
matching result MCRIT: downloading the matching result
labels MCRIT: fetching labels for n matched functions
Function Scope MCRIT: querying matches for function 0x…
Block Scope MCRIT: querying block matches for function 0x…

The tasks do not offer cancelling. A request cannot be interrupted, and it updates the session when it finishes, so a cancel button would not stop anything. On IDA and headless the title is unused and the requests still run synchronously.

The backend also logs through a Logger bound to the file's session id (Logger(bv.file.session_id, "MCRIT")), so its messages land in the log of the file they concern rather than the global one. The sidebar's own messages, which have no file yet, keep the global logger.

The Binary Ninja GUI test lists binaryninja.BackgroundTask while the job request runs, and checks that "MCRIT: requesting a matching job" is among the running tasks. With #33's plain-thread run_request restored, that check fails. With this PR, the test passes all 177 checks, pytest gives 214 passed, and the settings and metadata sync checks and run_quality_checks.py pass. The IDA GUI and IDALib tests were not run locally, because no licensed IDA was available. This PR changes IDA only in the added title argument, which IDA ignores.

Requests ran on plain threads, so a slow one, such as fetching labels
for a large result, showed nothing but the activity line in the MCRIT
sidebar. They now run as BackgroundTaskThreads, which Binary Ninja lists
in its status bar next to its own analysis tasks. Backend.run_request
takes a title for that, as run_background already does, and every
caller names its request. Cancelling is not offered: the requests
cannot be interrupted, and they update the session when they finish.

The backend logs through a Logger bound to the file's session id, so
its messages land in that file's log rather than the global one.

The Binary Ninja GUI test checks that the job request is listed among
the running background tasks. That check fails with plain threads.
# Conflicts:
#	mcrit_plugin/binja/BinjaBackend.py
danielplohmann
danielplohmann previously approved these changes Oct 12, 2026

@danielplohmann danielplohmann left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is a clean change. It merges into current main without conflicts now that #33 is in. Lint, the sync checks and the suite (226 tests) pass on the merged tree. I can't run the Binary Ninja GUI test here, so the status-bar check rests on your run.

I checked that every run_request caller passes a title, that no backend still overrides the old signature (IdaBackend inherits the synchronous default), and that the module-level logger is still used, by McritSidebar, as the description says.

@r0ny123
r0ny123 dismissed danielplohmann’s stale review October 12, 2026 07:56

The merge-base changed after approval.

@danielplohmann

Copy link
Copy Markdown
Collaborator

GitHub dismissed my approval because merging #33 moved this PR's merge-base. Could you merge main in? There are no conflicts, and I'll approve again once you've pushed.

@danielplohmann danielplohmann left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The merge of main (ce4a626) is clean, and lint, the sync checks and the suite (226 tests) pass on it. Approving again.

@danielplohmann
danielplohmann merged commit e619f5d into familiary:main Oct 12, 2026
10 checks passed
@r0ny123
r0ny123 deleted the binja-native-tasks branch October 15, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants