-
-
Notifications
You must be signed in to change notification settings - Fork 652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add validation of update mirror urls #17310
base: master
Are you sure you want to change the base?
add validation of update mirror urls #17310
Conversation
…unction (nvaccess#17205) Moved the logic for parsing update check responses into a new function `parseUpdateCheckResponse`.
Co-authored-by: Sean Budd <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @christopherpross. A couple of minor adjustments, plus I think you may have forgotten to push the schema validation.
source/gui/settingsDialogs.py
Outdated
if not response.ok: | ||
return False | ||
|
||
responseContent = response.text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response
is necessarily OK, as testing fails before running the validator for any status other than 200.
if not response.ok: | |
return False | |
responseContent = response.text | |
responseContent = response.text |
source/updateCheck.py
Outdated
data = res.text | ||
info = parseUpdateCheckResponse(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data = res.text | |
info = parseUpdateCheckResponse(data) | |
info = parseUpdateCheckResponse(res.text) |
Co-authored-by: Sascha Cowley <[email protected]>
Hi @christopherpross - just confirming you've seen Sascha's review and intend to still work on this? |
@seanbudd and @SaschaCowley sorry for the delay, my real life comes in the way. I am so sorry. If you have a deathline for this fix, someone can, if they want take this and fix the remaining missing code. I has forgotten something to push and deleted my local repo. So in the next few days I will try to get into this. But I understand fully if you have a deathline and you have to fix this issue fast. Sorry for the inconventience. |
…nd the updateCheck function. nvaccess#17205
@SaschaCowley and @seanbudd |
See test results for failed build of commit b58d91a109 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @christopherpross. A few suggestions to improve the quality of the update check code while you're here. Please also update the copyright headers of the files you have touched to reflect that they have been modified in 2025, and add yourself to the list of copyright holders, if you like
@@ -118,15 +118,64 @@ def getQualifiedDriverClassNameForStats(cls): | |||
return "%s (core)" % name | |||
|
|||
|
|||
def parseUpdateCheckResponse(data: str) -> dict[str, str] | None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make the code more self-documenting and easier to debug, could you create a new class to hold update information (perhaps as a dataclasses.dataclass
or typing.NamedTuple
)?
@@ -5595,3 +5596,10 @@ def _isResponseAddonStoreCacheHash(response: requests.Response) -> bool: | |||
# While the NV Access Add-on Store cache hash is a git commit hash as a string, other implementations may use a different format. | |||
# Therefore, we only check if the data is a non-empty string. | |||
return isinstance(data, str) and bool(data) | |||
|
|||
|
|||
def _isResponseUpdateMirrorValid(response: requests.Response) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rename this to be a little clearer? Perhaps something like isResponseUpdateMetadata
Co-authored-by: Sascha Cowley <[email protected]>
See test results for failed build of commit 8a7529d07e |
Link to issue number:
#17205
Summary of the issue:
Users could configure an invalid update mirror URL, which would only be discovered when attempting to check for updates. This PR implements a validation mechanism that ensures the specified update mirror is valid before allowing it to be set in the settings.
Description of user facing changes
A new validation process has been added when setting an update mirror URL in NVDA's settings. Users will now receive feedback if the URL they provide is not a valid update mirror. The "Test" button in the settings will now ensure that the mirror responds with the expected format, preventing invalid configurations.
Description of development approach
parseUpdateCheckResponse
.version
launcherUrl
apiVersion
_isResponseUpdateMirrorValid
insettingsDialogs.py
, which callsparseUpdateCheckResponse
to validate the mirror's response._isResponseUpdateMirrorValid
as theresponseValidator
in the_SetURLDialog
for update mirrors.Testing strategy:
Known issues with pull request:
No known issues.
Code Review Checklist:
@coderabbitai summary