-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates for CVE-2023-51074 and CVE-2023-5072
Updates the org.json.json and com.jayway.jsonpath.json-path libraries which fix CVE-2023-51074 and CVE-2023-5072. Had to make code changes because the json-path library introduced a bug in the updated version which fails a few unit tests in our repo. See this PR to track the issue json-path/JsonPath#871
- Loading branch information
1 parent
f96fbb3
commit 8993045
Showing
5 changed files
with
61 additions
and
7 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
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
42 changes: 42 additions & 0 deletions
42
src/test/java/com/mastercard/developer/encryption/JsonParserTest.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,42 @@ | ||
package com.mastercard.developer.encryption; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.JsonObject; | ||
import com.jayway.jsonpath.DocumentContext; | ||
import com.jayway.jsonpath.JsonPath; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertNull; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
public class JsonParserTest { | ||
|
||
@Test | ||
public void testDeleteIfExists_shouldDeleteIfElementExists() { | ||
final String key = "dummyKey"; | ||
JsonObject dummyObject = new JsonObject(); | ||
dummyObject.addProperty(key, "dummyValue"); | ||
|
||
DocumentContext context = JsonPath.parse(new Gson().toJson(dummyObject), JsonParser.jsonPathConfig); | ||
|
||
JsonParser.deleteIfExists(context, key); | ||
|
||
Object value = context.read(key); | ||
|
||
assertNull(value); | ||
} | ||
|
||
@Test | ||
public void testDeleteIfExists_doNothingIfElementDoesNotExist() { | ||
final String key = "dummyKey"; | ||
JsonObject dummyObject = new JsonObject(); | ||
dummyObject.addProperty(key, "dummyValue"); | ||
|
||
DocumentContext context = JsonPath.parse(new Gson().toJson(dummyObject), JsonParser.jsonPathConfig); | ||
|
||
JsonParser.deleteIfExists(context, "keyWhichDoesNotExist"); | ||
|
||
Object value = context.read(key); | ||
assertNotNull(value); | ||
} | ||
} |