What changed, and why it matters
This commit changes a test helper function in Trezor's Python library so that it returns the text of the menu item it selected, instead of returning nothing. It is purely a testing/debugging improvement and does not change any device firmware or user-facing security behavior.
No security action needed. Treat as a normal test-infrastructure change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies python/src/trezorlib/debuglink.py, specifically ButtonActions.navigate_to_menu_item(). The method’s return type changes from None to str, and each code path now captures and returns the selected menu item’s text (from layout.vertical_menu_content(), menu[‘current’][idx], button ‘text’ fields, etc.). The change is limited to the debuglink test harness and is marked [no changelog].
Changed components
python/src/trezorlib/debuglink.pyInspect captured patch +33 / −12
diff --git a/python/src/trezorlib/debuglink.py b/python/src/trezorlib/debuglink.py
index 624391227..755c33e0a 100644
--- a/python/src/trezorlib/debuglink.py
+++ b/python/src/trezorlib/debuglink.py
@@ -320,7 +320,9 @@ class LayoutContent(UnstructuredJSONReader):
def bolt_fido_confirm_account(self) -> str | None:
"""Getting the current account name for FIDO on Bolt."""
- fido_confirm = self.find_unique_object_with_key_and_value("component", "FidoConfirm")
+ fido_confirm = self.find_unique_object_with_key_and_value(
+ "component", "FidoConfirm"
+ )
if fido_confirm:
return fido_confirm["account_name"]
@@ -2263,8 +2265,8 @@ class ButtonActions:
click_amount = BUTTON_LETTERS_BIP39[idx].index(letter) + 1
return self.debuglink.screen_buttons.mnemonic_from_index(idx), click_amount
- def navigate_to_menu_item(self, idx: int) -> None:
- """Navigate to the nth item in the vertical menu. Starts from 0."""
+ def navigate_to_menu_item(self, idx: int) -> str:
+ """Navigate to the nth item in the vertical menu. Starts from 0. Returns the selected item text."""
item_buttons = self.debuglink.screen_buttons.vertical_menu_items()
layout = self.debuglink.read_layout()
if self.debuglink.layout_type is LayoutType.Delizia:
@@ -2280,14 +2282,17 @@ class ButtonActions:
)
# click the correct item
new_idx = idx % items_per_screen
+ selected_item_text = (
+ self.debuglink.read_layout().vertical_menu_content()[new_idx]
+ )
self.debuglink.click(item_buttons[new_idx])
+ return selected_item_text
elif "ScrolledVerticalMenu" in layout.all_components():
_prev, next = self.debuglink.screen_buttons.vertical_menu_prev_next()
menu = layout.find_unique_value_by_key(
key="menu_items", default=None, only_type=dict
)
- # multi-screen variant
- if menu["has_next"]:
+ if menu["has_next"]: # multi-screen variant
items_per_screen = 2
# get to the correct screen
for _ in range(idx // items_per_screen):
@@ -2301,25 +2306,41 @@ class ButtonActions:
"ScrolledVerticalMenu"
in self.debuglink.read_layout().all_components()
)
- new_idx = idx % items_per_screen
- self.debuglink.click(item_buttons[new_idx])
- # single-screen variant
- else:
+ idx = idx % items_per_screen
+ else: # single-screen variant
assert len(item_buttons) > idx
- self.debuglink.click(item_buttons[idx])
+ menu = self.debuglink.read_layout().find_unique_value_by_key(
+ key="menu_items", default=None, only_type=dict
+ )
+ selected_item = menu["current"][idx]
+ selected_item_text = selected_item.get(
+ "item", selected_item.get("cancel")
+ )
+ self.debuglink.click(item_buttons[idx])
+ return selected_item_text
# single-screen static menu
# FIXME: remove this when the ScrollableVerticalMenu is implemented everywhere
else:
assert len(item_buttons) > idx
+ button_objects = (
+ self.debuglink.read_layout().find_objects_with_key_and_value(
+ "component", "Button"
+ )
+ )
+ selected_button = button_objects[idx]
+ selected_item_text = selected_button.get("text", "")
self.debuglink.click(item_buttons[idx])
-
+ return selected_item_text
elif self.debuglink.layout_type is LayoutType.Eckhart:
assert "VerticalMenu" in layout.all_components()
# swipe up until the idx item gets to the first position
for _ in range(idx):
self.debuglink.swipe_up()
- assert "VerticalMenu" in self.debuglink.read_layout().all_components()
+ layout = self.debuglink.read_layout()
+ assert "VerticalMenu" in layout.all_components()
# click the first item
+ selected_item_text = layout.vertical_menu_content()[idx]
self.debuglink.click(item_buttons[0])
+ return selected_item_text
else:
raise ValueError("Wrong layout type")
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.