diff --git a/dependency_check_suppressions.xml b/dependency_check_suppressions.xml
index f187fca9..7e822060 100755
--- a/dependency_check_suppressions.xml
+++ b/dependency_check_suppressions.xml
@@ -29,6 +29,8 @@
CVE-2021-22569
CVE-2022-3171
CVE-2022-3509
+ CVE-2024-7254
+ CVE-2024-7254
CVE-2021-22569
CVE-2022-3171
CVE-2022-3510
+ CVE-2024-7254
\ No newline at end of file
diff --git a/inappmessaging/src/main/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/customjson/CustomJsonDeserializer.kt b/inappmessaging/src/main/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/customjson/CustomJsonDeserializer.kt
index 36988f73..d1b5b251 100644
--- a/inappmessaging/src/main/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/customjson/CustomJsonDeserializer.kt
+++ b/inappmessaging/src/main/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/customjson/CustomJsonDeserializer.kt
@@ -7,6 +7,7 @@ import com.rakuten.tech.mobile.inappmessaging.runtime.utils.InAppLogger
import java.lang.reflect.Type
internal class CustomJsonDeserializer : JsonDeserializer {
+
override fun deserialize(json: JsonElement?, typeOfT: Type?, context: JsonDeserializationContext?): CustomJson {
val jsonObject = json?.asJsonObject
diff --git a/inappmessaging/src/main/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/responses/ping/Message.kt b/inappmessaging/src/main/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/responses/ping/Message.kt
index 0b2c2fed..5e2e6686 100644
--- a/inappmessaging/src/main/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/responses/ping/Message.kt
+++ b/inappmessaging/src/main/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/responses/ping/Message.kt
@@ -81,15 +81,20 @@ internal data class Message(
return tooltip
}
+ @SuppressWarnings("TooGenericExceptionCaught")
fun getCustomJsonData(): CustomJson? {
if (!RmcHelper.isRmcIntegrated() || customJson == null || customJson.entrySet().isEmpty()) {
return null
}
if (customJsonData == null) {
- val gson = GsonBuilder()
- .registerTypeAdapter(CustomJson::class.java, CustomJsonDeserializer())
- .create()
- customJsonData = gson.fromJson(customJson, CustomJson::class.java)
+ try {
+ val gson = GsonBuilder()
+ .registerTypeAdapter(CustomJson::class.java, CustomJsonDeserializer())
+ .create()
+ customJsonData = gson.fromJson(customJson, CustomJson::class.java)
+ } catch (_: Exception) {
+ InAppLogger(TAG).debug("getCustomJsonData - invalid customJson format")
+ }
}
return customJsonData
}
diff --git a/inappmessaging/src/test/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/responses/ping/MessageSpec.kt b/inappmessaging/src/test/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/responses/ping/MessageSpec.kt
index ca6e5496..5048d1d5 100644
--- a/inappmessaging/src/test/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/responses/ping/MessageSpec.kt
+++ b/inappmessaging/src/test/java/com/rakuten/tech/mobile/inappmessaging/runtime/data/responses/ping/MessageSpec.kt
@@ -2,6 +2,7 @@ package com.rakuten.tech.mobile.inappmessaging.runtime.data.responses.ping
import com.google.gson.JsonParser
import com.rakuten.tech.mobile.inappmessaging.runtime.RmcHelper
+import com.rakuten.tech.mobile.inappmessaging.runtime.data.customjson.Background
import com.rakuten.tech.mobile.inappmessaging.runtime.data.customjson.CustomJson
import com.rakuten.tech.mobile.inappmessaging.runtime.data.customjson.PushPrimer
import com.rakuten.tech.mobile.inappmessaging.runtime.data.enums.InAppMessageType
@@ -310,7 +311,7 @@ class MessageCustomJsonSpec {
val campaign = TestDataHelper.createDummyMessage(
customJson = JsonParser.parseString("""{"pushPrimer": true}""").asJsonObject,
)
- campaign.getCustomJsonData() shouldBeEqualTo null
+ campaign.getCustomJsonData()?.pushPrimer shouldBeEqualTo null
}
@Test
@@ -340,4 +341,14 @@ class MessageCustomJsonSpec {
)
campaign.getCustomJsonData() shouldBeEqualTo CustomJson(pushPrimer = PushPrimer(button = 1))
}
+
+ @Test
+ fun `should map CustomJson data even if there is a feature key with invalid attribute`() {
+ val campaign = TestDataHelper.createDummyMessage(
+ customJson = JsonParser.parseString(
+ """{ "pushPrimer": { "button": "abcdef" }, "background": { "opacity": 0.6 } }""",
+ ).asJsonObject,
+ )
+ campaign.getCustomJsonData() shouldBeEqualTo CustomJson(background = Background(opacity = 0.6f))
+ }
}