From e60b816b19e23da0ecdbfee9f4d0f08e172e27af Mon Sep 17 00:00:00 2001 From: ags Date: Wed, 28 Mar 2018 14:28:55 +0100 Subject: [PATCH 1/5] double quotes in reference conf confuse people --- node/src/main/resources/reference.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/node/src/main/resources/reference.conf b/node/src/main/resources/reference.conf index c4f7fe169a..f3c83ef9f7 100644 --- a/node/src/main/resources/reference.conf +++ b/node/src/main/resources/reference.conf @@ -4,9 +4,9 @@ keyStorePassword = "cordacadevpass" trustStorePassword = "trustpass" dataSourceProperties = { dataSourceClassName = org.h2.jdbcx.JdbcDataSource - "dataSource.url" = "jdbc:h2:file:"${baseDirectory}"/persistence;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=10000;WRITE_DELAY=100;AUTO_SERVER_PORT="${h2port} - "dataSource.user" = sa - "dataSource.password" = "" + dataSource.url = "jdbc:h2:file:"${baseDirectory}"/persistence;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=10000;WRITE_DELAY=100;AUTO_SERVER_PORT="${h2port} + dataSource.user = sa + dataSource.password = "" } database = { transactionIsolationLevel = "REPEATABLE_READ" From 51567e944dc96499d14c53d490db6e9437ee9b4b Mon Sep 17 00:00:00 2001 From: ags Date: Wed, 28 Mar 2018 15:23:12 +0100 Subject: [PATCH 2/5] detect quotes in config keys --- .../net/corda/node/services/config/ConfigUtilities.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/node/src/main/kotlin/net/corda/node/services/config/ConfigUtilities.kt b/node/src/main/kotlin/net/corda/node/services/config/ConfigUtilities.kt index 1921632e90..8401df82f4 100644 --- a/node/src/main/kotlin/net/corda/node/services/config/ConfigUtilities.kt +++ b/node/src/main/kotlin/net/corda/node/services/config/ConfigUtilities.kt @@ -10,6 +10,7 @@ import net.corda.core.internal.div import net.corda.core.internal.exists import net.corda.nodeapi.internal.* import net.corda.nodeapi.internal.config.SSLConfiguration +import net.corda.nodeapi.internal.config.toProperties import net.corda.nodeapi.internal.crypto.X509KeyStore import net.corda.nodeapi.internal.crypto.loadKeyStore import net.corda.nodeapi.internal.crypto.save @@ -35,7 +36,16 @@ object ConfigHelper { .withFallback(appConfig) .withFallback(defaultConfig) .resolve() + + log.info("Config:\n${finalConfig.root().render(ConfigRenderOptions.defaults())}") + + val entrySet = finalConfig.entrySet().filter { entry -> entry.key.contains("\"") } + for (mutableEntry in entrySet) { + val key = mutableEntry.key + log.error("Config files should not contain \" in property names. Please fix: ${key}") + } + return finalConfig } } From 43ead6424036e5473c72bab60c101aa892a63011 Mon Sep 17 00:00:00 2001 From: ags Date: Wed, 28 Mar 2018 15:54:58 +0100 Subject: [PATCH 3/5] updating docs --- docs/source/corda-configuration-file.rst | 2 ++ .../example-code/src/main/resources/example-node.conf | 6 +++--- .../net/corda/node/services/config/ConfigUtilities.kt | 3 +-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/source/corda-configuration-file.rst b/docs/source/corda-configuration-file.rst index 01b615c417..e4477a62f9 100644 --- a/docs/source/corda-configuration-file.rst +++ b/docs/source/corda-configuration-file.rst @@ -22,6 +22,8 @@ Format The Corda configuration file uses the HOCON format which is superset of JSON. Please visit ``_ for further details. +Please do NOT use double quotes in configuration keys. + Defaults -------- A set of default configuration options are loaded from the built-in resource file ``/node/src/main/resources/reference.conf``. diff --git a/docs/source/example-code/src/main/resources/example-node.conf b/docs/source/example-code/src/main/resources/example-node.conf index 06e9fae078..48595226ab 100644 --- a/docs/source/example-code/src/main/resources/example-node.conf +++ b/docs/source/example-code/src/main/resources/example-node.conf @@ -3,9 +3,9 @@ keyStorePassword : "cordacadevpass" trustStorePassword : "trustpass" dataSourceProperties : { dataSourceClassName : org.h2.jdbcx.JdbcDataSource - "dataSource.url" : "jdbc:h2:file:"${baseDirectory}"/persistence" - "dataSource.user" : sa - "dataSource.password" : "" + dataSource.url : "jdbc:h2:file:"${baseDirectory}"/persistence" + dataSource.user : sa + dataSource.password : "" } p2pAddress : "my-corda-node:10002" rpcSettings = { diff --git a/node/src/main/kotlin/net/corda/node/services/config/ConfigUtilities.kt b/node/src/main/kotlin/net/corda/node/services/config/ConfigUtilities.kt index 8401df82f4..f7dc7f73f2 100644 --- a/node/src/main/kotlin/net/corda/node/services/config/ConfigUtilities.kt +++ b/node/src/main/kotlin/net/corda/node/services/config/ConfigUtilities.kt @@ -10,7 +10,6 @@ import net.corda.core.internal.div import net.corda.core.internal.exists import net.corda.nodeapi.internal.* import net.corda.nodeapi.internal.config.SSLConfiguration -import net.corda.nodeapi.internal.config.toProperties import net.corda.nodeapi.internal.crypto.X509KeyStore import net.corda.nodeapi.internal.crypto.loadKeyStore import net.corda.nodeapi.internal.crypto.save @@ -43,7 +42,7 @@ object ConfigHelper { val entrySet = finalConfig.entrySet().filter { entry -> entry.key.contains("\"") } for (mutableEntry in entrySet) { val key = mutableEntry.key - log.error("Config files should not contain \" in property names. Please fix: ${key}") + log.error("Config files should not contain \" in property names. Please fix: ${key}") } return finalConfig From c28a16cb410d800ded1f32f5068a875ca2a1af9c Mon Sep 17 00:00:00 2001 From: szymonsztuka Date: Wed, 28 Mar 2018 17:09:42 +0100 Subject: [PATCH 4/5] Description id docs and change log. --- docs/source/changelog.rst | 2 ++ docs/source/corda-configuration-file.rst | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 4d704bd66c..cb95f072b5 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -34,6 +34,8 @@ from the previous milestone release. * Introduced a placeholder for custom properties within ``node.conf``; the property key is "custom". +* Property keys with double quotes (e.g. `"key"`) in ``node.conf`` are no longer allowed, for rationale refer to :doc:`corda-configuration-file`. + * java.math.BigInteger serialization support added. * java.security.cert.CRLReason added to the default Whitelist. diff --git a/docs/source/corda-configuration-file.rst b/docs/source/corda-configuration-file.rst index e4477a62f9..81fa11e23c 100644 --- a/docs/source/corda-configuration-file.rst +++ b/docs/source/corda-configuration-file.rst @@ -22,7 +22,14 @@ Format The Corda configuration file uses the HOCON format which is superset of JSON. Please visit ``_ for further details. -Please do NOT use double quotes in configuration keys. +Please do NOT use double quotes (``"``) in configuration keys. + +Node will throw exception `Config files should not contain \" in property names. Please fix: [key]` +when it founds double quotes around keys. +This prevents configuration errors when mixing keys containing ``.`` wrapped with double quotes and without them +e.g.: +The property `"dataSourceProperties.dataSourceClassName" = "val"` in ``reference.conf`` +would be not overwritten by the property `dataSourceProperties.dataSourceClassName = "val2"` in ``node.conf``. Defaults -------- From 91036abe1888150236f295a72bf0aa0d99d5646b Mon Sep 17 00:00:00 2001 From: Andrzej Grzesik Date: Wed, 28 Mar 2018 22:41:37 +0100 Subject: [PATCH 5/5] Update corda-configuration-file.rst --- docs/source/corda-configuration-file.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/corda-configuration-file.rst b/docs/source/corda-configuration-file.rst index 81fa11e23c..f8e668cea8 100644 --- a/docs/source/corda-configuration-file.rst +++ b/docs/source/corda-configuration-file.rst @@ -24,7 +24,7 @@ The Corda configuration file uses the HOCON format which is superset of JSON. Pl Please do NOT use double quotes (``"``) in configuration keys. -Node will throw exception `Config files should not contain \" in property names. Please fix: [key]` +Node setup will log `Config files should not contain \" in property names. Please fix: [key]` as error when it founds double quotes around keys. This prevents configuration errors when mixing keys containing ``.`` wrapped with double quotes and without them e.g.: @@ -270,4 +270,4 @@ Longer term these keys will be managed in secure hardware devices. :permissions: A list of permissions for starting flows via RPC. To give the user the permission to start the flow ``foo.bar.FlowClass``, add the string ``StartFlow.foo.bar.FlowClass`` to the list. If the list contains the string ``ALL``, the user can start any flow via RPC. This value is intended for administrator - users and for development. \ No newline at end of file + users and for development.