From 8eac659991594202578069f5fce483045afeb186 Mon Sep 17 00:00:00 2001 From: Sean Budd Date: Fri, 9 Sep 2022 13:27:58 +1000 Subject: [PATCH] Restore backwards compatibility for SecureDesktopNVDAObject (#14116) Follow up to #14105 Fixes issue described in https://github.com/nvaccess/nvda/pull/14111#issuecomment-1239040406 Summary of the issue: SecureDesktopNVDAObject is an API end point used to indicate to the user and to API consumers (including NVDA remote), that the user has switched to a secure desktop. This is triggered when Windows notification EVENT_SYSTEM_DESKTOPSWITCH notifies that the desktop has changed. The switch is handled via a gainFocus event. The gainFocus event causes the user instance of NVDA to enter sleep mode as the secure mode NVDA instance starts on the secure screen. Information from SecureDesktopNVDAObject should not be accessible to the user, as it is backed by a valid MSAA desktop running on a secure profile, that NVDA can report information from. This should generally be handled by NVDA entering sleep mode. In #14105, SecureDesktopNVDAObject became based on NVDAObject to improve security for the object, by breaking it's connection to a valid window. This was to decrease the theoretical risk of information leakage. However, it was discovered that NVDA core event tracking and API consumers rely on SecureDesktopNVDAObject inheriting from Window (a parent class of Desktop). As such, SecureDesktopNVDAObject must remain a Desktop subclass to retain backwards compatibility. However we can prevent neighbouring objects from being accessed. Description of user facing changes Fixes bug in NVDA alpha with handling SecureDesktopNVDAObject. Fixes API breakage. Description of development approach Reverts the change in #14105, making SecureDesktopNVDAObject inherit from Desktop. Prevents neighbouring objects to SecureDesktopNVDAObject from being accessed by overriding relevant methods. --- source/IAccessibleHandler/__init__.py | 37 +++++++++++++++------------ user_docs/en/changes.t2t | 8 ------ 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/source/IAccessibleHandler/__init__.py b/source/IAccessibleHandler/__init__.py index 24cdc4d5092..d8703c66aa2 100644 --- a/source/IAccessibleHandler/__init__.py +++ b/source/IAccessibleHandler/__init__.py @@ -48,7 +48,6 @@ import keyboardHandler from logHandler import log import mouseHandler -from NVDAObjects import NVDAObject import NVDAObjects.IAccessible import NVDAObjects.window import winUser @@ -772,7 +771,7 @@ def processFocusNVDAEvent(obj, force=False): return True -class SecureDesktopNVDAObject(NVDAObject): +class SecureDesktopNVDAObject(NVDAObjects.window.Desktop): """ Used to indicate to the user and to API consumers (including NVDA remote), that the user has switched to a secure desktop. @@ -781,23 +780,12 @@ class SecureDesktopNVDAObject(NVDAObject): The gainFocus event causes NVDA to enter sleep mode as the secure mode NVDA instance starts on the secure screen. - This object is not backed by a valid MSAA object as the Secure Desktop - object should not be accessed via NVDA. - The minimal functionality has been added to support backwards compatibility. + This object is backed by a valid MSAA object. + However, as information from the Secure Desktop object should not be accessed via this instance of NVDA, + getting related objects returns None. + This object must remain a Desktop subclass to retain backwards compatibility. """ - def __init__(self, windowHandle: int): - """ - @param windowHandle: to retain backwards compatibility, - unused as this object is not backed by a valid MSAA object. - This object just serves as a minimal API endpoint. - """ - self._windowHandle = windowHandle - super().__init__() - - def _get_processID(self) -> int: - return 0 - def findOverlayClasses(self, clsList): clsList.append(SecureDesktopNVDAObject) return clsList @@ -814,6 +802,21 @@ def event_gainFocus(self): # After handling the focus, NVDA should sleep while the secure desktop is active. self.sleepMode = self.SLEEP_FULL + def _get_next(self) -> None: + return None + + def _get_previous(self) -> None: + return None + + def _get_firstChild(self) -> None: + return None + + def _get_lastChild(self) -> None: + return None + + def _get_parent(self) -> None: + return None + def processDesktopSwitchWinEvent(window, objectID, childID): if isMSAADebugLoggingEnabled(): diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index cc1af1c1040..fcee6160c7d 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -11,14 +11,6 @@ This is a patch release to fix an accidental API breakage introduced in 2022.2.1 This caused NVDA remote to not recognize secure desktops. (#14094) - -== Changes for Developers == -This release contains a technical breakage in API backwards compatibility. -It is expected that this change does not affect any add-ons. -Please open a GitHub issue if your add-on becomes incompatible as a result of this release. - -- ``SecureDesktopNVDAObject`` is no longer a subclass of ``Desktop`` or ``Window``. (#14105) -- - = 2022.2.2 = This is a patch release to fix a bug introduced in 2022.2.1 with input gestures.