TOMEE-4654 - Make the component naming context read-only by default#2846
Open
jungm wants to merge 1 commit into
Open
TOMEE-4654 - Make the component naming context read-only by default#2846jungm wants to merge 1 commit into
jungm wants to merge 1 commit into
Conversation
The Enterprise Beans spec (10.4.4) and EE.5.3.4 require java:comp and its subcontexts to be read-only inside a deployed application: write attempts must not take effect. The IvmContext read-only machinery already existed but was gated behind openejb.forceReadOnlyAppNamingContext, which defaulted to false, so every deployed application received a fully writable ENC. Flip that default to true (retained as an explicit opt-out for backward compatibility) and extend the enforcement to the web and app contexts. Servlets and JSF managed beans resolve java:comp/java:module/java:app through the WebContext and AppContext rather than a BeanContext, so marking only the BeanContexts read-only left the web tier writable. Adds JavaCompReadOnlyTest, which deploys a real application and asserts that bind/rebind/rename/unbind/createSubcontext/destroySubcontext are all refused on java:comp and java:app, and inverts AppNamingReadOnlyTest, whose former testAppNamingContextWritableByDefault asserted the exact behaviour being fixed.
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.
What
Makes the
java:compcomponent naming context read-only by default, as the Enterprise Beans spec (10.4.4) and EE.5.3.4 require: write attempts against a deployed application's ENC must not take effect.Why
The
IvmContextread-only enforcement already existed and was correct —checkReadOnly()throwsOperationNotSupportedExceptionandsetReadOnly()cascades through the whole name tree. But nothing ever turned it on:openejb.forceReadOnlyAppNamingContextdefaulted tofalse, so every deployed application got a fully writablejava:comp, lettingbind/rebind/renamethrough where the spec requires them refused.Changes
Assembler: defaultopenejb.forceReadOnlyAppNamingContexttotrue(kept as an explicit opt-out for anyone depending on the old writable behaviour).Assembler.setAppNamingContextReadOnly: also mark theWebContextandAppContextnaming contexts read-only. Servlets and JSF managed beans resolvejava:comp/java:module/java:appthrough those contexts rather than through aBeanContext, so marking only theBeanContexts left the web tier writable. The one late write to the app context (app/BeanManager) happens before this point, so it is unaffected.JavaCompReadOnlyTest(new): deploys a real application and assertsbind/rebind/rename/unbind/createSubcontext/destroySubcontextare all refused onjava:compandjava:app, that nothing written becomes observable, and that pre-existing bindings survive.AppNamingReadOnlyTest: invertedtestAppNamingContextWritableByDefault(it asserted the exact bug) into a read-only-by-default test, plus a separate test for the opt-out path.Verification
openejb-corefull suite: 4093 tests, the only 6 failures are pre-existing security-test failures reproduced on a cleanmain(unrelated to this change).enterprise-beans-30partition against a freshly built Plume distribution: thenaming/contextwrite assertions now pass in both the EJB and web (servlet / filtered-servlet / JSF) vehicles.Reviewer notes
apache/tomee-tckrepo and is not part of this PR.org.apache.naming.NamingContextinstead ofIvmContext, sojava:comp/envlists extracomp/moduleentries andclose()fails. It is orthogonal to this read-only fix and not addressed here.🤖 Generated with Claude Code