Enable deserialisation for certain package from Oracle database drivers. (#298)

* Oracle database drivers ojdbc7.jar and ojdbc8.jar use deserialisation which is disabled by the default in Corda. Added an Oracle package to serialFilter when the node uses Oracle database.
This commit is contained in:
szymonsztuka 2018-01-09 18:25:54 +00:00 committed by GitHub
parent 40edc286f5
commit c7487a8696
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -173,4 +173,7 @@ class HibernateConfiguration(
return "corda-wrapper-binary"
}
}
}
}
/** Allow Oracle database drivers ojdbc7.jar and ojdbc8.jar to deserialize classes from oracle.sql.converter package. */
fun oracleJdbcDriverSerialFilter(clazz: Class<*>) : Boolean = clazz.name.startsWith("oracle.sql.converter.")

View File

@ -13,6 +13,7 @@ import net.corda.node.shell.InteractiveShell
import net.corda.node.utilities.registration.HTTPNetworkRegistrationService
import net.corda.node.utilities.registration.NetworkRegistrationHelper
import net.corda.nodeapi.internal.addShutdownHook
import net.corda.nodeapi.internal.persistence.oracleJdbcDriverSerialFilter
import org.fusesource.jansi.Ansi
import org.fusesource.jansi.AnsiConsole
import org.slf4j.bridge.SLF4JBridgeHandler
@ -201,7 +202,19 @@ open class NodeStartup(val args: Array<String>) {
open protected fun loadConfigFile(cmdlineOptions: CmdLineOptions): NodeConfiguration = cmdlineOptions.loadConfig()
open protected fun banJavaSerialisation(conf: NodeConfiguration) {
SerialFilter.install(if (conf.notary?.bftSMaRt != null) ::bftSMaRtSerialFilter else ::defaultSerialFilter)
val isOracleDbDriver = conf.dataSourceProperties.getProperty("dataSource.url", "").startsWith("jdbc:oracle:")
val filter =
if (conf.notary?.bftSMaRt != null && isOracleDbDriver) {
val bftAndOracleSerialFilter: (Class<*>) -> Boolean = { clazz -> bftSMaRtSerialFilter(clazz) || oracleJdbcDriverSerialFilter(clazz) }
bftAndOracleSerialFilter
} else if (conf.notary?.bftSMaRt != null) {
::bftSMaRtSerialFilter
} else if (isOracleDbDriver) {
::oracleJdbcDriverSerialFilter
} else {
::defaultSerialFilter
}
SerialFilter.install(filter)
}
open protected fun getVersionInfo(): VersionInfo {