fix(tracker): sanitize the Behaviour factory misparse before 6.1 mapping

Pinokio's 6.1 factory parse attributes every type to CMC_Behaviour; the
constructor-runner walk ran before that known failure was discarded and
gave INTEGER the BEHAVIOUR runner.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Patryk Gensch
2026-10-24 19:30:42 +02:00
co-authored by Claude Opus 5.5
parent f8178a08f3
commit a3a572c9db
2 changed files with 10 additions and 6 deletions
+4 -4
View File
@@ -218,14 +218,14 @@ def script_owners(snap: Snapshot, owners) -> dict[str, tuple[str, str]]:
if t.get("type_id") in by_type_id:
mappings[name] = (by_type_id[t["type_id"]], "runner_factory")
continue
runner_owner = _constructor_runner(name, t.get("cpp_class"), class_runner, bases, known_classes)
if runner_owner:
mappings[name] = (runner_owner, "class_constructor")
continue
owner, mapping = t.get("cpp_class"), "explicit"
# Known extractor failure: unrelated factory entries all mapped to Behaviour.
if owner == "CMC_Behaviour" and name != "BEHAVIOUR":
owner = None
runner_owner = _constructor_runner(name, owner, class_runner, bases, known_classes)
if runner_owner:
mappings[name] = (runner_owner, "class_constructor")
continue
if not owner:
candidate = [o for o in owners if owner_name(o) == name]
owner, mapping = (candidate[0] if len(candidate) == 1 else None), "inferred"
+6 -2
View File
@@ -266,14 +266,18 @@ def test_shared_runner_methods_follow_per_type_verdicts(tmp_path):
def test_class_constructor_runners_map_piklib61_types(tmp_path):
snap = Snapshot({"binary": {"name": "p61.dll", "sha256": SHA},
"types": [{"script_name": "INTEGER", "cpp_class": None}, {"script_name": "CONDITION", "cpp_class": None}],
"types": [{"script_name": "INTEGER", "cpp_class": "CMC_Behaviour"}, # Pinokio's factory misparse
{"script_name": "CONDITION", "cpp_class": None}],
"methods": [{"owner": "CMC_Variable", "runner": "CMC_Variable_Runner", "name": "inc", "id": None},
{"owner": "CMC_BasicCondition", "runner": "CMC_BasicCondition_Runner", "name": "check", "id": None}],
{"owner": "CMC_BasicCondition", "runner": "CMC_BasicCondition_Runner", "name": "check", "id": None},
{"owner": "CMC_Behaviour", "runner": "CMC_Behaviour_Runner", "name": "run", "id": None}],
"field_inheritance": [{"class": "CMC_Integer", "base_class": "CMC_Variable"},
{"class": "CMC_Condition", "base_class": "CMC_BasicCondition"}],
"runner_map": {"by_class": [{"class": "CMC_Variable", "runner": "CMC_Variable_Runner"},
{"class": "CMC_Behaviour", "runner": "CMC_Behaviour_Runner"},
{"class": "CMC_BasicCondition", "runner": "CMC_BasicCondition_Runner"}]}})
result = build_tracker([snap], emulator(tmp_path))
assert row(result, "INTEGER", "INC")["original"][0]["mapping"] == "class_constructor"
assert row(result, "CONDITION", "CHECK")["original"]
assert "RUN" not in {m["name"] for m in typ(result, "INTEGER")["methods"]}
assert not {"VARIABLE", "BASICCONDITION"} & {t["name"] for t in result["types"]}