Remote Python executor unescapes script parameter values 14/90314/1
authorSerge Simard <serge@agilitae.com>
Fri, 21 Jun 2019 14:56:52 +0000 (10:56 -0400)
committerSerge Simard <serge@agilitae.com>
Fri, 21 Jun 2019 14:56:52 +0000 (10:56 -0400)
Issue-ID: CCSDK-1426
Signed-off-by: Serge Simard <serge@agilitae.com>
Change-Id: I919e30b76bb472b4e0aeeb2294f0b3087a655efd

ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt

index 4ef1cfb..398c6c9 100644 (file)
@@ -16,6 +16,7 @@
 
 package org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor
 
+import com.fasterxml.jackson.databind.JsonNode
 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.*
 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction
 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ExecutionServiceConstant
@@ -74,8 +75,19 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
         val dynamicProperties = getOptionalOperationInput(INPUT_DYNAMIC_PROPERTIES)
         val packages = getOptionalOperationInput(INPUT_PACKAGES)?.returnNullIfMissing()
 
-        val args = getOptionalOperationInput(INPUT_ARGUMENT_PROPERTIES)?.returnNullIfMissing()
-                ?.rootFieldsToMap()?.toSortedMap()?.values?.map { it.textValue() }?.joinToString(" ")
+        val argsNode = getOptionalOperationInput(INPUT_ARGUMENT_PROPERTIES)?.returnNullIfMissing()
+
+        // This prevents unescaping values, as well as quoting the each parameter, in order to allow for spaces in values
+        var args = ""
+        argsNode?.fields()?.forEach {
+            if (it.value.isValueNode) {
+                args = "$args ${it.value}"
+            } else {
+                it.value.fields().forEach { item ->
+                    args = "$args ${item.value}"
+                }
+            }
+        }
 
         val command = getOperationInput(INPUT_COMMAND).asText()
         var scriptCommand = command.replace(pythonScript.name, pythonScript.absolutePath)