-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28ec8a4
commit 6ce32ff
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
40 changes: 40 additions & 0 deletions
40
src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.fasterxml.jackson.databind.interop; | ||
|
||
import com.fasterxml.jackson.databind.*; | ||
|
||
/** | ||
* Test case(s) to guard against handling of types that are illegal to handle | ||
* due to security constraints. | ||
*/ | ||
public class IllegalTypesCheckTest extends BaseMapTest | ||
{ | ||
static class Bean1599 { | ||
public int id; | ||
public Object obj; | ||
} | ||
|
||
public void testIssue1599() throws Exception | ||
{ | ||
final String JSON = aposToQuotes( | ||
"{'id': 124,\n" | ||
+" 'obj':[ 'com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl',\n" | ||
+" {\n" | ||
+" 'transletBytecodes' : [ 'AAIAZQ==' ],\n" | ||
+" 'transletName' : 'a.b',\n" | ||
+" 'outputProperties' : { }\n" | ||
+" }\n" | ||
+" ]\n" | ||
+"}" | ||
); | ||
ObjectMapper mapper = new ObjectMapper(); | ||
mapper.enableDefaultTyping(); | ||
try { | ||
mapper.readValue(JSON, Bean1599.class); | ||
fail("Should not pass"); | ||
} catch (JsonMappingException e) { | ||
verifyException(e, "Illegal type"); | ||
verifyException(e, "to deserialize"); | ||
verifyException(e, "prevented for security reasons"); | ||
} | ||
} | ||
} |
6ce32ff
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.
there is a null exception!
because you did not set _tfactory property
6ce32ff
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.
@nike022812 I don't think that matters here as the goal is to ensure there is security exception; if not it does not matter if it fails for NPE or passes -- code should never reach that far.
6ce32ff
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.
please try in jdk 1.7
6ce32ff
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.
@ayound Please try what? Test passes on JDK 1.7 for me.