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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-63343] Validate element types for collections and maps when deserializing XML files #9727
[JENKINS-63343] Validate element types for collections and maps when deserializing XML files #9727
Changes from all commits
2f4e04c
966f598
0944533
61db49c
09ca355
db6f157
b37ca86
c1af611
312e51c
801c3e7
df2ac81
bc2cf4d
013bd6e
c8000fa
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check warning on line 86 in core/src/main/java/hudson/util/RobustCollectionConverter.java
ci.jenkins.io / Code Coverage
Partially covered line
Check warning on line 75 in core/src/main/java/hudson/util/RobustMapConverter.java
ci.jenkins.io / Code Coverage
Partially covered line
Check warning on line 457 in core/src/main/java/hudson/util/RobustReflectionConverter.java
ci.jenkins.io / Code Coverage
Partially covered line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #9727 (comment) for discussion about cases where
converter
is not null. In short, I don't think we care.I am not sure though whether this method covers all of the cases we care about. It seems like we may need similar changes related to "implicit collections". I will look into that a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifically, prior to this line, I think we should look up the field and then add code comparable to what we added to
RobustCollectionConverter
to validate the value type:jenkins/core/src/main/java/hudson/util/RobustReflectionConverter.java
Line 477 in 1836bd6
Needs to be investigated with a test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked into the cases related to implicit collections today. My understanding is that you need to explicitly call
addImplicitArray
,addImplicitCollection
, oraddImplicitMap
for the relevant code to matter, which is not very common, see here (there are also a few usages in CloudBees plugins). The overloads where you specify the item type already avoid JENKINS-63343 because ofgetFieldNameForItemTypeAndName
here which usescontext.getRequiredType()
leading to invalid elements being silently ignored. The overloads for arrays and maps seem to not actually work at all due to this check (which leaves me somewhat confused about #2621, but perhaps my testing did not cover all cases).So, I think we do not really care much about implicit collections, but 09ca355 should handle them too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit awkward to recreate this for every single field being unmarshalled, should we keep an instance as a local field just for these
canConvert
calls?