Skip to content
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

Parseexception with ancestors fix #365

Merged

Conversation

dmeibusch
Copy link
Contributor

Fix for #363

Adds a test case for the issue, then a commit for a proposed fix.

Signed-off-by: David Meibusch <david.meibusch@oracle.com>
Explicitly handle the parsing of components when parsing from the token buffer.
This happens in `MetadataDeserializer` when the token stream is materialized to a JsonNode and then "re-parsed" (hence no longer an XML-based stream)

Signed-off-by: David Meibusch <david.meibusch@oracle.com>

wrapper.setComponents(Arrays.asList(components));

List<Component> components = Collections.emptyList();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can determine, the issue arises due to MetadataDeserializer using the shortcut of reading the tree from the XML (this is only an XML issue) token stream, then using a unconfigured ObjectMapper to convert to the target types. The context is then lost (e.g. XML parser, XML deserialization context) within child deserializers and we enter this deserializer re-parsed then tree now as plain JSON tokens with a vanilla JSON parser.

This list of components (when nested in metadata/../ancestors etc) might be absent (no tokens), a single object, or an array of objects. Fix here is to explicitly handle these cases.

Not 100% happy - still a hack on top of the existing hack to handle component object lists. 🤷

@dmeibusch dmeibusch marked this pull request as ready for review January 26, 2024 00:31
@stevespringett
Copy link
Member

Thanks for identifying the issue. I should have time to review in a week or two.

@stevespringett stevespringett merged commit cfd7d0f into CycloneDX:master May 14, 2024
4 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants