From 7010ea90e14305837a30764db8a5e4bc1338e378 Mon Sep 17 00:00:00 2001 From: aribeiro Date: Mon, 15 Feb 2021 17:24:11 +0000 Subject: Fix Security Vulnerabilities Issue-ID: SDC-3500 Signed-off-by: aribeiro Change-Id: I3fa2ed2bc3a170d8256fbc91c98bbfbaf5c0a403 --- .../app/services/components/component-service.ts | 52 +++++++++++++++++----- 1 file changed, 41 insertions(+), 11 deletions(-) (limited to 'catalog-ui/src/app/services/components') diff --git a/catalog-ui/src/app/services/components/component-service.ts b/catalog-ui/src/app/services/components/component-service.ts index f22562f439..47eec26a77 100644 --- a/catalog-ui/src/app/services/components/component-service.ts +++ b/catalog-ui/src/app/services/components/component-service.ts @@ -19,8 +19,25 @@ */ 'use strict'; import * as _ from "lodash"; -import {ArtifactModel, IFileDownload, InstancesInputsPropertiesMap, InputModel, IValidate, RelationshipModel, PropertyModel, Component, ComponentInstance, - AttributeModel, IAppConfigurtaion, Resource, Module, DisplayModule, ArtifactGroupModel, InputsAndProperties} from "app/models"; +import { + ArtifactModel, + IFileDownload, + InstancesInputsPropertiesMap, + InputModel, + IValidate, + RelationshipModel, + PropertyModel, + Component, + ComponentInstance, + AttributeModel, + IAppConfigurtaion, + Resource, + Module, + DisplayModule, + ArtifactGroupModel, + InputsAndProperties, + AsdcComment +} from "app/models"; import {ComponentInstanceFactory, CommonUtils} from "app/utils"; import {SharingService} from "app/services-ng2"; import {ComponentMetadata} from "../../models/component-metadata"; @@ -29,7 +46,7 @@ export interface IComponentService { getComponent(id:string); updateComponent(component:Component):ng.IPromise; - changeLifecycleState(component:Component, state:string, userRemarks:any):ng.IPromise ; + changeLifecycleState(component:Component, state:string, userRemarks:AsdcComment):ng.IPromise ; validateName(newName:string, subtype?:string):ng.IPromise; createComponent(component:Component):ng.IPromise; //importComponent @@ -233,15 +250,28 @@ export class ComponentService implements IComponentService { return deferred.promise; }; - public changeLifecycleState = (component:Component, state:string, userRemarks:any):ng.IPromise => { + public changeLifecycleState = (component:Component, state:string, commentObj:AsdcComment):ng.IPromise => { let deferred = this.$q.defer(); - this.restangular.one(component.uniqueId).one(state).customPOST(userRemarks).then((response:ComponentMetadata) => { - this.sharingService.addUuidValue(response.uniqueId, response.uuid); - let component:ComponentMetadata = new ComponentMetadata().deserialize(response); - deferred.resolve(component); - }, (err)=> { - deferred.reject(err); - }); + let headerObj = {}; + if (commentObj.userRemarks) { + headerObj = this.getHeaderMd5(commentObj); + this.restangular.one(component.uniqueId).one(state).customPOST(JSON.stringify(commentObj), '', {}, headerObj) + .then((response:ComponentMetadata) => { + this.sharingService.addUuidValue(response.uniqueId, response.uuid); + let component:ComponentMetadata = new ComponentMetadata().deserialize(response); + deferred.resolve(component); + }, (err)=> { + deferred.reject(err); + }); + } else { + this.restangular.one(component.uniqueId).one(state).customPOST().then((response:ComponentMetadata) => { + this.sharingService.addUuidValue(response.uniqueId, response.uuid); + let component:ComponentMetadata = new ComponentMetadata().deserialize(response); + deferred.resolve(component); + }, (err)=> { + deferred.reject(err); + }); + } return deferred.promise; }; -- cgit 1.2.3-korg