[VOL-4631] openonuAdapterGo - hardening: check ONU OMCI get responses for consistency

Change-Id: I6402b16408fd29db8d95f1607ff1af21da5907de
diff --git a/internal/pkg/swupg/omci_onu_upgrade.go b/internal/pkg/swupg/omci_onu_upgrade.go
index 369890a..006c62c 100755
--- a/internal/pkg/swupg/omci_onu_upgrade.go
+++ b/internal/pkg/swupg/omci_onu_upgrade.go
@@ -1625,15 +1625,28 @@
 			log.Fields{"device-id": oFsm.deviceID})
 		return
 	}
-
 	meAttributes := msgObj.Attributes
-	imageIsCommitted := meAttributes[me.SoftwareImage_IsCommitted].(uint8)
-	imageIsActive := meAttributes[me.SoftwareImage_IsActive].(uint8)
-	imageVersion := cmn.TrimStringFromMeOctet(meAttributes[me.SoftwareImage_Version])
-	logger.Debugw(ctx, "OnuUpgradeFsm - GetResponse Data for SoftwareImage",
-		log.Fields{"device-id": oFsm.deviceID, "entityID": msgObj.EntityInstance,
-			"version": imageVersion, "isActive": imageIsActive, "isCommitted": imageIsCommitted})
+	var imageVersion string
+	var imageIsCommitted, imageIsActive uint8
 
+	if softwareImageIsCommitted, ok := meAttributes[me.SoftwareImage_IsCommitted]; ok {
+		if softwareImageIsActiveimage, ok := meAttributes[me.SoftwareImage_IsActive]; ok {
+			if softwareImageVersion, ok := meAttributes[me.SoftwareImage_Version]; ok {
+				imageIsCommitted = softwareImageIsCommitted.(uint8)
+				imageIsActive = softwareImageIsActiveimage.(uint8)
+				imageVersion = cmn.TrimStringFromMeOctet(softwareImageVersion)
+				logger.Debugw(ctx, "OnuUpgradeFsm - GetResponse Data for SoftwareImage",
+					log.Fields{"device-id": oFsm.deviceID, "entityID": msgObj.EntityInstance,
+						"version": imageVersion, "isActive": imageIsActive, "isCommitted": imageIsCommitted})
+			} else {
+				logger.Errorw(ctx,
+					"OnuUpgradeFsm - Not all mandatory attributes present in in SoftwareImage instance - handling stopped!",
+					log.Fields{"device-id": oFsm.deviceID})
+				oFsm.abortOnOmciError(ctx, false)
+				return
+			}
+		}
+	}
 	if oFsm.PAdaptFsm.PFsm.Current() == UpgradeStCheckImageName {
 		//image name check after EndSwDownload, this state (and block) can only be taken if APIVersion43 is used
 		oFsm.verifyOnuSwStatusAfterDownload(ctx, msgObj.EntityInstance, imageVersion, imageIsActive, imageIsCommitted)
diff --git a/internal/pkg/swupg/onu_image_status.go b/internal/pkg/swupg/onu_image_status.go
index 02d92bc..ae798d0 100755
--- a/internal/pkg/swupg/onu_image_status.go
+++ b/internal/pkg/swupg/onu_image_status.go
@@ -207,11 +207,14 @@
 
 	if _, ok := oo.requestedAttributes[me.SoftwareImage_Version]; ok {
 		if msgObj.Result != me.Success {
-			logger.Errorw(ctx, "processAttributesReceived retrieval of mandatory attributes failed",
+			logger.Errorw(ctx, "processAttributesReceived - retrieval of mandatory attributes not successful",
 				log.Fields{"device-id": oo.deviceID})
-			return fmt.Errorf("process-image-status-response-error")
+			return fmt.Errorf("retrieve-mandatory-attributes-not-successful")
 		}
-		oo.pDevEntry.HandleSwImageIndications(ctx, msgObj.EntityInstance, meAttributes)
+		if !oo.pDevEntry.HandleSwImageIndications(ctx, msgObj.EntityInstance, meAttributes) {
+			logger.Errorw(ctx, "processAttributesReceived - not all mandatory attributes present in SoftwareImage instance", log.Fields{"device-id": oo.deviceID})
+			return fmt.Errorf("not-all-mandatory-attributes-present")
+		}
 	}
 	for k := range oo.requestedAttributes {
 		switch k {