Skip to content

add validation of update mirror urls#17310

Merged
seanbudd merged 22 commits into
nvaccess:masterfrom
christopherpross:feature/#17205
Mar 7, 2025
Merged

add validation of update mirror urls#17310
seanbudd merged 22 commits into
nvaccess:masterfrom
christopherpross:feature/#17205

Conversation

@christopherpross

@christopherpross christopherpross commented Oct 20, 2024

Copy link
Copy Markdown
Contributor

Link to issue number:

Fixes #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

  • Refactored parsing logic for update responses into a new function: parseUpdateCheckResponse.
  • Defined the minimum schema for an update mirror response based on the following required keys:
    • version
    • launcherUrl
    • apiVersion
  • Implemented a new function _isResponseUpdateMirrorValid in settingsDialogs.py, which calls parseUpdateCheckResponse to validate the mirror's response.
  • Added _isResponseUpdateMirrorValid as the responseValidator in the _SetURLDialog for update mirrors.

Testing strategy:

  • Ran NVDA from source.
  • Ensured the update mirror URL was set to "no Mirror".
  • Test 1: Set the URL to "https://www.nvaccess.org/nvdaUpdateCheck".
    • Pressed the "Test" button and verified that the URL was marked as valid.
  • Test 2: Set the URL to "https://google.de".
    • Pressed the "Test" button and verified that the URL was marked as invalid.
  • Test 3: Set the URL to "https://github.com".
    • Pressed the "Test" button and verified that the URL was marked as invalid.
  • Test 4: Set the URL to the Chinese NVDA Community Update Mirror (https://nvaccess.mirror.nvdadr.com/nvdaUpdateCheck).
    • Verified that this URL was marked as valid.
  • Additional tests with random strings to ensure that invalid URLs are correctly marked as invalid.

Known issues with pull request:

No known issues.

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@coderabbitai summary

@christopherpross christopherpross marked this pull request as ready for review October 20, 2024 11:34
@christopherpross christopherpross requested a review from a team as a code owner October 20, 2024 11:34
Comment thread source/updateCheck.py Outdated
Co-authored-by: Sean Budd <seanbudd123@gmail.com>
@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Oct 21, 2024

@SaschaCowley SaschaCowley left a comment

Copy link
Copy Markdown
Member

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.

Comment thread user_docs/en/changes.md Outdated
Comment thread source/gui/settingsDialogs.py Outdated
Comment thread source/gui/settingsDialogs.py Outdated
Comment thread source/updateCheck.py Outdated
Co-authored-by: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com>
@seanbudd seanbudd marked this pull request as draft November 4, 2024 01:05
@seanbudd

seanbudd commented Dec 2, 2024

Copy link
Copy Markdown
Member

Hi @christopherpross - just confirming you've seen Sascha's review and intend to still work on this?

@christopherpross

Copy link
Copy Markdown
Contributor Author

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

@christopherpross

Copy link
Copy Markdown
Contributor Author

@SaschaCowley and @seanbudd
sorry for the delay, I have now pushed the missing code.

@christopherpross christopherpross marked this pull request as ready for review January 7, 2025 08:42
@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit b58d91a109

@seanbudd seanbudd requested a review from SaschaCowley January 9, 2025 03:12

@SaschaCowley SaschaCowley left a comment

Copy link
Copy Markdown
Member

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

Comment thread source/updateCheck.py Outdated
Comment thread source/updateCheck.py Outdated
Comment thread source/gui/settingsDialogs.py Outdated
@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 8a7529d07e

christopherpross and others added 3 commits January 10, 2025 06:40
Co-authored-by: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com>
…s#17205

Introduced the UpdateInfo dataclass to replace the dictionary used for update metadata. This improves type safety, readability, and maintainability by providing a structured and self-documenting representation of update information.
@christopherpross

Copy link
Copy Markdown
Contributor Author

@SaschaCowley
Done, I have implemented all the suggested changes.

@SaschaCowley SaschaCowley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions on how to make this more maintainable and performant, as well as on keeping to our coding standards.

Comment thread source/updateCheck.py Outdated
Comment thread source/updateCheck.py Outdated
Comment thread source/updateCheck.py
Comment thread source/updateCheck.py Outdated
Comment thread source/updateCheck.py Outdated
Comment thread source/updateCheck.py Outdated
Comment thread source/updateCheck.py Outdated
Comment thread source/updateCheck.py
Comment thread source/updateCheck.py Outdated
Comment thread user_docs/en/changes.md
Co-authored-by: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com>
@christopherpross

Copy link
Copy Markdown
Contributor Author

@SaschaCowley Ok, I have applied the suggestions and documented the breaking changes.

Comment thread source/updateCheck.py Outdated
Comment thread source/updateCheck.py
Comment thread source/updateCheck.py Outdated
Comment thread source/updateCheck.py Outdated
Comment thread source/updateCheck.py Outdated
Comment thread source/updateCheck.py Outdated
Comment thread user_docs/en/changes.md Outdated
# Conflicts:
#	source/gui/settingsDialogs.py
#	user_docs/en/changes.md
@seanbudd seanbudd marked this pull request as draft February 20, 2025 03:37
@gerald-hartig gerald-hartig added this to the 2025.1 milestone Mar 3, 2025
@seanbudd seanbudd modified the milestone: 2025.1 Mar 3, 2025
@seanbudd seanbudd added api-breaking-change release/blocking this issue blocks the milestone release labels Mar 3, 2025
@SaschaCowley SaschaCowley marked this pull request as ready for review March 6, 2025 22:51
@seanbudd seanbudd merged commit 1b4a28d into nvaccess:master Mar 7, 2025
christopherpross added a commit to christopherpross/nvda that referenced this pull request Mar 8, 2025
christopherpross added a commit to christopherpross/nvda that referenced this pull request Mar 10, 2025
SaschaCowley added a commit that referenced this pull request Mar 20, 2025
Fixes #17811
Follow-up to #17310

Summary of the issue:
Attempting to install a just-downloaded update fails on latest alphas.

Description of user facing changes
Update installation should work again

Description of development approach
Fixed several instances of property access on the `UpdateInfo` object
using snake_case instead of camelCase.

Testing strategy:
Created a portable from source, spoofing the version and update version
type:

```ps
./scons source version=2024.1 updateVersionType=stable
```

Ran the following tests:

1. Update and install immediately
   1. Launch the portable
   1. Check for updates, and download the update
   1. When prompted, choose to install the update
1. Wait for the launcher to run, then cancel by answering No when asked
whether to update the portable
1. Update and install later manually
   1. Launch the portable
   1. Check for updates, and download the update
   1. When prompted, choose to postpone the update
1. Exit NVDA via the exit dialog, and choose to install the pending
update
1. Wait for the launcher to run, then cancel by answering No when asked
whether to update the portable
1. Update and install later when prompted
   1. Launch the portable
   1. Check for updates, and download the update
   1. When prompted, choose to postpone the update
   1. Restart the portable
   1. When prompted, choose to install the pending update
1. Wait for the launcher to run, then cancel by answering No when asked
whether to update the portable

Known issues with pull request:
None.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-breaking-change conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. release/blocking this issue blocks the milestone release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve NVDA Update Check URL testing to be more robust

5 participants