Suppress case variants of mapped names in isPropertySuppressed - #431
Open
rootvector2 wants to merge 1 commit into
Open
Suppress case variants of mapped names in isPropertySuppressed#431rootvector2 wants to merge 1 commit into
rootvector2 wants to merge 1 commit into
Conversation
The check compared the raw expression token, while the mapped-descriptor fallback it guards derives its accessor names from the capitalized property name, so a name differing only in the case of its first character resolved the same accessors and was still readable and writable.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR closes a suppression bypass for mapped properties where case-variants of the property token (e.g., MappedProperty(key) vs mappedProperty(key)) could still resolve the same mapped accessor pair and remain readable/writable despite suppression.
Changes:
- Align
isPropertySuppressed()withMappedPropertyDescriptor’s accessor-name derivation by comparing suppressed names on the same capitalized base form. - Expose
MappedPropertyDescriptor.capitalizePropertyName()at package scope to avoid duplication/drift in capitalization logic. - Add a regression test covering suppression of a mapped-property case variant.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/test/java/org/apache/commons/beanutils2/PropertyUtilsTest.java | Adds a regression test ensuring case-variants of suppressed mapped properties are also blocked. |
| src/main/java/org/apache/commons/beanutils2/PropertyUtilsBean.java | Updates suppression check to compare on the capitalized base name used for mapped accessor resolution. |
| src/main/java/org/apache/commons/beanutils2/MappedPropertyDescriptor.java | Makes capitalizePropertyName package-private so the suppression logic can reuse the same derivation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return true; | ||
| if (introspector instanceof SuppressPropertiesBeanIntrospector) { | ||
| for (final String suppressed : ((SuppressPropertiesBeanIntrospector) introspector).getSuppressedProperties()) { | ||
| if (base.equals(MappedPropertyDescriptor.capitalizePropertyName(suppressed))) { |
Member
|
@rootvector2 see copilot comments. If you ran copilot on your own branch before creating a PR, we could save some time here. |
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.
isPropertySuppressedcompares the raw expression token against the suppressed set, but the mapped-descriptor fallback it guards buildsget<Base>(String)/set<Base>(String, ?)fromMappedPropertyDescriptor.capitalizePropertyName(name), so any name that differs only in the case of its first character resolves the same accessor pair and is never matched by the check. WithmappedPropertysuppressed,mappedProperty(key)is blocked butMappedProperty(key)still reads and writes it, including throughBeanUtilsBean.populatewith a caller-supplied parameter map. Mapped accessors are never JavaBeans property descriptors, sodata.getDescriptor(name)is always null for them and this check is the only thing in front of the accessor.Comparing on the same capitalized base the descriptor derives keeps the guard and the descriptor from drifting apart again;
capitalizePropertyNamedrops to package-private for that. Found while re-auditing the suppression path from #413.PropertyUtilsTest.testCustomIntrospectionSuppressedMappedPropertyCaseVariantfails without the runtime change (MappedPropertystill resolves aMappedPropertyDescriptor) and passes with it. Fullmvndefault goal is green: 1284 tests, 0 failures.mvn; that'smvnon the command line by itself.