Resolve XML configuration resources through ConfigurationSource#4161
Draft
ppkarwasz wants to merge 4 commits into
Draft
Resolve XML configuration resources through ConfigurationSource#4161ppkarwasz wants to merge 4 commits into
ppkarwasz wants to merge 4 commits into
Conversation
Resolve the resources referenced by an XML configuration through a single `ConfigurationSourceResolver`: * the targets of `xi:include` (as an `EntityResolver`), * the validation schema, and * the schema's own `xsd:include`/`xsd:import` resources (as an `LSResourceResolver`). They therefore support the Log4j URI conventions (such as the `classpath:` scheme) and obey the `log4j2.configurationAllowedProtocols` restrictions. The schema is parsed with XInclude disabled (a schema is not a configuration), and a schema violation or a rejected resource fails the configuration with a `ConfigurationException`. Assisted-By: Claude Opus 4.8 <noreply@anthropic.com>
Assisted-By: Claude Opus 4.8 <noreply@anthropic.com>
4 tasks
`ConfigurationSourceResolver` resolved `xi:include` targets through the `EntityResolver` interface, whose `resolveEntity(publicId, systemId)` lacks the base URI, so a parser that passes an unresolved, relative `systemId` (such as the target of a nested `xi:include`) could not be satisfied. Implement `EntityResolver2` so the resolver receives the base URI and resolves the `systemId` against it, the same way `resolveResource` already does for schema imports. Assisted-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Note
Stacked on #4158 (
feat/2.x/xinclude-opt-in). Routes every external resource an XML configuration references throughConfigurationSource, the same way the configuration file itself is resolved.A single
ConfigurationSourceResolver(implementingEntityResolver+LSResourceResolver) resolves:xi:includetargets,schemaattribute), andxsd:include/xsd:importresources.As a result, all of them support the Log4j URI conventions (such as the
classpath:scheme) and are subject to thelog4j2.configurationAllowedProtocolsrestrictions, limiting the blast radius of a (trusted) configuration.Behavior changes
ConfigurationExceptioninstead of only logging.Notes
ConfigurationSource/ALLOWED_PROTOCOLSrouting is defense-in-depth within that single trusted tier.XmlConfigurationSchemaTest): a conforming config validates, aFileappender is rejected by aConsole-only schema, and anhttpsub-schema include is blocked byALLOWED_PROTOCOLS; plus the existing XInclude tests.The changelog entry's
<issue>will be set to this PR number once assigned.