On Fri, Sep 27, 2019 at 3:43 AM Guido Medina <
oxy...@gmail.com> wrote:
>
> Had to go back to LaissezFaireSubTypeValidator.instance as I'm getting an exception when using the default generated by BasicPolymorphicTypeValidator.builder().build()
Yes. This is a very important point, regarding security (as per
https://medium.com/@cowtowncoder/on-jackson-cves-dont-panic-here-is-what-you-need-to-know-54cd0d6e8062):
- Default state for `BasicPolymorphictypeValidator` is NOT to allow
any type when asked: you will need to add "allow" rules.
- `LaissezFairSubTypeValidator` is only provided for
backwards-compatibility needs: I do not recommend its use (and it will
not be included in 3.0) BUT can be used on 2.x for, ideally only for
tests.
Also note that validator is not called for types for which
deserializer is explicitly registered: so, most JDK types, 3rd party
datatypes handled by datatype libraries, are fine as-is.
In practice it's your POJOs (Beans) and, well, malicious gadgets ( :)
) that will be validated.
-+ Tatu +-
>
> On Friday, September 27, 2019 at 11:32:31 AM UTC+1, Guido Medina wrote:
>>
>> Though this form look more standard?
>>
>>
>> public static final ObjectMapper USER_PREFS_MAPPER = configureDefaultObjectMapper(JsonMapper.builder(SmileFactory.builder()
>> .disable(ENCODE_BINARY_AS_7BIT)
>> .enable(CHECK_SHARED_STRING_VALUES)
>> .build())
>> .activateDefaultTyping(BasicPolymorphicTypeValidator.builder().build(), ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT, JsonTypeInfo.As.WRAPPER_ARRAY).build()
>> );
>>
>>
>>
>> On Friday, September 27, 2019 at 11:25:36 AM UTC+1, Guido Medina wrote:
>>>
>>> So, will then the following provide me the same functionality?
>>>
>>> public static final ObjectMapper USER_PREFS_MAPPER = configureDefaultObjectMapper(JsonMapper.builder(
>>> SmileFactory.builder()
>>> .disable(ENCODE_BINARY_AS_7BIT)
>>> .enable(CHECK_SHARED_STRING_VALUES)
>>> .build())
>>> .activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT, JsonTypeInfo.As.WRAPPER_ARRAY).build()
>>> );
>>>
>>>
>>>
>>> On Friday, September 27, 2019 at 10:41:53 AM UTC+1, Marc Dzaebel wrote:
>>>>
>>>> Guido,
>>>>
>>>> I already asked such questions in the "polymorphic serialization" issue but I agree, that we'd need an adapted documentation on this topic. You might look in test samples with JsonMapper.builder().activateDefaultTyping(...).
>>>>
>>>> Marc
>
> --
> You received this message because you are subscribed to the Google Groups "jackson-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
jackson-user...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/jackson-user/ab3aa977-0e57-4969-93fe-c074ef3124d5%40googlegroups.com.