Skip to content

Fix #13084: allow negated-property profiles in external model builds - #13095

Open
gnodet wants to merge 1 commit into
apache:masterfrom
gnodet:fix/13084-negated-property-activation-in-external-models
Open

Fix #13084: allow negated-property profiles in external model builds#13095
gnodet wants to merge 1 commit into
apache:masterfrom
gnodet:fix/13084-negated-property-activation-in-external-models

Conversation

@gnodet

@gnodet gnodet commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Profiles activated by a negated property condition (<name>!foo</name>, no value) fire when the property is absent — the classic "opt-out flag" idiom. Such profiles are on by default and can only be suppressed (by setting the property), never injected by supplying one.

The previous implementation treated all property conditions as unsafe and filtered them out of external model builds (withoutFileAndPropertyActivation / hasFileOrPropertyOrConditionActivation). This broke effective model construction for any POM that relies on negated-property profiles to inject dependency versions — resteasy-client:7.0.0.Final is a canonical example (its resteasy-default profile activates on !resteasy.dependencies.eap). When those versions were missing, the effective-model validator reported them as errors and threw ModelBuildingException.

Root cause

The filter introduced in commit 03c947d8 to prevent environment-controlled profiles from injecting repositories into external models blocked negated-property activations as a side effect. Negated conditions are the opposite of the threat model: an attacker cannot force them on — they are already on by default.

Fix

Both the compat (DefaultModelBuilder) and the Maven 4 impl (DefaultModelBuilder / hasFileOrPropertyOrConditionActivation) now treat a negated-name-only property condition as environment-independent and allow it through the filter. All other property conditions (positive name, or a required value) remain blocked. The existing repository-stripping step is unaffected — external models still cannot inject repositories.

Test

Added negatedPropertyActivatedProfileIsPreservedInExternalModelBuild() to DefaultModelBuilderTest: builds a POM in VALIDATION_LEVEL_MINIMAL mode (the same level used by the artifact descriptor reader) with a profile activated by !skip.defaults; verifies that the profile activates and its dependency appears in the effective model.

Fixes #13084


Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet

…uilds

A profile whose activation uses a negated property condition
(<name>!foo</name>, no value) fires when the property is *absent* —
the common "opt-out flag" idiom.  Such profiles are on by default and
can only be suppressed (by setting the property), never injected by
supplying one.  They do not present the security risk that motivated
the file/property filter in withoutFileAndPropertyActivation()
(commit 03c947d).

The previous implementation treated *all* property conditions as
unsafe and filtered them out of external model builds.  This broke
effective model construction for any POM that relied on
negated-property profiles to inject dependency versions —
resteasy-client:7.0.0.Final is a canonical example (its
resteasy-default profile activates on <!resteasy.dependencies.eap>).
When those versions were missing, the effective-model validator
reported them as errors and threw a ModelBuildingException.

Fix: both the compat (DefaultModelBuilder) and the Maven 4 impl
(DefaultModelBuilder / hasFileOrPropertyOrConditionActivation)
now treat a negated-name-only property condition as environment-
independent and allow it through.  All other property conditions
(positive name, or a required value) remain blocked.  The existing
repository-stripping step is unaffected, so external models still
cannot inject repositories.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@gnodet gnodet added the bug Something isn't working label Sep 10, 2026
@gnodet gnodet added this to the 3.10.0 milestone Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3.10.x fails on org.jboss.resteasy:resteasy-client:jar:7.0.0.Final

1 participant