Skip to content

Fix label import, scope queries and settings that shipped wrong in 1.1.10 - #23

Merged
danielplohmann merged 4 commits into
familiary:mainfrom
r0ny123:fix-shipped-behaviour
Sep 28, 2026
Merged

danielplohmann merged 4 commits into
familiary:mainfrom
r0ny123:fix-shipped-behaviour

Conversation

@r0ny123

@r0ny123 r0ny123 commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Based on main after #17. It fixes behaviour that already shipped in 1.1.10 and turned up while testing #17, so it should merge before ida-v2.0.0 is tagged. #22 stacks on this one.

The fixes users can notice have entries in the [2.0.0] section of CHANGELOG.md.

What it fixes

  • Sorted tables. Both the Function Overview and the result chooser allow sorting, which moves rows, while the label mappings, the dropdown editors, job_infos and the status colours stayed keyed by the row each entry was filled into. After a header click, Import Labels applied each label to another function and the chooser loaded another job than the selected one. Each cell now carries the row it was filled into, or its job's index.
  • sample_group_only. MCRIT hands the query parameters of POST /query/function to MinHashIndex.getMatchesForSmdaFunction, and those of a single-sample matching job to Worker.getMatchesForSample. Neither takes sample_group_only, so with the setting on every Function Scope query answered 500 and every matching job failed. MCRIT's own client sends it only for cross compares, which the plugin does not request, and MCRITweb forwards neither request's parameters. The plugin no longer sends it, and the setting is removed (see "Review of the first three commits" below).
  • config_override.json was merged into the defaults, which are read only when the settings store raises, and ida-settings answers with the declared default for every declared key. So an override never applied, on main either. Overrides are now read first, and the plugin prints the keys an override forces when it loads. All four integration runners refuse to start while the plugin under test has one, and README says to keep only the keys to force.
  • Function Scope and Block Scope:
    • Cursor moves before Convert were ignored, so Query Current Function and Query Current Block right after Convert found no current function.
    • Functions of exactly 10 instructions were queried, which MCRIT does not MinHash (MINHASH_FN_MIN_INS, compared with >).
    • A failed PicBlockHash query was cached as "no matches".
    • A failed sample list showed "unknown" hashes instead of the "unavailable" message.
    • Sample Info kept a family picked for an earlier result even when the next result has no match in it.
  • Result queries and graph view: a failed job query opened a chooser that said no results existed, Block Scope's message named Function Scope, and the IDA graph view's hover hint showed a placeholder.
  • Cleanup: the IDA 6.x leftovers the first commit carried over from IDAscope (attributes nothing read, and a PySide 1 branch in each of QtShim's 50 accessors) are removed. The plugin requires IDA 9.

Checks

Local at the head, against MCRIT 1.12.0 and SMDA 4.9.0: ruff clean, 210 pytest passed with PySide6 installed (207 and one skip without it), the IDA 9.3 GUI test in autonomous mode, -A (145 checks) and the IDALib test pass, and the Binary Ninja 6.0 GUI test (167 checks) and the headless test pass. Both GUI tests now import labels from a table sorted by descending offset; without the sorted-table fix, that check names the three functions that got another function's label.

Review of the first three commits

5b09e87 addresses the review, on a branch rebased onto main:

  • config_override.json visibility: the plugin prints [!] config_override.json forces: … once at load, and the template lists two example keys instead of all eighteen. An override whose top level is not a JSON object is ignored instead of failing the import.
  • sample_group_only removed. Checked with ida-hcli 0.26.0 and ida-settings 3.5.1 in a throwaway IDAUSR: after installing the current package with --config sample_group_only=true, uninstalling and installing a build that no longer declares the key succeeds. The stored value stays in ida-config.json and is ignored, and hcli plugin config list, get and set work for the remaining keys. Only a read of the removed key raises KeyError, which nothing does now. hcli refuses plugin upgrade from a local file, so the index upgrade path itself was not run. The vendored McritClient keeps its parameters.
  • Nits:
    • A failed PicBlockHash lookup skips the rest of that visit's lookups.
    • A reachable server with no families or samples counts as fetched.
    • Query Current Block takes the function from the block under the cursor.
    • The 10-instruction check notes that a server can set another threshold.
    • The CHANGELOG has the Block Scope message fix, and the two config_override.json bullets are merged.
    • An offscreen PySide6 test covers the sorted Overview and result chooser. It fails without the fix, and the pytest job now installs PySide6.
  • Found while writing that test: Function Scope's match table puts hex offsets into NumberQTableWidgetItem, whose __lt__ called float(). Sorting that table by offset raised inside Qt's sort, which crashes the process under PySide6 6.11. That shipped in 1.1.10. Hex text now compares by value, with a test and a CHANGELOG bullet.

@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.

Reviewed the three commits of this PR (pr/17..70c07ee). Nothing blocks the merge. There is one should-fix, and the question you asked is answered below. On the head, ruff passes, 214 pytest pass, and the settings and metadata sync scripts pass.

Should-fix

An active config_override.json now takes priority without telling anyone. See mcrit_plugin/core/config.py:105-118. Reading overrides first is the correct fix, but it changes who is affected:

  • docs/config_override.json.template lists all 18 keys at their defaults, including mcrit_server: 127.0.0.1 and an empty token. The IDA ZIP ships it.
  • Someone who copied the whole template, or still has a full copy from 1.1.x (where it never applied), gets server, token and every option pinned after upgrading.
  • From then on, Plugin Settings Manager, hcli and Binja Settings silently do nothing.

Suggested fix: print the forced keys once at load, e.g. [!] config_override.json forces: mcrit_server, .... Alternatively, cut the template down to one or two example keys. Doing both would be best.

Nits

  • config.py:110-116: if the JSON top level is not an object, the plugin fails at import. A number, bool or null makes key in override_settings raise TypeError; a string does substring matching and then fails. Only JSONDecodeError and IOError are caught, so an isinstance(..., dict) check would fix it.
  • BlockMatchWidget.py:244-255: not caching a failed PicBlockHash lookup is right. But if the server answers the family and sample lists and then times out on picblockhash, every revisit repeats every failed hash one after another on the UI thread. With live tracking on, that is N x timeout per function visit, where before only the first visit paid. Stopping after the first failure in a visit would fix it.
  • FunctionMatchWidget.py:138-149 and the same check in BlockMatchWidget: moving from is None to not is right for the "unknown hashes" fix. But a reachable server with 0 families or samples now shows "unavailable. Check server connection." and fetches both lists again on every query.
  • BlockMatchWidget.py:171-179 (low confidence): queryCurrentBlock takes the block from the cursor, but the function comes only from FunctionMatchWidget.hook_refresh. On Binja, where cursor notifications can arrive late, the pair can mismatch. Taking the function from the report entry that contains the block would rule that out.
  • FunctionMatchWidget.py:205: the <= 10 check is correct for default servers. We checked MCRIT's MinHasher.isMinHashableFunction: it uses > MINHASH_FN_MIN_INS, or > MINHASH_FN_MIN_BLOCKS, which is off by default. It still copies a value the server can configure, so a comment there would help.
  • CHANGELOG: the Block Scope message fix ("Live Block Queries are deactivated") has no bullet. The #17 bullet "Where config_override.json applied, which was only when the settings store failed…" now stands next to the new precedence bullet, and the two read better as one.
  • The sorted-table fix has only GUI-test coverage. An offscreen PySide6 test guarded by importorskip is feasible: we built the real ResultChooserDialog and a table with the real DropdownDelegate and _populatedRow in a scratch script, and it behaves as described.

Checked and correct

  • Sorted tables, at runtime:
    • After a descending sort, getEditorForRow(_populatedRow(r)) returns each row's own editor. Keyed by the visual row, every row got another row's editor.
    • jobInfoAt, the status colour key and the selection all follow the job.
    • No other consumer indexes by the visual row.
  • sample_group_only, checked in the MCRIT source: the query and match resources pass **getMatchingParams into getMatchesForSmdaFunction / getMatchesForSample, and neither accepts it. Only getMatchesCross does. MCRITweb forwards neither request's parameters.
  • Override precedence: holds on all three backends. Boolean coercion handles "false".
  • Runner refusal: limited to the four dev and CI runners, not the plugin runtime.
  • Scope fixes: the cursor is tracked before Convert, and [] versus None caching is correct. Sample Info falls back to the best family, and a None job list no longer opens the chooser.
  • QtShim: nothing references the removed attributes, and idaVersions is >=9.0.

Your question: sample_group_only

Remove it in 2.0.0.

  • It is the major release, so removal is clean now; otherwise it waits for 3.0.
  • The option broke every request against a plain MCRIT server, so no working setup depends on it.
  • A toggle that does nothing, in both settings UIs, will produce "why does this do nothing" reports.

One check first: make sure hcli / ida-settings don't reject or loudly warn about an undeclared key still stored in an existing ida-config.json. If they error, keep it deprecated for 2.0.x after all. Either way, keep the sample_group_only parameters in the vendored McritClient, since the cross-compare path uses them.

@r0ny123
r0ny123 force-pushed the fix-shipped-behaviour branch from 70c07ee to c900b2f Compare September 28, 2026 19:22
@danielplohmann

Copy link
Copy Markdown
Collaborator

@r0ny123 #17 is merged into main as 15f5789 with a merge commit, so its SHAs are unchanged and this PR's diff is down to its own three commits.

Please bring this branch up to date with main. A rebase or a merge of main both work. The only new commit besides #17 is c3ff5ab (CODEOWNERS). In the same push, please pick up the review above:

  • should-fix: make an active config_override.json visible, either by logging the forced keys once at load or by shipping a minimal template.
  • sample_group_only: remove it in 2.0.0, after checking that hcli / ida-settings don't reject a stale key left in an existing ida-config.json. Keep the parameters in the vendored McritClient, since the cross-compare path uses them.
  • the nits as you see fit (the non-dict override crash and the CHANGELOG gaps are the ones I'd take).

The licensed IDA job can't run from the fork, so I'll dispatch it again on an origin branch at the new head before merging, as for #17. #22 comes after this one.

@r0ny123
r0ny123 marked this pull request as ready for review September 28, 2026 19:29
All of these behaved this way in 1.1.10.

- Both the Function Overview and the result chooser allow sorting,
  which moves rows, while the Overview's label mappings and dropdown
  editors and the chooser's job_infos and status colours stayed keyed
  by the row each entry was filled into. After a header click, Import
  Labels applied each label to another function and the chooser loaded
  another job than the selected one. Each cell now carries the row it
  was filled into, or its job's index, and every lookup goes through
  that. Both GUI tests import labels from a table sorted by descending
  offset and check each renamed function against its own matches'
  labels; without the fix that check names three functions.
- Function Scope's refresh returned before reading the cursor while no
  report existed, so Query Current Function and Query Current Block
  right after Convert found no current function. The cursor is
  followed first, and Query Current Block takes the block under the
  cursor.
- MCRIT MinHashes a function only above 10 instructions and answers a
  query for one of exactly 10 with a 500; Function Scope now requires
  more than 10.
- A failed PicBlockHash query was cached as None and read as "no
  matches"; only answers are cached now.
- Function and Block Scope tested sample_infos against None, which it
  never is, so a failed sample list showed "unknown" hashes instead of
  "Remote family/sample info unavailable".
- A failed job query opened the result chooser, which then claimed no
  matching results existed; the handler stops after the failure message.
- Sample Info kept a family picked for an earlier result even when the
  next result has no match in it; it falls back to the best family.
- Block Scope said "Live Function Queries are deactivated", and the IDA
  graph view's hover hint showed a placeholder; it shows the block's
  offset. SmdaGraphViewer's header no longer calls it a Hex-Rays
  example, and draw() no longer calls OnGetText only to discard it.
Neither did in 1.1.10.

- MCRIT hands the query parameters of POST /query/function to
  MinHashIndex.getMatchesForSmdaFunction, and those of a single-sample
  matching job to Worker.getMatchesForSample. Neither takes
  sample_group_only, so with the setting on every Function Scope query
  answered 500 and every matching job failed. MCRIT's own client sends
  it only for cross compares, which the plugin does not request, and
  MCRITweb forwards neither request's parameters. The plugin no longer
  sends it; the setting stays declared, titled and documented as
  deprecated with no effect, and the vendored client's docstring says
  what MCRIT does with it.
- config_override.json was merged into the defaults, which McritConfig
  reads only when the settings store raises. ida-settings answers with
  the declared default for any declared key, and Binary Ninja's Settings
  has every key once they are registered, so an override never applied.
  The overrides are kept apart and read first. README says the file's
  keys take precedence, so it should hold only the keys to force, and
  where it goes for Binary Ninja.
- The config tests get an empty plugin root, so a developer's own
  config_override.json cannot change the defaults they pin.
- An override in the plugin under test would now beat the settings the
  integration runners use, so all four refuse to start while one is
  there, before they install or write anything.
The plugin's first commit brought code over from IDAscope, written for
IDA 6: attributes that kept json and os reachable on IDA 6.x for
Windows, a datetime alias for the same reason, comments about shared
MCRIT4IDA modules and IDA < 6.9, and in QtShim a PySide 1 branch for
IDA 6.8 and below in each of the 50 accessors. The plugin requires IDA
9, nothing read the attributes, and the branches were unreachable. Every
QtShim accessor still resolves under PySide6, and IDA 9.0/9.1 keep
PyQt5. A comment typo is fixed on the way.
sample_group_only is removed. MCRIT fails every matching job and
function query that carries it, so no working setup depends on it.
With hcli 0.26 and ida-settings 3.5.1, a value that an earlier version
stored stays in ida-config.json and is ignored: installing a version
that no longer declares the key succeeds, and the remaining settings
read, set and list as before. The vendored McritClient keeps its
parameters, because MCRIT's cross compare takes them.

config_override.json now takes precedence, so a full copy of the old
template would pin every setting without anyone noticing. The plugin
prints the keys an override forces when it loads. The template shows two
keys instead of all eighteen, and an override whose top level is not a
JSON object is ignored instead of failing the import.

NumberQTableWidgetItem compared its text with float(), so sorting
Function Scope's match table by its hex offsets raised inside Qt's sort,
which crashes the process under PySide6 6.11. Hex text now compares by
value.

Scope queries:
- An empty family or sample list from a reachable server counts as
  fetched; only a failed request (None) is fetched again.
- A failed PicBlockHash lookup skips the rest of that visit's lookups
  instead of each waiting out the same timeout.
- Query Current Block takes the function from the block under the
  cursor, since the Function Scope hook can lag behind on Binary Ninja.

An offscreen PySide6 test covers the sorted Function Overview, the
result chooser and hex sorting, and the pytest job installs PySide6 to
run it. The IDA entry-point test hides Qt modules that other tests
loaded, so it checks only the entry point's own imports.
@r0ny123
r0ny123 force-pushed the fix-shipped-behaviour branch from c900b2f to 5b09e87 Compare September 28, 2026 19:45
@r0ny123

r0ny123 commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. The branch is rebased onto main (it now holds only this PR's commits), and 5b09e87 addresses the review:

  • Should-fix: both. The plugin prints [!] config_override.json forces: … once at load, and the template has two example keys instead of all eighteen.
  • sample_group_only: removed. Checked with ida-hcli 0.26.0 and ida-settings 3.5.1 in a throwaway IDAUSR: after installing with --config sample_group_only=true, uninstalling and installing a build that no longer declares the key succeeds, and the stored value stays in ida-config.json, ignored. hcli plugin config list, get and set work for the other keys, and only reading the removed key raises KeyError. hcli refuses plugin upgrade from a local file, so the upgrade path through the index was not run. The vendored McritClient keeps its parameters.
  • Nits: all taken:
    • the isinstance(..., dict) check on the override;
    • one failed PicBlockHash lookup per visit;
    • an empty family or sample list counts as fetched;
    • Query Current Block takes the function from the block;
    • the threshold comment;
    • both CHANGELOG gaps;
    • the offscreen PySide6 test. It fails without the fix, and the pytest job installs PySide6 for it.
  • One more bug, found while writing that test: Function Scope's match table puts hex offsets into NumberQTableWidgetItem, whose __lt__ used float(). Sorting by offset raised inside Qt's sort, which crashes the process under PySide6 6.11. That shipped in 1.1.10. It now compares hex by value, with a test and a CHANGELOG bullet.

With MCRIT 1.12.0 and smda 4.9.0, the IDA 9.3 GUI test (145 checks), the IDALib test, the Binary Ninja GUI test (167 checks) and the headless test pass locally at 5b09e87. #22 is rebased onto it.

@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.

Approving at 5b09e87. It addresses the whole review: the forced override keys are printed at load, the template is minimal, a non-object override is ignored, sample_group_only is removed (and thanks for checking hcli / ida-settings with a stale key), and the scope nits and sorted-table test are in. The hex-sort crash fix is a good catch.

The licensed IDA 9.3 job ran on this exact commit from an origin branch against smda 4.9.0 (run 36474647820): 145 PASS, 0 FAIL.

One nit for later, not blocking: _numeric in NumberQTableWidgetItem.py still raises on non-numeric text ("", "unknown"), which would reach Qt's sort the same way. If any of those columns can ever hold such text, falling back to a text comparison would close it.

@danielplohmann
danielplohmann merged commit ca71edb into familiary:main Sep 28, 2026
19 checks passed
@r0ny123
r0ny123 deleted the fix-shipped-behaviour branch September 30, 2026 18:47
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