| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
All XML parsing of server responses already uses defusedxml (safe against XXE/entity expansion). Stdlib xml is retained only for building outbound request bodies (no defusedxml equivalent) and for the ParseError exception type (which defusedxml raises unchanged). Added inline comments at each import site so future contributors don't replace these with defusedxml unnecessarily, and updated pyproject.toml dependency comment to explain the split. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sorry, something went wrong.
There was a problem hiding this comment.
This PR clarifies the project’s intended split between stdlib xml.etree.ElementTree (XML building/types) and defusedxml.ElementTree (XML parsing), adding inline comments at import/dependency sites to make future security audits and refactors less error-prone.
Changes:
Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.
Show a summary per file| File | Description |
|---|---|
| tableauserverclient/server/request_factory.py | Annotates stdlib ElementTree import as intended for request XML building only. |
| tableauserverclient/server/endpoint/endpoint.py | Annotates ParseError import as exception-type-only (shared with defusedxml). |
| tableauserverclient/models/workbook_item.py | Adds builder-only intent comment to stdlib ElementTree import. |
| tableauserverclient/models/webhook_item.py | Adds builder-only intent comment to stdlib ElementTree import. |
| tableauserverclient/models/virtual_connection_item.py | Adds builder-only intent comment to stdlib Element import. |
| tableauserverclient/models/user_item.py | Adds builder-only intent comment to stdlib ElementTree import. |
| tableauserverclient/models/tag_item.py | Adds builder-only intent comment to stdlib ElementTree import. |
| tableauserverclient/models/site_item.py | Adds builder-only intent comment to stdlib ElementTree import. |
| tableauserverclient/models/server_info_item.py | Adds comment clarifying stdlib xml import is only for ParseError typing/handling. |
| tableauserverclient/models/schedule_item.py | Adds builder-only intent comment to stdlib ElementTree import. |
| tableauserverclient/models/project_item.py | Adds builder-only intent comment to stdlib ElementTree import. |
| tableauserverclient/models/permissions_item.py | Adds builder-only intent comment to stdlib ElementTree import. |
| tableauserverclient/models/metric_item.py | Adds builder-only intent comment to stdlib ElementTree import. |
| tableauserverclient/models/location_item.py | Adds builder-only intent comment to stdlib ElementTree import. |
| tableauserverclient/models/groupset_item.py | Adds builder-only intent comment to stdlib ElementTree import. |
| tableauserverclient/models/flow_item.py | Adds builder-only intent comment to stdlib ElementTree import. |
| tableauserverclient/models/extract_item.py | Adds builder-only intent comment to stdlib ElementTree import. |
| tableauserverclient/models/datasource_item.py | Adds builder-only intent comment to stdlib ElementTree import. |
| tableauserverclient/models/data_freshness_policy_item.py | Adds builder-only intent comment to stdlib ElementTree import. |
| tableauserverclient/models/collection_item.py | Adds builder-only intent comment to stdlib Element import. |
| pyproject.toml | Expands defusedxml dependency comment to document parsing-vs-building intent. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sorry, something went wrong.
metric_item.py's from_response() was parsing untrusted server response bytes with xml.etree.ElementTree.fromstring, which is exactly the scenario defusedxml exists to defend against. Switch to defusedxml.ElementTree.fromstring so metric responses go through the same hardened parser as every other from_response path in this package. Also correct import-site comments to reflect actual usage: - location_item, data_freshness_policy_item and 14 other models use stdlib ET only for type annotations (ET.Element hints, isinstance narrowing). Comment now reads "type annotation only; parsing uses defusedxml" instead of the inaccurate "building XML request bodies only". - server_info_item.py used a bare `import xml` and reached into xml.etree.ElementTree.ParseError, which only worked because defusedxml happens to import xml.etree transitively. Replace with an explicit `from xml.etree.ElementTree import ParseError` and match the except clause. defusedxml.ElementTree.fromstring raises this same class for malformed input. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| Back | FazBrowse Home | New Git URL |
Motivation
TSC uses both xml.etree.ElementTree (stdlib) and defusedxml.ElementTree
across the codebase, and the pattern isn't obvious from a fresh reading.
Frontier AI's recent security analysis of all OSS Salesforce repos flagged
these stdlib xml.etree.ElementTree imports as a potential XXE concern.
On investigation, every parsing path (from_response, from_xml inputs)
already uses defusedxml.fromstring for XXE safety; stdlib
xml.etree.ElementTree is retained only for building outbound request
bodies (Element / SubElement / tostring) and as a type annotation
for already-parsed inputs. defusedxml doesn't provide a builder
equivalent, so we can't simplify by using it everywhere.
Inline comments answer the security-analysis question at each import
site so future audits (Frontier AI or human) can confirm the intent
without re-tracing every usage, and so a well-meaning "swap stdlib for
defusedxml" cleanup doesn't accidentally break outbound XML building.
Behavior change
Docs only.
(21 files) explaining the intent.
the same split.
Test plan
🤖 Generated with Claude Code