Skip to content

[codex] Remove defusedxml dependency#1549

Merged
maurosoria merged 2 commits into
masterfrom
codex/remove-defusedxml
May 22, 2026
Merged

[codex] Remove defusedxml dependency#1549
maurosoria merged 2 commits into
masterfrom
codex/remove-defusedxml

Conversation

@maurosoria
Copy link
Copy Markdown
Owner

@maurosoria maurosoria commented May 22, 2026

Summary

Removes the defusedxml runtime dependency and replaces its two uses with a small stdlib-based XML helper.

Details

  • Adds lib/utils/safe_xml.py, which uses xml.etree.ElementTree after rejecting DTD and entity declarations.
  • Updates Nmap XML parsing and MIME XML detection to use the shared helper.
  • Removes defusedxml from runtime requirements and PyInstaller hidden imports.
  • Removes incidental typing_extensions usage from runtime code while touching the affected imports.
  • Adds direct safe XML tests plus integration coverage for Nmap parsing and MIME XML detection.

Impact

The CLI can start without defusedxml installed, while still rejecting the XML constructs that mattered for XXE-style input. Packaged installs and PyInstaller builds no longer include the unused dependency.

Validation

  • python3 -m unittest tests.utils.test_safe_xml
  • python3 -m unittest tests.utils.test_safe_xml tests.parse.test_nmap tests.utils.test_mimetype tests.parse.test_config tests.parse.test_headers tests.core.test_importable_api
  • python3 -m py_compile lib/utils/safe_xml.py lib/parse/nmap.py lib/utils/mimetype.py lib/core/decorators.py tests/utils/test_safe_xml.py
  • python3 dirsearch.py -h
  • python3 dirsearch.py --wordlist-status -w tests/static/wordlist.txt -q

A broader requester/scanner unittest run was not available in this local environment because httpx is not installed.

Comment thread lib/utils/mimetype.py
from typing_extensions import LiteralString

from defusedxml import ElementTree
from xml.etree import ElementTree
Comment thread lib/utils/safe_xml.py

import re
from pathlib import Path
from xml.etree import ElementTree
@maurosoria maurosoria marked this pull request as ready for review May 22, 2026 02:08
@maurosoria maurosoria merged commit cd35855 into master May 22, 2026
4 of 17 checks passed
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.

2 participants