Skip to content

Cleanup reported issues#364

Open
chennes wants to merge 1 commit intoFreeCAD:devfrom
chennes:miscSmallCleanup
Open

Cleanup reported issues#364
chennes wants to merge 1 commit intoFreeCAD:devfrom
chennes:miscSmallCleanup

Conversation

@chennes
Copy link
Member

@chennes chennes commented Feb 22, 2026

Remove fallback to regular Python XML parser, forcing use of defusedxml, and eliminate backwards-compatibility of SHA1 generator for Python 3.8, adding the usedforsecurity=False flag.

Copilot AI review requested due to automatic review settings February 22, 2026 22:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request performs security and compatibility cleanup by removing backward-compatibility code. It enforces the use of defusedxml for secure XML parsing (removing the fallback to the standard library's potentially vulnerable XML parser) and drops Python 3.8 compatibility for SHA1 hash generation. Additionally, it adds URL scheme validation to ensure only HTTP(S) URLs are processed, strengthening security posture.

Changes:

  • Removed try/except fallback from defusedxml to xml.etree.ElementTree, making defusedxml mandatory
  • Removed Python 3.8 compatibility code for SHA1 hash generation with usedforsecurity=False parameter
  • Added URL scheme validation to reject non-HTTP(S) schemes in blocking_get() and translation API requests

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
addonmanager_workers_startup.py Changed import to use ParseError alias, removed Python 3.8 SHA1 fallback code
addonmanager_utilities.py Added URL scheme validation to reject non-HTTP(S) URLs
addonmanager_metadata.py Removed fallback import, now requires defusedxml
addonmanager_icon_utilities.py Removed fallback import, now requires defusedxml
Resources/translations/run_translation_cycle.py Added HTTPS validation for API requests and download URLs
AddonCatalogCacheCreator.py Changed import to use ParseError alias
AddonCatalog.py Changed import to use ParseError alias
Addon.py Changed import to use ParseError alias

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +88 to +90
parsed_url = urlparse(url)
if parsed_url.scheme != "https":
raise Exception("API requests must be made over HTTPS")
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

The urlparse function is used here but is not imported. The import statement on line 38 only imports quote_plus from urllib.parse, but not urlparse. This will cause a NameError at runtime when this code is executed.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

While urlparse is imported here from urllib.request (so no runtime error), it is a transitive name. The correct import should be from urllib.parse as it is the real source of the symbol.

https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse

Comment on lines +88 to +90
parsed_url = urlparse(url)
if parsed_url.scheme != "https":
raise Exception("API requests must be made over HTTPS")
Copy link
Contributor

Choose a reason for hiding this comment

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

While urlparse is imported here from urllib.request (so no runtime error), it is a transitive name. The correct import should be from urllib.parse as it is the real source of the symbol.

https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse

provided mainly for testing purposes."""
p = b""
parse_result = urllib.parse.urlparse(url)
if parse_result.scheme != "http" and parse_result.scheme != "https":
Copy link
Contributor

Choose a reason for hiding this comment

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

In other parts you restrict to https, but here you allow http as well. Is this a special case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants