Skip to content

Add Makefile.PL prompt to enable no_network by default - #280

Draft
toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/eumm-prompt-nonet-default
Draft

toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/eumm-prompt-nonet-default

Conversation

@toddr-bot

@toddr-bot toddr-bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds an opt-in build-time prompt to perl Makefile.PL that lets users/packagers enable no_network => 1 as the default for all XML::LibXML parsers, readers, and schema validators.

Why

GH #43: XML::LibXML allows network access during XML parsing by default. Even with expand_entities and load_ext_dtd disabled, network fetches can still occur. This is a security concern, but changing the default unconditionally would break existing code. The prompt approach lets users choose.

How

  • Makefile.PL: EUMM prompt() asks "Enable no_network by default?" (default: n). XML_LIBXML_DEFAULT_NONET=1 env var skips the prompt for automated builds. Answering yes adds -DLIBXML_DEFAULT_NONET to compile flags. PERL_MM_USE_DEFAULT=1 (CPAN smokers) gets the safe default of "n".
  • LibXML.xs: New DEFAULT_NONET() function exposes the compile-time flag.
  • LibXML.pm: Conditionally ORs XML_PARSE_NONET into $XML_LIBXML_PARSE_DEFAULTS when the flag is set.
  • _html_options fix: The old !$self->no_network fallback was a hack that inverts when the XML default changes. Replaced with unconditional 1 — HTML always defaults to NONET, which was always the intent. Only explicit method-level no_network => 0 disables it.

Testing

  • Full test suite passes both WITH and WITHOUT -DLIBXML_DEFAULT_NONET
  • t/43options.t updated to handle conditional default
  • Verified DEFAULT_NONET() returns correct value in both builds
  • Verified $parser->no_network() returns 1 when built with the flag, 0 otherwise
  • Verified explicit no_network => 0 opt-out works in both builds

Closes #43


🤖 Generated with Claude Code


Quality Report

Changes: 8 files changed, 63 insertions(+), 15 deletions(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

XML::LibXML allows network access during XML parsing by default,
which is a security concern even when expand_entities and
load_ext_dtd are disabled.  This adds an opt-in build-time prompt
so distributors and end-users can choose secure defaults.

Mechanism:
- Makefile.PL prompts "Enable no_network by default?" (default: n)
- XML_LIBXML_DEFAULT_NONET=1 env var skips the prompt for automation
- Answering "y" adds -DLIBXML_DEFAULT_NONET to the compile flags
- New XS function DEFAULT_NONET() exposes the build-time choice
- LibXML.pm conditionally ORs XML_PARSE_NONET into parse defaults

Also fixes _html_options() to unconditionally default HTML parsing
to NONET (the old !$self->no_network fallback was a fragile hack
that inverts when the XML default flips).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nwellnhof

Copy link
Copy Markdown
Contributor

Even with expand_entities and load_ext_dtd disabled, network fetches can still occur.

How?

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.

XML::LibXML has by default enabled insecure http network access

2 participants