Repository navigation
Show Binary Ninja's MCRIT requests as background tasks - #35
Conversation
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
left a comment
There was a problem hiding this comment.
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.
The merge-base changed after approval.
|
GitHub dismissed my approval because merging #33 moved this PR's merge-base. Could you merge |
danielplohmann
left a comment
There was a problem hiding this comment.
Thanks. The merge of main (ce4a626) is clean, and lint, the sync checks and the suite (226 tests) pass on it. Approving again.
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.
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_requesttakes a title for that, asrun_backgroundalready does, and each caller names its request: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
Loggerbound 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.BackgroundTaskwhile the job request runs, and checks that "MCRIT: requesting a matching job" is among the running tasks. With #33's plain-threadrun_requestrestored, that check fails. With this PR, the test passes all 177 checks,pytestgives 214 passed, and the settings and metadata sync checks andrun_quality_checks.pypass. The IDA GUI and IDALib tests were not run locally, because no licensed IDA was available. This PR changes IDA only in the addedtitleargument, which IDA ignores.