Skip to content

Prevent kotlinx.serialization usage on collection of interfaces #26371

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

Closed
sdeleuze opened this issue Jan 12, 2021 · 0 comments
Closed

Prevent kotlinx.serialization usage on collection of interfaces #26371

sdeleuze opened this issue Jan 12, 2021 · 0 comments
Assignees
Milestone

Comments

@sdeleuze
Copy link
Contributor

As a refinement of #26298, we should disable out of the box open polymorphic serialization for collections using something like:

// Pseudocode, not tested
fun hasPolymorphism(serializer: KSerializer<*>): Boolean = hasPolymorphism(serializer.descriptor)
fun hasPolymorphism(descriptor: SerialDescriptor): Boolean {
    if (descriptor.kind == PolymorphicKind.OPEN.INSTANCE) return true
    for (i in 0 until descriptor.elementsCount) {
        // TODO circuit breaker for recursive types
        if (hasPolymorphism(descriptor.getElementDescriptor(i)) return true
    }
   return false
}
@sdeleuze sdeleuze added this to the 5.3.4 milestone Jan 12, 2021
@sdeleuze sdeleuze self-assigned this Jan 12, 2021
lxbzmy pushed a commit to lxbzmy/spring-framework that referenced this issue Mar 26, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
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

No branches or pull requests

1 participant