Kafka Audit Service : Error with CBA using dg-generic node template 48/107648/1
authorJulien Fontaine <julien.fontaine@bell.ca>
Thu, 14 May 2020 00:29:56 +0000 (20:29 -0400)
committerJulien Fontaine <julien.fontaine@bell.ca>
Thu, 14 May 2020 00:29:56 +0000 (20:29 -0400)
* Fixed issue with dg-generic node template
* Changed behaviour for hiding sensitive data -> Instead of just checking the node-template targeted by the workflow, we check every node-template declared in the CBA. If we find one or more component-resource-resolution node-template, we verify if we need to hide sensitive data in the kafka message.

Issue-ID: CCSDK-2372
Signed-off-by: Julien Fontaine <julien.fontaine@bell.ca>
Change-Id: I079ee29ae532b3947cdc8efe3438678309ca50b7

ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/KafkaPublishAuditService.kt

index e26af2b..5c522e7 100644 (file)
@@ -239,4 +239,6 @@ object BluePrintConstants {
     const val PROPERTY_CLUSTER_NODE_ADDRESS = "CLUSTER_NODE_ADDRESS"
     const val PROPERTY_CLUSTER_JOIN_AS_CLIENT = "CLUSTER_JOIN_AS_CLIENT"
     const val PROPERTY_CLUSTER_CONFIG_FILE = "CLUSTER_CONFIG_FILE"
+
+    const val NODE_TEMPLATE_TYPE_COMPONENT_RESOURCE_RESOLUTION = "component-resource-resolution"
 }
index 9f406f7..9ac11c7 100644 (file)
@@ -23,6 +23,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutp
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
 import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BluePrintMessageLibPropertyService
 import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BlueprintMessageProducerService
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
 import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
 import org.onap.ccsdk.cds.controllerblueprints.core.common.ApplicationConstants
@@ -144,33 +145,40 @@ class KafkaPublishAuditService(
             val blueprintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(requestId, basePath.toString())
             val blueprintContext = blueprintRuntimeService.bluePrintContext()
 
-            val nodeTemplateName = blueprintContext.workflowFirstStepNodeTemplate(workflowName)
-            val interfaceName = blueprintContext.nodeTemplateFirstInterfaceName(nodeTemplateName)
-            val operationName = blueprintContext.nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName)
-
-            val propertyAssignments: MutableMap<String, JsonNode> =
-                    blueprintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)
-                            ?: hashMapOf()
-
-            val artifactPrefixNamesNode = propertyAssignments[ResourceResolutionConstants.INPUT_ARTIFACT_PREFIX_NAMES]
-            val artifactPrefixNames = JacksonUtils.getListFromJsonNode(artifactPrefixNamesNode!!, String::class.java)
-
-            /** Storing mapping entries with metadata log-protect set to true */
-            val sensitiveParameters: List<String> = artifactPrefixNames
-                    .map { "$it-mapping" }
-                    .map { blueprintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, it) }
-                    .flatMap { JacksonUtils.getListFromJson(it, ResourceAssignment::class.java) }
-                    .filter { PropertyDefinitionUtils.hasLogProtect(it.property) }
-                    .map { it.name }
-
-            /** Hiding sensitive input parameters from the request */
-            var workflowProperties: ObjectNode = clonedExecutionServiceInput.payload
-                    .path("$workflowName-request")
-                    .path("$workflowName-properties") as ObjectNode
-
-            sensitiveParameters.forEach { sensitiveParameter ->
-                if (workflowProperties.has(sensitiveParameter)) {
-                    workflowProperties.replace(sensitiveParameter, ApplicationConstants.LOG_REDACTED.asJsonPrimitive())
+            /** Looking for node templates defined as component-resource-resolution */
+            val nodeTemplates = blueprintContext.nodeTemplates()
+            nodeTemplates!!.forEach { nodeTemplate ->
+                val nodeTemplateName = nodeTemplate.key
+                val nodeTemplateType = blueprintContext.nodeTemplateByName(nodeTemplateName).type
+                if (nodeTemplateType == BluePrintConstants.NODE_TEMPLATE_TYPE_COMPONENT_RESOURCE_RESOLUTION) {
+                    val interfaceName = blueprintContext.nodeTemplateFirstInterfaceName(nodeTemplateName)
+                    val operationName = blueprintContext.nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName)
+
+                    val propertyAssignments: MutableMap<String, JsonNode> =
+                            blueprintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)
+                                    ?: hashMapOf()
+
+                    val artifactPrefixNamesNode = propertyAssignments[ResourceResolutionConstants.INPUT_ARTIFACT_PREFIX_NAMES]
+                    val artifactPrefixNames = JacksonUtils.getListFromJsonNode(artifactPrefixNamesNode!!, String::class.java)
+
+                    /** Storing mapping entries with metadata log-protect set to true */
+                    val sensitiveParameters: List<String> = artifactPrefixNames
+                            .map { "$it-mapping" }
+                            .map { blueprintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, it) }
+                            .flatMap { JacksonUtils.getListFromJson(it, ResourceAssignment::class.java) }
+                            .filter { PropertyDefinitionUtils.hasLogProtect(it.property) }
+                            .map { it.name }
+
+                    /** Hiding sensitive input parameters from the request */
+                    var workflowProperties: ObjectNode = clonedExecutionServiceInput.payload
+                            .path("$workflowName-request")
+                            .path("$workflowName-properties") as ObjectNode
+
+                    sensitiveParameters.forEach { sensitiveParameter ->
+                        if (workflowProperties.has(sensitiveParameter)) {
+                            workflowProperties.replace(sensitiveParameter, ApplicationConstants.LOG_REDACTED.asJsonPrimitive())
+                        }
+                    }
                 }
             }
         }